I recency posted a problem on sharing 2 internet connections for different LANs.
I would like to thank the guy (P Gentry) who provided me the link for this.
Good news is, I finally got it working.
I have the following setup:
http://accessdenied.darktech.org/2.txt
Bad news is, I now have problems with internal routing (company A & B senario routing).
My setup:
eth0 and eth1 (coy A/B) are connected to my Local area network:
eth0=10.30.1.0
eth1=10.20.0.0
eth2 is connected to the internet via a lease line.
ppp0 is connected to an ADSL provider:
eth2=161.18.195.4
ppp0=220.255.206.242
So to let users on eth0 tap on internet via eth2
and
the users on eth1 tap on the internet via ppp0(adsl), I do this:
#Start sharing internet from 2 providers
#Enable NAT routing from ppp0 (default route) for eth1 (coy B)
iptables -t nat -A POSTROUTING -o ppp0 -j SNAT -s 10.20.0.0/22 --to-source 220.255.206.242
#Enable NAT routing from eth2 for eth0 (coy A)
iptables -t mangle -A PREROUTING -s 10.30.1.0/24 -j MARK --set-mark 5 #This line causes the
problem.
iptables -t nat -A POSTROUTING -o eth2 -j SNAT -s 10.30.1.0/24 --to-source 61.8.195.4
#Add the route/marker for the eth0/eth2
/sbin/ip route flush table 5
/sbin/ip route add table 5 default via 161.18.195.1
/sbin/ip rule add fwmark 5 table 5
#End sharing internet from 2 providers
That shares the internet for the 2 networks (coy A & B).
Now, because of this line:
iptables -t mangle -A PREROUTING -s 10.30.1.0/24 -j MARK --set-mark 5
It screws up routing btw eth0 and eth1. Remove that line, and problem disappears (obviously
coy A/eth0 can't access the internet then).
It seems that all packets coming to eth0 are been marked '5'. So packets coming from eth1
(10.20.0.0)->eth0 also end up being marked I suppose? And therefore end up on the wrong gateway
(161.18.195.1)
I solved the problem by inserted another marker.
iptables -t mangle -A PREROUTING -s 10.30.1.0/24 -d 10.20.0.0/22 -j MARK --set-mark 6
iptables -t nat -A POSTROUTING -o eth1 -j SNAT --to-source 10.20.1.1
#Add the route/marker for the eth0/eth1
/sbin/ip route flush table 6
/sbin/ip route add table 6 default via 10.20.1.1
/sbin/ip rule add fwmark 6 table 6
Ok everything works now but is there a easier or more appropriate way to do this?
Am I doing this right?
I don't want to do this all the time when I include new networks.
Thanks
To e-mail, remove the obvious