LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
Search this Thread
Old 04-12-2008, 07:41 PM   #1
exodist
Senior Member
 
Registered: Aug 2003
Location: Portland, Oregon
Distribution: Gentoo
Posts: 1,372

Rep: Reputation: 46
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
 
Old 04-13-2008, 10:13 AM   #2
dr_agon
Member
 
Registered: Sep 2007
Location: Poland
Distribution: Ubuntu 8.04
Posts: 77
Blog Entries: 12

Rep: Reputation: 24
If you leave
Quote:
Originally Posted by exodist View Post
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.
 
Old 04-13-2008, 09:54 PM   #3
exodist
Senior Member
 
Registered: Aug 2003
Location: Portland, Oregon
Distribution: Gentoo
Posts: 1,372

Original Poster
Rep: Reputation: 46
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.
 
  


Reply

Tags
default, interface, route


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
For laptop - different networks in /etc/network/interfaces, or use network-manager? dmravaet Linux - Wireless Networking 4 03-17-2007 11:42 PM
Multiple Interfaces + Cisco 515 and default NIC streamalot Linux - Networking 0 06-12-2006 01:43 PM
Manual Network Setup Works, /etc/network/interfaces doesn't verdeboy2k Linux - Wireless Networking 0 05-31-2006 06:56 PM
multiple interfaces, default gateway sopiaz57 Linux - Networking 6 05-03-2005 02:02 PM
Linux virtual interfaces....specify default ip nastea Linux - Networking 5 12-08-2004 12:58 PM


All times are GMT -5. The time now is 07:38 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration