routing out two ppp lines via source eth - iptables

Discussion in 'Linux Networking' started by chris329, Aug 27, 2004.

  1. chris329

    chris329 Guest

    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
     
    chris329, Aug 27, 2004
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.