LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 12-11-2003, 11:33 AM   #1
gauge73
Member
 
Registered: Jan 2003
Location: Dallas, TX
Distribution: Fedora Core 4
Posts: 420

Rep: Reputation: 30
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
 
Old 12-11-2003, 07:47 PM   #2
g-rod
Member
 
Registered: Dec 2003
Location: Long Island, NY USA
Distribution: RedHat, SUSE
Posts: 336

Rep: Reputation: 30
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting rid of the black dotted box 357mag Mandriva 3 03-18-2005 12:37 PM
Can a router cause a box to crash?? esteeven Linux - Networking 6 06-30-2004 05:03 PM
Can ping box to box thru router - good sign? toastermaker Linux - Networking 15 12-07-2003 12:00 AM
Using Linux Box as a Router wasabi Linux - Networking 5 09-04-2003 05:08 PM
Fwall/Router Network Appliance vs. stock mdk9 Fwall/Router box jqpdev Linux - Networking 2 02-28-2003 07:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 08:55 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration