-1

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.

ServerChecker
  • 1,518
  • 2
  • 14
  • 35
  • Why did someone downvote this? I don't get it? – ServerChecker Jun 02 '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 07 '11 at 19:23

2 Answers2

5

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
Mircea Vutcovici
  • 17,619
  • 4
  • 56
  • 83
3

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
chocripple
  • 2,109
  • 14
  • 9
  • 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 02 '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 03 '11 at 00:46