Today, lets start with basic terminal tutorial for changing Internet Protocol address or IP address of networked computers. Let’s assume we want to give our Windows based system an IP address of 10.0.0.1, a subnet mask of 255.255.255.0, a default gateway of 10.0.0.254, and a DNS server address of 10.0.0.200.
It is possible to change or set IP address in windows machines (Windows 8, windows 7, windows xp, etc.) fro command prompt. The commands for setting static IP address are:
netsh interface ipv4 set address “local area connection” static 10.0.0.1 255.255.255.0 10.0.0.254
netsh interface ipv set dnsservers “local area connection” static 10.0.0.200
These two commands will configure the Local Area Connection with a static IP, netmask, gateway, and DNS server.
In case, if we want our network setting to get IP address from a DHCP server, the command to do it are:
netsh interface ipv4 set address name=”local area connection” source=dhcp
netsh interface ipv4 set dnsservers name=”local area connection” source=dhcp
To change the IP settings in linux, we use the ifconfig command with few parameters. like
sudo ifconfig eth0 10.0.0.1 netmask 255.255.255.0
- The interface that you want to change the IP for is eth0
- The IP you want to give the interface is 10.0.0.1
- The Subnet Mask you want to set for the interface is 255.255.255.0
To change the default gateway, we use
sudo route add default gw 10.1.1.254 eth0