Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    iptables, multiple interfaces

    Here's my problem:
    I have 5 static IP's from my ISP, they are however in two different series. They look like this:

    These also have different GW's. and

    What I want to do is to add all these IP's to a linuxbox that act like a router/gateway and send those IP's through to a local ip (192.168.100.x). Four IPs should be passed on, the last one should be the machines own, which is also used for the general internetsharing. -> Machine1 -> Machine2 -> Machine3 -> Machine4 -> 192.168.100.* Machine5+

    So, I want all internet trafic that commes to/from Machine1 to go in and out through the given ISP-IP. Machine2 through that given one etc etc. Machine5 (server) shares it's IP with the rest of the computers that doesn't have an external IP of their own, some regular nat solution there.

    Righ now, the machine only have one NIC, but I will add another one when I know how to do this routing.

    Can someone give me a hand here? I've thought about using iptables for it, perhaps there's some other solution that you know of, please tell me anything you can about this.

    There is another NIC in the machine now.

  2. #2

    Well there is no real problem here...

    Just use iptables to masquerade the addresses that come from the outside (and goes back out...);

    iptables -t nat -A POSTROUTING -j MASQUERADE

    You must also make sure that you have routing switch on

    echo 1 > /proc/sys/net/ipv4/ip_forward

    That should be it...

    Then to disable/enable stuff that passes your router-box you edit the FORWARD chain...

    Look at for some more documentation...



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts