0

Totaly edited:

I have 3 nic with links eth0 eth1 eth2. I made 3 table T1 T2 T3. In /etc/network/interfaces i wrote:

auto eth0
iface eth0 inet static
        address 1.0.0.1
        netmask 255.255.255.0
        post-up ip route add 1.0.0.2/32 dev eth0 src 1.0.0.1 table T1
        post-up ip route add default via 1.0.0.2 table T1
        post-up ip rule add from 1.0.0.1 table T1
        post-down ip rule del from 1.0.0.1 table T1

auto eth1
iface eth1 inet static
        address 2.0.0.1
        netmask 255.255.255.0
        post-up ip route add 2.0.0.2/32 dev eth1 src 2.0.0.1 table T2
        post-up ip route add default via 2.0.0.2 table T2
        post-up ip rule add from 2.0.0.1 table T2
        post-down ip rule del from 2.0.0.1 table T2

auto eth2
iface eth2 inet static
        address 3.0.0.1
        netmask 255.255.255.0
        post-up ip route add 3.0.0.2/32 dev eth2 src 3.0.0.1 table T3
        post-up ip route add default via 3.0.0.2 table T3
        post-up ip rule add from 3.0.0.1 table T3
        post-down ip rule del from 3.0.0.1 table T3

So, i made a restart, all intefaces bringed up, and than i need to add such rule because there is no gateway:

ip route add default scope global nexthop via 1.0.0.2 dev eth0 weight 1 nexthop via 2.0.0.2 eth1 weight 1 nexthop via 3.0.0.2 eth2 weight 1

But after that command i receive error:

RTNETLINK answers: Invalid argument

So, whats wrong? I used this manual https://www.debian-administration.org/articles/377

user785415
  • 11
  • 4
  • It's not clear what you're saying. Do you mean you can't ping them from this very machine? Or do you mean you can't ping them from some other machine? How are the three links connected? All to the same switch?! – David Schwartz Mar 04 '14 at 13:18
  • Yes all three links conected to one provider switch. I can't ping eth1 and eth2 from other machine. I want 3 links to work simultaneously – user785415 Mar 04 '14 at 13:27
  • 1
    See [this answer](http://serverfault.com/a/415749/91987) for more on why this is a bad idea. Linux uses a weak end system model where IP addresses belong to the machine as a whole, not to just one of its interfaces. – David Schwartz Mar 04 '14 at 13:30
  • Maybe alias ip is a variant. Can one inteface link have 3 ip. 1 default and 2 alias? – user785415 Mar 04 '14 at 13:32
  • It would help a lot to understand what you're trying to accomplish. – David Schwartz Mar 04 '14 at 13:34
  • I had 3 mail servers on three pc, now I want 1 pc with 3 virtual mail servers, so I thought that I need 3 network cards - for 1 to every virtual machine, what is the best way to make my transformation? – user785415 Mar 04 '14 at 13:39
  • Just use one network card. You can assign as many IP addresses to the machine as you want. – David Schwartz Mar 04 '14 at 13:43
  • I know, but i have 3 cables from my provider – user785415 Mar 04 '14 at 13:49
  • 1
    See if they support LACP and setup the 3 cable as redundant. Also make sure the provider knows that all 3 cables should have access to all 3 IPs. They're probably using port security on the switch to limit the endpoint IP, which is why you're having problems with ping right now. – Chris S Mar 04 '14 at 14:07
  • `so I thought that I need 3 network cards - for 1 to every virtual machine` - No, that is not how VMs work. Usually you setup a virtual switch/bridge on your hypervisor. Your hypervisor has none of the IPs assigned to it. The VMs have the IPs, and they are bridged to the correct network link. What hypervisor are you using? – Zoredache Mar 04 '14 at 18:14

4 Answers4

2

Firstly, eth2 will not work because you've a typo in the configuration file : gateway XXX.XXX.XXX.255 should be gateway XXX.XXX.XXX.254

Secondly, XXX.XXX.XXX.71 should answer to the ping if XXX.XXX.XXX.213 does from the same machine. If it doesn't, eth1 may be down (output of ifconfig -a may help) or your firewall drop all packets on eth1 but not on eth0, or maybe you've a network problem (defective cable, switch misconfigured), in this case you should try to swap cable between eth0 and eth1.

Another thing, according to your routing table, only one interface will be used for outgoing connections. It depends on the metric sets for each route. You can view your routing table with ip route show

piernov
  • 415
  • 2
  • 7
2

I don't know what Virtualization setup you have, but the key to have multiple NIC and have them used is to set up your network properly.

You have in your configuration a default gateway on all interface, that won't work. The key to understanding is to look at your routing table (usually the command "route" shows that).

You will see that you have 3 ways for traffic to go out. So what's going to happen? One of the route will be used. But will the answer (say to a ping) come back on the same interface? Most probably not.

So what you need is to decide all to route this traffic and set up your routes accordingly. Automatically, traffic going to the same network as the interface will go through that interface. You should have only 1 DEFAULT gateway (that's why it's called DEFAULT - that's for when there is no better route). Then shape your traffic the way you want it.

You don't provide the IP addresses so there is not a lot we can do to help here. As I can't tell whether they are all the same subnet or not. Are they all 192.168.5.xxx or they are different?

What you are trying to achieve is that each of your email server go out through their applicable ISP line. You don't specify which email software you use, so I will assume Postfix. You can set up postfix to bind to a specific interface. That should make your email go out through it. For that you can set up a route entry that will send traffic on that NIC through the gateway for that NIC.

ETL
  • 6,443
  • 1
  • 26
  • 47
0

The ping answer will depend on your routing table and particularly your default gateway, I guess here it is configured to be eth0, that's why eth1 and eth2 are not responding. You will need to use ip route and ip rule command. Like this i guess : https://unix.stackexchange.com/questions/4420/reply-on-same-interface-as-incoming

Charly
  • 101
  • 4
-3

When you send data only one interface is used at a time which 99% of the time is the default eth0. You can of course receive data from all 3 simultaneously ...