route based on incoming eth out ppp - two eth / two ppp

route based on incoming eth out ppp - two eth / two ppp

Post by Chris.. » Sun, 29 Aug 2004 03:15:59



I have two ethernet connections to an internal lan and two
outbound connections via ppp - two seperate isp's

I need to be able to route traffic based on incoming source.

                   25
 ------->| eth0    | --------->ppp0 ---------> Internet
              |    80        |
              |              |
              |    26        |
 ------->| eth0:1  | --------->ppp1 ---------> Internet
                  8080  

I have two squid and two sendmail daemons running each
bound to it's interface.
Outbound mail needs to be able to go through it's
respective isp's smtp server as a smart host - hence
the traffic shaping.

I have scripted the connection and then added the following
iptables setup. Unfortunately it is not working.

#/bin/bash!
p0=`/sbin/ifconfig |grep P-t-P | awk '{print $2}' \
|sed -e 's/addr\://g;' |grep 209`
p1=`/sbin/ifconfig |grep P-t-P | awk '{print $2}' \
|sed -e 's/addr\://g;' |grep 129`
#
echo $p0
echo $p1
# Setup IPTABLES
                iptables -t mangle -A PREROUTING -i eth0 -j MARK --set-mark 20
                iptables -t mangle -A PREROUTING -i eth1 -j MARK --set-mark 21
                ip route add default via $p0 dev ppp0 table 22
                ip route add default via $p1 dev ppp1 table 23
                ip rule add fwmark 20 table 22
                ip rule add fwmark 21 table 23

Can anyone see where i have made a mistake in this?

Thanks for any and all help,

Cheers,

Chris

 
 
 

1. routing out two ppp lines via source eth - iptables

I am trying to create two tables to route traffic based on the
ethernet port in which the originate.

Basically it is setup like this;

                  25
 ------->| eth0    | --------->ppp0 ---------> Internet
              |   80      |
              |           |
              |  26       |
 ------->| eth0:1 | --------->ppp1 ---------> Internet

                8080  

On each eth interface an instance of squid and sendmail are running
through the ports identified above.

I have scripted the connection for each ppp interface and then followed
up with the following;

#/bin/bash!
p0=`/sbin/ifconfig |grep P-t-P | awk '{print $2}'\
|sed -e 's/addr\://g;' |grep 209`
p1=`/sbin/ifconfig |grep P-t-P | awk '{print $2}'\
|sed -e 's/addr\://g;' |grep 129`
#
echo $p0
echo $p1
# Setup IPTABLES
                iptables -t mangle -A PREROUTING -i eth0 -j MARK --set-mark 20
                iptables -t mangle -A PREROUTING -i eth1 -j MARK --set-mark 21
                ip route add default via $p0 dev ppp0 table 22
                ip route add default via $p1 dev ppp1 table 23
                ip rule add fwmark 20 table 22
                ip rule add fwmark 21 table 23

Unfortunately this is not working - for some reason it is taking the default
route instead of using the rules setup above.

Can anyone shed some light on where i have gone wrong?

Thanks in advance for any and all help

Cheers,

Chris

2. access not allowed - help please

3. facing problems in configuring two (PPP, Eth) interfaces.

4. mmdf woes

5. 2 x ppp and 1 x eth routing question

6. IDE

7. Routing with ppp and eth

8. Need help: problem with Exabyte tape-drive

9. Need help:routing table for 1 eth and n ppp interfaces

10. routing for ppp and eth question

11. IPX RIP/SAP routing between ppp and eth

12. Create routing table for 1 eth and multiple ppp interface

13. routing for ppp and eth question