LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   two interfaces, same network, specify default for outgoing (https://www.linuxquestions.org/questions/linux-networking-3/two-interfaces-same-network-specify-default-for-outgoing-634956/)

exodist 04-12-2008 07:41 PM

two interfaces, same network, specify default for outgoing
 
This is my setup script:

Code:

        /sbin/ifconfig eth0 192.168.0.2 netmask 255.255.255.0
        /sbin/ip route add 192.168.0.0/24 dev eth0 src 192.168.0.2 table 1
        /sbin/ip rule add from 192.168.0.2 table 1

        /sbin/ifconfig eth1 192.168.0.1 netmask 255.255.255.0
        /sbin/ip route add 192.168.0.0/24 dev eth1 src 192.168.0.1 table 2
        /sbin/ip rule add from 192.168.0.1 table 2

This sets it up so that any request to 192.168.0.1 is answered over eth1, and any request to 192.168.0.2 is answered over eth0.

Also at the moment if I try requesting 192.168.0.3-254 it uses eth0, this is what I want, but I did not tell it to do this, that means if default behavior changes in the future I can be in trouble.

So, how do I explicitly specify that all outgoing traffic to 192.168.0.x with exception of that directed to 192.168.0.1 should use eth0?

Routing table snippet FYI:
Code:

# ip route | grep eth[01]
192.168.0.0/24 dev eth0  proto kernel  scope link  src 192.168.0.2
192.168.0.0/24 dev eth1  proto kernel  scope link  src 192.168.0.1


dr_agon 04-13-2008 10:13 AM

If you leave
Quote:

Originally Posted by exodist (Post 3119470)
Code:

        /sbin/ifconfig eth0 192.168.0.2 netmask 255.255.255.0
        /sbin/ip route add 192.168.0.0/24 dev eth0 src 192.168.0.2 table 1
        /sbin/ip rule add from 192.168.0.2 table 1


and change the netmask for eth1 to 255.255.255.255

Code:

        /sbin/ifconfig eth1 192.168.0.1 netmask 255.255.255.255
        /sbin/ip route add 192.168.0.0/32 dev eth1 src 192.168.0.1 table 2

wouldn't it be as you want it?

I'm not a network wizz to know it off the top of my head, but if 192.168.0.1 is one of your local interfaces, it should get all the traffic to it without special routing rule, as this traffic should simply loop back to your host.

Good luck.

exodist 04-13-2008 09:54 PM

That was apparently not relevant. I do not know enough about deep networking details to know if it is even correct fo rsomething other than what I am doing.

Anyway I have avoided the issue, I decided to just bond the interfaces together, separating internet and other services was meant to increase speed, I think bonding achieves this a lot better.


All times are GMT -5. The time now is 01:58 PM.