Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How do I add more IP addresses to a network card on Linux? Do I use the route command?

It's Ubuntu Server 10.04 LTS.

share|improve this question
    
Why did someone downvote this? I don't get it? –  ServerChecker Jun 2 '11 at 18:28
    
@sciurus, I disagree. If we're going to do that, then what's the point of serverfault.com? Besides, a quarter of the time we do searches on Google these days, we get spam blogs, or a query in a forum where no one has ever given out an answer, or ExpertExchange (gah!), or advice from like 2007. No thanks. I'll stick with the stack* sites. –  ServerChecker Jun 7 '11 at 19:23
add comment

2 Answers 2

up vote 3 down vote accepted

do you mean you want to add secondary ip ?

   $ sudo vi /etc/network/interfaces
     auto eth0
     iface eth0 inet static
      address x.x.x.x
      netmask x.x.x.x
      network x.x.x.x
      gateway x.x.x.x
      broadcast x.x.x.x

     auto eth0:1
      iface eth0:1 inet static
      address x.x.x.x
      netmask x.x.x.x
      network x.x.x.x
      broadcast x.x.x.x

   $ sudo /etc/init.d/networking restart
share|improve this answer
    
Can you expand on this? I mean, what about the changes I need to do to whatever else is already in /etc/network/interfaces by default? –  ServerChecker Jun 2 '11 at 18:49
    
on /etc/network/interfaces, the default is only 1 device (eth0/etch1/ethX) so you need to add more if you want to add secondary ip, i updated the sample above. –  chocripple Jun 3 '11 at 0:46
add comment

You can use the new style:

ip address add 192.168.10.0/24 dev eth0

Or the old style:

ifconfig eth0:1 192.168.10.0 netmask 255.255.255.0
share|improve this answer
add comment

Your Answer

 
discard

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.