View previous topic :: View next topic |
Author |
Message |
CinqueX n00b
Joined: 26 Jan 2003 Posts: 58
|
Posted: Mon Mar 15, 2004 4:16 am Post subject: Dynamic IP (pppoe) + static routes |
|
|
Hello,
Hopefully somebody more guru than I can help me figure this one out. I am pretty familiar with iproute2 and iptables so be as verbose with your answers as you need to be.
this is my network:
ISP1-----| ppp0 (pppoe)
ISP2-----| eth1 (static IP)
ppp0 is configured by pppoe's DHCP and the IP and gateway change every time the dhcp license is renewed.
The eth1 interface had a static IP has a gateway defined in the /etc/conf.d/net file.
Because the static gateway is the only one defined and it is attributed to eth1, ALL outgoing traffic leaves from the static IP, even if it responding to requests on the pppoe interface.
The pppoe interface has unlimited bandwidth costs, while the static has a cost per MB. I would like all outgoing traffic to pass through the pppoe's interface and gateway, but I cant "hard code" them in the config files because they will change daily.
What iproute and iptables magic can you think of that will cause my network to act the way I want?
C. |
|
Back to top |
|
|
kashani Advocate
Joined: 02 Sep 2002 Posts: 2032 Location: San Francisco
|
Posted: Wed Mar 17, 2004 12:04 pm Post subject: |
|
|
I believe the following would work for you.
route add -net 0.0.0.0 netmask 128.0.0.0 dev ppp0
route add -net 128.0.0.0 netmask 128.0.0.0 dev ppp0
The idea is that you add two routes that are more specific than your default route of 0.0.0.0/0.0.0.0 and are then preferred for all traffic. I believe these routes will withdraw if the ppp0 interface goes down, but would test that to make sure.
kashani _________________ Will personally fix your server in exchange for motorcycle related shop tools in good shape. |
|
Back to top |
|
|
CinqueX n00b
Joined: 26 Jan 2003 Posts: 58
|
Posted: Fri Mar 19, 2004 2:37 am Post subject: The eventual solution |
|
|
Thanks!
I tried your suggestion, but it didnt work out. Here is what I ended up doing:
#!/bin/bash
DYN_IP=`ifconfig ppp0 | grep inet | cut -d : -f 2 | cut -d ' ' -f 1`
echo $DYN_IP
# Setup source IP routing rules for STATIC
ip rule add from x.x.x.x lookup 3
ip route add 10.10.10.0/24 via 10.10.10.1 table 3
ip route add 0/0 via 192.168.0.1 table 3
# Setup source IP routing rules for DYNAMIC
ip rule add from $DYN_IP lookup 2
ip route add 10.10.10.0/24 via 10.10.10.1 table 2
ip route add 0/0 via x.x.x.x table 2
ip route add default equalize nexthop via 192.168.0.1 dev eth1 nexthop via $DYN_IP dev ppp0 |
|
Back to top |
|
|
|