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

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
  • 435
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,691
  • 1
  • 32
  • 49
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
  • 201
-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 ...