AcCeSsDeNiEd wrote:
> You are in luck. I just got this setup after weeks of hunting, asking for help and tweaking.
>
> First read this: http://linux-ip.net/html/adv-multi-internet.html
> This site brought me closer to my solution.
> Credit given to the poster who pointed me to this site.
>
>
> This is what I did:
>
> #ISP 1 nat (defualt route)
> iptables -t nat -A POSTROUTING -o $ISP1_iface -s ip_net1/bits -j MASQUERADE
>
> #ISP 2 nat
> $iptables -t mangle -A PREROUTING -s $ip_net2/bits -j MARK --set-mark 5
> $iptables -t nat -A POSTROUTING -o $ISP2_iface -j SNAT -s ip_net2/bits --to-source $ISP2_IPaddr
>
> #Add the iproute2 and marker/s for ISP2 nat
> /sbin/ip route flush table 5
> /sbin/ip route add table 5 default via ISP2_gw_IPaddrr
> /sbin/ip rule add fwmark 5 table 5
>
I try your solution, but it's not working for me, do you know what I'm
doing wrong ?
I just go on my first ISP with this, never on my second ISP,
If I remove the default (ISP1) gateway in my /etc/nerwork/interfaces
I cannot access anymore to internet (also from the router himself).
(eth1 -> my first ISP / eth2 -> my second ISP)
Here is my script for routing and iptables:
################################################## ######################
# ISP2
/sbin/ip route flush table 5
/sbin/ip route add table 5 default via 5.6.7.9 dev eth2
/sbin/ip rule add fwmark 5 table 5
# ISP1
/sbin/ip route flush table 6
/sbin/ip route add table 6 default via 1.2.3.5 dev eth1
/sbin/ip rule add fwmark 6 table 6
echo "firewall constants setup"
# FLUSH the tables
iptables -t nat -F POSTROUTING
iptables -t nat -F PREROUTING
## Mangeling Rules ##
# special rules for some IPs to go on second ISP
iptables -t mangle -A PREROUTING -s 10.117.71.162 -j MARK --set-mark 5
iptables -t mangle -A PREROUTING -s 10.117.71.171 -j MARK --set-mark 5
iptables -t mangle -A PREROUTING -s 10.117.71.174 -j MARK --set-mark 5
iptables -t mangle -A PREROUTING -s 10.117.71.175 -j MARK --set-mark 5
iptables -t mangle -A PREROUTING -s 10.117.71.176 -j MARK --set-mark 5
# default for all our network
iptables -t mangle -A PREROUTING -s 10.117.71.0/24 -j MARK --set-mark 6
################################################## #####################
Here is my /etc/init.d/interface :
################################################## #####################
# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)
# The loopback interface
auto lo
iface lo inet loopback
# The first network card - this entry was created during the Debian
installation
# (network, broadcast and gateway are optional)
auto eth1 eth0 eth2
# local network (LAN)
iface eth0 inet static
address 10.117.71.1
netmask 255.255.255.0
# external network (ISP1)
iface eth1 inet static
address 1.2.3.4
netmask 255.255.255.248
gateway 1.2.3.5
iface eth2 inet static
address 5.6.7.8
netmask 255.255.255.0
################################################## ####################
Thank you for help,
Guillaume