LinuxQuestions.org
Visit the LQ Articles and Editorials section
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-23-2005, 07:50 AM   #1
gomen
LQ Newbie
 
Registered: Aug 2003
Posts: 8

Rep: Reputation: 0
iptables don't do port forwarding


Hi Everyone....first at all thank for reed this post.
Mi problem is the following: I am having troubles with iptables on my Debian Sarge 3 Stable.
When I redirect all incoming recived from port 80 to my intenral web server it doesn't work. The rule is the following: iptables -t nat -A PREROUTING -p tcp -i ppp0 --dport 80 -j DNAT --to-destination 192.168.0.5:80
But, when I use the same rule to redirect, por example, the VNC port to a Window Machine It work fine !!! so I do not know what is the problem.
If any pf you have a suggestion, please let me know it !!!
Thanks.
 
Old 12-23-2005, 04:12 PM   #2
win32sux
Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
you'd need to have a FORWARD rule to go along with the PREROUTING rule... kinda like this:
Code:
iptables -t nat -A PREROUTING -p TCP -i ppp0 --dport 80 \
-j DNAT --to-destination 192.168.0.5

iptables -A FORWARD -p TCP -i ppp0 -d 192.168.0.5 --dport 80 -j ACCEPT
 
Old 12-23-2005, 06:05 PM   #3
WindowBreaker
Member
 
Registered: Oct 2005
Distribution: Slackware
Posts: 228

Rep: Reputation: 31
Gomen:
What is your iptables policy for the INPUT, FORWARD, AND OUTPUT chains?
Anything set to the target "DROP" in your FORWARD chain?

If not, could it be that your ISP blocks port 80 for some reason.
I'd try setting up anything (http server, telnet, ssh, etc) running on port 80 on your linux box (router, with port-forwarding not enabled), and try to access it from the outside. Then if that work successfully, but the portforwarding doesn't, you can be sure the problem has to do with the port forwarding.

If still doesn't work, please post results of the following commands:
iptables -n -L
iptables -n -t nat -L
 
Old 12-26-2005, 12:26 PM   #4
gomen
LQ Newbie
 
Registered: Aug 2003
Posts: 8

Original Poster
Rep: Reputation: 0
Thanks !! now it is working !!! i had the default policy of FORWARD in DROP !!! Thanks !
 
Old 12-26-2005, 03:05 PM   #5
win32sux
Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
Quote:
Originally Posted by gomen
Thanks !! now it is working !!! i had the default policy of FORWARD in DROP !!! Thanks !
a FORWARD policy of DROP is exactly what you *should* have, always... if setting it to ACCEPT makes your setup work, then that confirms that your problem was your FORWARD rules... it's highly recommended that you get this working with a policy of DROP...

Last edited by win32sux; 12-26-2005 at 03:08 PM.
 
  


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
IPCHAINS port forwarding and IPTABLES port forwarding ediestajr Linux - Networking 26 01-14-2007 07:35 PM
port forwarding with iptables kkennedy Linux - Networking 1 09-01-2005 06:48 PM
Iptables -- Port Forwarding slack_baby Linux - Networking 3 06-03-2004 02:29 PM
IPTABLES #Port Forwarding goldenmag Linux - Security 4 11-21-2003 07:10 AM
IPTABLES port forwarding sal_paradise42 Linux - Networking 5 10-25-2003 04:11 PM


All times are GMT -5. The time now is 02:30 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration