iptables: howto forward to different gateways

Discussion in 'Linux Networking' started by cyberroadie, Jun 2, 2005.

  1. cyberroadie

    cyberroadie Guest

    Hello,


    I'm trying to route all trafic from a private (nat) network to an adsl
    connection (214..),
    the default gateway on my machine is 10.10.0.254 (of the corporate
    network) because I need that for my normal desktop tasks
    email/intranet/browsing.


    Code:

    NAT network My Machine
    |192.168.0.10|-------|192.168.0.1|eth1:
    |10.10.0.100|eth0:---corporate
    mw/proxy---|gw:10.10.0.254|-->

    |214.1.1.200|eth2:---adsl------------------|gw:214.1.1.81|-->


    I'm using iptables to set this up and come up with this so far:

    iptables -F
    iptables -t nat -F

    iptables -A FORWARD -i eth1 -j ACCEPT
    iptables -t nat -A POSTROUTING -o eth2 -j MASQUERADE

    But this forwarding is not working since my default gateway (on My
    Machine) is pointing to the corporate network.

    I don't want to change the default gateway, all trafic from 'my
    machine' has to go via the corporate network (something todo with my
    developer tools I'm using and other machines wich trafic are routed via
    my machine, all that traffic has to go through the firewall/proxy).

    I only want traffic _from_ eth1 forwarded _to_ eth2 . No other traffic
    is allowed to use the adsl connection.

    How can I configure this, do I need an extra iptable rule or do I need
    to alter my routing table (and if so how)?

    Cheers,


    Olivier
     
    cyberroadie, Jun 2, 2005
    #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.