Home Download Ubuntu

Configure the network interfaces in Ubuntu

Short explanation for the following: The eth0 is your first network adapter, eth1 is the second, and so on. The lo is the loopback adapter that has the local adress 127.0.0.1, and you should not chance it.

See the status of your network cards:

sudo ifconfig


To see the status of a particular NIC:

sudo ifconfig eth0


To set a static ip adress to eth0:

sudo ifconfig eth0 192.168.0.1 netmask 255.255.255.0


Shutting down eth0:

sudo ifconfig eth0 down


Bring up eth0:

sudo ifconfig eth0 up


Edit Network configuration file /etc/network/interfaces and adjust it to your needs:

But first make a backup of it:

sudo cp /etc/network/interfaces /etc/network/interfaces.bak


and then

sudo nano /etc/network/interfaces


The file should look something like this:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.0.101
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1


The configuration above has the eth0 adapter as static adress with ip 192.168.0.101, netmask 255.255.255.0, gateway 192.168.0.1, etc.

Examples of static and automatic ip adress configuration:

1.Configure automatic ip adress for eth0 (if exists a DHCP server):

auto eth0
iface eth0 inet dhcp


2.Configure eth0 static ip adress:

iface eth0 inet static
address 192.168.0.2
netmask 255.255.255.0
gateway 192.168.0.1


After you have made any changes, restart networking:

sudo /etc/init.d/networking restart


Testing the connectivity:

ping -c 3 -W 10 ubuntu.com


You should see something like this:

PING ubuntu.com (82.211.81.166) 56(84) bytes of data.
64 bytes from signey.ubuntu.com (82.211.81.166): icmp_seq=1 ttl=43 time=99.9 ms
64 bytes from signey.ubuntu.com (82.211.81.166): icmp_seq=2 ttl=43 time=109 ms
64 bytes from signey.ubuntu.com (82.211.81.166): icmp_seq=3 ttl=43 time=100 ms

--- ubuntu.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2001ms
rtt min/avg/max/mdev = 99.982/103.450/109.419/4.254 ms


Resources: Ubuntu.com 1 and Ubuntu.com 2

2 comments:

Nallathmby said...

when I enter
sudo ifconfig eth0 192.168.0.1 netmask 255.255.255.0
It says Cannot assign request address
Please help me how to do this setting

Speedy Gonzales said...

I would love to help you on this one, but i haven't seen this error before. you should ask for help on ubuntu forums. There are others who had the same problem.

Post a Comment