Wednesday, 12 March 2014

Changing network settings in Linux

Change IP
ifconfig eth0 192.168.0.10 netmask 255.255.255.0 up
or edit configs:
Debian / Ubuntu: /etc/network/interfaces
Redhat: /etc/sysconfig/network/network-scripts/ifcfg-eth0 or run command /usr/sbin/netconfig

Add a new IP
ifconfig - a 192.168.0.11 netmask 255.255.255.0

Set default gateway
route add default gw 192.168.0.1

Change dns servers
edit resolv.conf with:
nameserver 8.8.8.8 #google public dns
nameserver 208.67.222.222 #opendns