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.

link|improve this question

80% accept rate
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
feedback

2 Answers

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
link|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. – Rikih Jun 3 '11 at 0:46
feedback

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
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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