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, 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 netmask

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

The configuration above has the eth0 adapter as static adress with ip, netmask, gateway, 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

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 ( 56(84) bytes of data.
64 bytes from signey.ubuntu.com ( icmp_seq=1 ttl=43 time=99.9 ms
64 bytes from signey.ubuntu.com ( icmp_seq=2 ttl=43 time=109 ms
64 bytes from signey.ubuntu.com ( 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


Nallathmby said...

when I enter
sudo ifconfig eth0 netmask
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.

Anonymous said...

Terrific tutorial, still works after all these years!

Post a Comment