Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Dynamic IP (pppoe) + static routes
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
CinqueX
n00b
n00b


Joined: 26 Jan 2003
Posts: 58

PostPosted: Mon Mar 15, 2004 4:16 am    Post subject: Dynamic IP (pppoe) + static routes Reply with quote

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
View user's profile Send private message
kashani
Advocate
Advocate


Joined: 02 Sep 2002
Posts: 2032
Location: San Francisco

PostPosted: Wed Mar 17, 2004 12:04 pm    Post subject: Reply with quote

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
View user's profile Send private message
CinqueX
n00b
n00b


Joined: 26 Jan 2003
Posts: 58

PostPosted: Fri Mar 19, 2004 2:37 am    Post subject: The eventual solution Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum