0

I'm using ubuntu 12.04.

I tried to assign two ips to two ethernet cards in my server.

The content of /etc/network/interfaces is like this:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 114.80.156.a
netmask 255.255.255.224
gateway 114.80.156.b

auto eth1
iface eth1 inet static
address 114.80.156.c
netmask 255.255.255.240
gateway 114.80.156.d

a b c d have different values, which means the two ips are in different vlans.

But I can only bring up eth0 with this command:

$ /etc/init.d/networking restart
RTNETLINK answers: File exists
Failed to bring up eth1.
...done.

I have checked the question here which shows the same problem like the one I encountered: Can only bring up one of two interfaces

But it seems it's not really solved. And in my situation, I need the 2 ips to use 2 different gateways.

So how to fix this problem?


Edit1, changed the example config ip from 192.168.0.0/16 subnet to another 'real' subnet.


Edit2, the purpose of doing this is fairly simple. Because the ip range I previous in don't have more room for new servers, and I have to move to another ip range. So I want to make the public servers bind to 2 ips for the transition period.

I only have really limited knowledge about routing and subnet. @BillThor @rackandboneman, would you please give me some keywords or links on how to setup route for 2 ips?

and @Mike Pennington, how do you know I speak chinese?

lxyu
  • 281
  • 1
  • 5
  • 9
  • 2
    `I need the 2 ips to use 2 different gateways.` -- Unless you are using some advanced rules and multiple route tables, this is not going to work the way you expect. You can't just have 2 default gateways without extra work. It just doesn't make much sense. Perhaps you should describe what you are really trying to do? – Zoredache Jun 12 '12 at 18:39
  • 1
    Also. Given your subnet masks you need to give us the FULL addresses of the interfaces/gateways. I can't tell if you think eth0, and eth1 should be on the same subnet or not, or if you have provided invalid subnet information. – Zoredache Jun 12 '12 at 19:42
  • 1
    @lxyu, I know you are a Chinese speaker because your profile says you are from China. – Mike Pennington Jun 13 '12 at 03:30

3 Answers3

2

"RTNETLINK answers: File exists" means it is trying to set up a static route that is in conflict with another.

If the original idea behind the question is QoSing traffic out two different interfaces on the same subnet: That really gets advanced quick. The next thing you will discover is how the default ARP behaviours on Linux will sabotage the project :)

rackandboneman
  • 2,487
  • 10
  • 8
0

Are you sure that the ips are not on the same subnet. As the 192.168.0.0/16 subnet is private, you can give use the right values. Add broadcast and network options may help too.

Dom
  • 6,628
  • 1
  • 19
  • 24
0

You are trying to create two default gateways on different addresses. If you only need to route to the vlan omit the gateway entry. If you need routes from the vlan to limited addresses use post-up commands to add the required routes for that interface.

I generally try to have eth0 the interface with the default gateway. Other interfaces are used for communication on the network to which they are connected, and in limited cases have routing rules to networks attached through that subnet.

There are techniques that can be used to route specific traffic via different interfaces. However, its not something I have had need to do and don't have experience with it. I have seen documentation on the Shorewall site. It is likely not what you want to do.

BillThor
  • 27,354
  • 3
  • 35
  • 69