Friday, December 5, 2008

How to configure network interfaces in ubuntu server

Ubuntu server runs in text mode by default. to setup IP Adress of LAN cards by using command line you can follow following steps:
open network interfaces file by typing:
sudo vim /etc/network/interfaces
in the files you may have no. of lines written in it. we may set all the interfaces in it. a sample for the same is as follows:
auto eth0
iface eth0 inet dhcp


"auto" keyword is to detect the ethernet card automatically when the system boots.
the second line here tells that ip address will be configured automatically from dhcp.
if we want to configure the ip address permanently or staticaly then we have to write the lines similar to following:
iface eth0 inet static
address 192.168.1.5
netmask 255.255.255.0
gateway 192.168.1.254


after writing these lines close the file by saving it . to save a file in vi editor , after completion of file press Esc and then press 'w' and then 'q'.
then to configure the newly assigned addresses restart the network services by writing:
sudo /etc/init.d/networking restart
check for the output status. it should not give any error.
now your system is in network. use ping command to check connectivity.

No comments: