LinuxQuestions.org
Review your favorite Linux distribution.
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 05-31-2009, 01:24 PM   #1
fancylad
Member
 
Registered: Mar 2008
Distribution: slackware
Posts: 175

Rep: Reputation: 19
how to port forward with iptables


i am using debian etch as my gateway for my home network. eth1 is connected to my isp. eth0 is connected to my LAN. in order to share an internet connection i use:

Quote:
iptables --table nat --append POSTROUTING --out-interface eth1 -j MASQUERADE
i have been trying to port forward incoming port 25 to 192.168.1.222:25. from what i have read online i have tried:

Quote:
sudo iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 25 -j DNAT --to 192.168.1.222:25
this however does not work. if i try connecting with telnet it never connects. if i do examine the packets on 192.168.1.222 however i can see that the packets are getting there. it just seems like they can't get back. i have tried adding a line like this to the POSTROUTING chain:

Quote:
sudo iptables -t nat -A POSTROUTING -p tcp -j SNAT -s 192.168.1.222 --to <public ip address>:25
and sometimes i am able to connect via telnet to port 25. however after i disconnect and try again it doesn't work.

does anyone know how i can get port forwarding to work?
 
Old 05-31-2009, 01:47 PM   #2
david1941
Member
 
Registered: May 2005
Location: St. Louis, MO
Distribution: CentOS7
Posts: 267

Rep: Reputation: 58
Are you trying to connect from the same network you DNATed to? That can give a connection problem for traffic going in reverse as explained in this chapter of a good tutorial:

http://iptables.rlworkman.net/chunkyhtml/x4033.html

Dave
 
Old 05-31-2009, 02:41 PM   #3
fancylad
Member
 
Registered: Mar 2008
Distribution: slackware
Posts: 175

Original Poster
Rep: Reputation: 19
never mind. i just found out my isp blocks inbound port 25. i tried this with port 22 and it does work. thanks for your help.
 
  


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
iptables - port forward v1pEr Linux - Networking 3 04-23-2009 02:33 PM
IPTables port forward help matux Linux - Networking 1 09-09-2008 10:54 AM
Forward port with iptables ThaHabbis Linux - Networking 5 03-18-2007 05:30 PM
iptables port forward forbese SUSE / openSUSE 1 02-12-2006 02:35 PM
IPtables Forward 1 Port to another on the same IP KevinB Linux - Networking 2 01-13-2005 10:56 PM

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

All times are GMT -5. The time now is 11:26 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