Networking Forums

Networking Forums > Computer Networking > Linux Networking > Routing local origin conns out second gateway.

Reply
Thread Tools Display Modes

Routing local origin conns out second gateway.

 
 
Chris Heller
Guest
Posts: n/a

 
      01-18-2006, 10:23 PM
I'm would like to make linux send any socket connections that originate
on the local system to travel out a gateway different that the default
gateway.

This is my current network:

[---------------- THE INTERNET -------------------]
| | | |
[gw0: 192.168.2.1] [gw1: 192.168.2.2]
| | | |
[----------------- 192.168.2.0/24 -------------------]
| |
[host0: 192.168.2.100]

Here is the current routing table on host0:

> ip route show table main

192.168.2.0/24 dev eth0 scope link
127.0.0.0/8 dev lo scope link
default via 192.168.2.1 dev eth0

After briefly consulting this document:
http://linux-ip.net/html/adv-multi-internet.html
I think I've found a solution.

I first added a second routing table:

> ip route show table 4

192.168.2.0/24 dev eth0 scope link
127.0.0.0/8 dev lo scope link
default via 192.168.2.2 dev eth0

Then I made some iptable rules:

> iptables -t mangle -A PREROUTING -p tcp -s 192.168.2.0/24 -j MARK --set-mark 4
> iptables -t mangle -nvL

Chain PREROUTING (policy ACCEPT 91807 packets, 52M bytes)
pkts bytes target prot opt in out source
destination
16169 2872K MARK tcp -- * * 192.168.2.0/24
0.0.0.0/0 MARK set 0x4

Chain OUTPUT (policy ACCEPT 83576 packets, 29M bytes)
pkts bytes target prot opt in out source
destination

And then finally added one last ip rule:

> ip rule add fwmark 4 table 4
> ip rule show

0: from all lookup local
32765: from all fwmark 4 lookup 4
32766: from all lookup main
32767: from all lookup 253

I tried this out, and it didn't work. I do not see traffic originating
on the system appear route to gw1, traffic that originates from gw0
routes fine. And traffic originating on the system still routes to gw0.

Any help would be appreciated.

Thanks,
Chris

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
host name vs. device name vs. local domain name vs. gateway name me Network Routers 0 06-27-2011 12:49 PM
local routing Igor Nemilentsev Linux Networking 5 10-05-2010 11:57 AM
Can't use unique local address as default IPv6 gateway - why not? Asfand Yar Qazi Linux Networking 0 06-17-2007 08:43 PM
routing VPN traffic into local net speakeasy Windows Networking 5 10-01-2004 01:43 AM
Local Gateway BFH Windows Networking 1 12-13-2003 02:01 PM



1 2 3 4 5 6 7 8 9 10 11