LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Getting Rid of My Router-In-A-Box (https://www.linuxquestions.org/questions/linux-networking-3/getting-rid-of-my-router-in-a-box-124943/)

gauge73 12-11-2003 11:33 AM

Getting Rid of My Router-In-A-Box
 
I now have two functioning NICs up on my linux box. I want to perform the same simple port address translation that my Linksys router did. I see a bunch of howtos using ipchains, iptables, and ipmasq. What should I use?

The iptables howto I saw only discussed rules that didn't really have a dynamic effect. I could have all the packets matching the rule go to a single IP, but that's not what I want. What I want is more dynamic, I think. If Computer A sends a packet on port X to an internet host, then responses from that host on port X should go to computer A. But if a few minutes later computer B sends a packet to the same host on port X, then responses should go to computer B, not A. Thus, I seem to think that either the howto I read wasn't exhaustive, or I didn't understand it, or there's another tool that I'm missing.

I realize this question is not posed in a very coherent way, but tell me how to better describe my problem and I'll be happy to try to clarify. :x

g-rod 12-11-2003 07:47 PM

Sure that is easy. All you need to do is login as root and run the following
iptables -t nat -I POSTROUTING -o eth0 -j MASQUERADE;
/etc/init.d/iptables save;
chkconfig --add iptables;

The explanation of the first line
-t nat Add a Network Address Translation rule.
-I POSTROUTING Perform it after the route has be selected.
-o eth0 Only apply this run if the traffic is going out on interface eth0
-j MASQUERADE the trafic as if it was comming from the firewall
Without going into detail the firewall "remembers" who it routed where and when. It then knows who to route it to when it gets a responce.

The explanation of the second line
save the rules in iptables to disk (/etc/sysconfig/iptables)
The Third line makes sure that iptables is restarted on reboot.

Hope this helps.


All times are GMT -5. The time now is 08:23 AM.