Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My eth0 is using DHCP to get IP address for Internet. However I still need to set some static IP for my LAN. The following is my setting in /etc/network/interface. Any problem on the script ? I always failed when I try to start network.

I checked the IP via ifconfig. and found eth0:3 is set but others. May I know what's the problem?

  1 auto lo
  2 iface lo inet loopback
  4 #auto eth0
  5 #iface eth0 inet dhcp
  7 auto eth0:1
  8 iface eth0:1 inet static
  9 address
 10 netmask
 11 gateway
 13 auto eth0:2
 14 iface eth0:2 inet static
 15 address
 16 netmask
 17 gateway
 19 auto eth0:3
 20 iface eth0:3 inet static
 21 address
 22 netmask
 23 gateway   
share|improve this question

migrated from Mar 7 '12 at 3:44

This question came from our site for professional and enthusiast programmers.


You don't really need to edit `/etc/network/interfaces' to set the static IP addresses. You can do that using the Network Manager. Just right click on the network applet and go to Edit Connections.

If you however don't want to use the network manager, the following steps will help you assign multiple ip addresses:

  1. Disable the network manager sudo service network-manager stop
  2. Get the IP address from the server using: sudo dhclient eth0
  3. Assign the first ip addresses like this: sudo ip addr add dev eth0, and repeat for other IP addresses.
  4. Add the default route using: sudo route add default gw <internet gateway ip address>

If you do step 2, step 4 is not required. Hope that helps.

share|improve this answer
thanks. I prefer use Network-manager. but when I edit the connection and add two more static ip address and then reboot. Then the ip change to lan only, I lost my dhcp ip address. – iAsk Mar 7 '12 at 5:12
Well then go with the command line. – The Terminator Mar 7 '12 at 10:11
command line is easier, but I need to input password every time. thanks – iAsk Mar 7 '12 at 11:19
sudo su will relieve you of that trouble. – The Terminator Mar 7 '12 at 16:53
sudo su still need input password, how come to relieve the trouble. – iAsk Mar 13 '12 at 6:11

If you have NetworkManager installed, it could be causing a problem with /etc/network/interfaces. See /usr/share/doc/network-manager/README.Debian (I've used Ubuntu just enough to install it for someone else).

share|improve this answer
can network manager achieve some work? I tried to assign static IP in network manager and also failed. – iAsk Mar 7 '12 at 3:18

If the problem persists while setting up a static ip, use the following steps to set up a new static ip address:

Open terminal (command line) and type the following command:

sudo vi /etc/network/interfaces


sudo gedit /etc/network/interfaces

Make the changes as follows:

auto eth0
iface eth0 inet static

Save and close the file. Restart networking:

sudo /etc/init.d/networking restart
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.