LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 08-08-2003, 02:31 PM   #1
kharris
LQ Newbie
 
Registered: Aug 2003
Posts: 15

Rep: Reputation: 0
Port Forwarding with one Nic


I am starting a new post as I still have not been able to accomplish my goal, and I really need to get this figured out. Any and all help would be greatly appreciated.

My problem. I need to set up a Linux machine containing one nic to accept connections on a port and forward them on to the same port on another computer. For example, when the Linux machine (10.1.1.2) receives a packet on port 25 I need for the machine running SMTP at 10.1.1.1 to answer. I think this is called port forwarding, but so far I have not been able to make it work.

I have deleted my /etc/sysconfig/iptables file and am starting with a clean slate after a reboot. How can I simply set up my Linux machine (10.1.1.2) to forward all packets that it receives on port 25 of eth0 (it's only nic) on to 10.1.1.1. No other security needed, just yet.

Once I get that working, I can then add the security portion piece by piece.
 
Old 08-08-2003, 02:48 PM   #2
hakcenter
Member
 
Registered: Apr 2003
Location: Not to far from the computer screen
Distribution: RedHat 9.0
Posts: 324

Rep: Reputation: 30
I think i figured it out, after a small amount of thinking...

I don't believe we actually setup the masq. part of your firewall

iptables stop
iptables save
iptables start

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

iptables -t nat -A PREROUTING -t tcp --dport 25 -j SNAT --to 10.1.1.1:25

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
 
Old 08-08-2003, 02:54 PM   #3
kharris
LQ Newbie
 
Registered: Aug 2003
Posts: 15

Original Poster
Rep: Reputation: 0
That worked! Thank you, thank you, and thank you again!!!
 
Old 08-08-2003, 02:57 PM   #4
hakcenter
Member
 
Registered: Apr 2003
Location: Not to far from the computer screen
Distribution: RedHat 9.0
Posts: 324

Rep: Reputation: 30
ya i was being stupid at first...

dunno today has not even been close to being my day...

If you know anything about masq'ing.. it has to be done, because your computer isn't going to accept a tcp connection from the other machine..

ex:

Your on Machine A, and attempting to HTTP to Machine B,

But Machine B forwards to Machine C...

Well.. without masqing, Machine C is going to attempt to contact Machine A, about its request.. sorry for not noticing sooner... having 1 fucking sucking ass day at work.
 
Old 08-08-2003, 02:57 PM   #5
hakcenter
Member
 
Registered: Apr 2003
Location: Not to far from the computer screen
Distribution: RedHat 9.0
Posts: 324

Rep: Reputation: 30
make sure you edit the /etc/sysctl.conf file to having ip_forward = 1

so when it reboots you dont need to re-echo it
 
  


Reply



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
IPCHAINS port forwarding and IPTABLES port forwarding ediestajr Linux - Networking 26 01-14-2007 07:35 PM
Simple Port Forwarding Firewall - not forwarding MadTurki Linux - Security 14 04-09-2006 12:08 PM
Port 80 forwarding to port 22 with iptables zahoo Linux - Networking 3 02-22-2005 07:22 AM
Port Forwarding on RedHat 9 with single NIC brianv Linux - Networking 5 05-31-2004 06:36 PM
port forwarding and packet forwarding syrtsardo Linux - Newbie 2 07-03-2003 10:37 AM

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

All times are GMT -5. The time now is 06:09 AM.

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