2009-03-30

Linux networking - edit /etc/network/interfaces for auto IP assingment aka DHCP

Commonly, changing network interface IP, subnet mask or DNS used to be on GUI (Graphical User Interface). But they will be times it needs to be done on CLI (Command Line Interface). e.g. the windows manager fail to start, window manager does not provide a GUI to change it, it is a server and no GUI allowed to free up more resources or Just For Fun.

The instructions below attempt to configure eth0 for auto IP assignment from a DHCP (Dynamic Host Configuration Protocol) server. It is tested on Ubuntu and will most likely do fine on debian based distribution  :


1. Network interface settings config are stored at /etc/network/interfaces. Edit it (vi /etc/network/interfaces) using the below as reference :
# make sure below line exist for interface to auto start when /etc/init.d/networking is initiate
auto l0 eth0
iface eth0 inet dhcp


2. DNS settings are stored at /etc/resolv.conf. Edit it (vi /etc/resolv.conf) and use below for common setup :
nameserver 208.67.222.222


3. Finally, restart the interface to make the settings above take effect :
/etc/init.d/networking restart

Voilla !!!

No comments: