iptables: howto forward to different gateways

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

  1. cyberroadie

    cyberroadie Guest


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


    NAT network My Machine


    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)?


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