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-29-2001, 02:19 PM   #1
infinity6
Member
 
Registered: Dec 2001
Posts: 66

Rep: Reputation: 15
iptables port forwarding over ADSL


I am attempting to set up a box as an iptables firewwall. I have the web server sitting behind it and need to forward all port 80 traffic to and from the web server. I have read through the forums (very nice posts) but still can't get anything working.

My $INET_IP changes randomly.
My $INET_IF is pppo
My $LAN_IF is eth0
The LAN subnet is 192.168.0.0/24

Here's the basic configuration I'm working with:

iptables -t nat -A PREROUTING -s 192.168.0.0/24 -d 0/0 -j MASQUERADE

iptables -t nat -A PREROUTING -p tcp --dport 80 -i ppp0 -j DNAT --to 192.168.0.55

iptables -A FORWARD -p tcp --dport 80 -o eth0 -d 192.168.0.55 -j ACCEPT

iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to $INET_IP

Obviously, this is only to allow forwarded traffic from the LAN to the Internet, and to forward port 80 traffic to and from the web server. It looks like it should work. What am I missing?
 
Old 12-31-2001, 10:13 AM   #2
ifincham
LQ Newbie
 
Registered: Dec 2001
Distribution: Redhat / Mandrake / Suse / Debian
Posts: 6

Rep: Reputation: 0
Hi,

Well it should work pretty much as you have it already - presumably you have ip forwarding turned on in the /proc filesystem ?

echo 1 > /proc/sys/net/ipv4/ip_forward
/sbin/modprobe iptable_nat
/sbin/iptables -t nat -A PREROUTING -s 192.168.0.0/24 -d 0/0 -o ppp0 -j MASQUERADE
/sbin/iptables -t nat -A PREROUTING -p tcp --dport 80 -i ppp0 -j DNAT --to 192.168.0.55

Regards
 
Old 12-31-2001, 03:18 PM   #3
infinity6
Member
 
Registered: Dec 2001
Posts: 66

Original Poster
Rep: Reputation: 15
Thanks for the post. I verified that the module was loaded. It is. All the iptables modules are loaded correctly. As for forwarding, I turn it on by editing /etc/sysctl.conf and making it a permanent change in that file (that file will preload the echo > 1 ... command automatically at boot so that I don't have to script it.)

The major problem that appears to be happening is that when I set this up, port 80 traffic doesn't get routed.

I've tried both the lines you've listed and the ones in my previous post. It just doesn't seem to work. I'm assuming at this point that's it's something really simple that I've overlooked.
 
Old 01-01-2002, 03:45 AM   #4
infinity6
Member
 
Registered: Dec 2001
Posts: 66

Original Poster
Rep: Reputation: 15
Fixed my first problem. Apparently, there was some old information in my script from a previous firewall that I was trying to build. Once I cleared that out and set up the rules as I had them, things worked great.

Now there's one other problem, how do I get traffic from one domain to forward to my internal box, while the rest of the machines on the network go out to the internet for www traffic? I haven't seen anything posted to this effect, and I haven't seen anything in either the iptables howto on linuxdoc, nor several of the other guides I've read through online. If anyone could point me to some good documentation, or another thread, I'd really appreciate it.
 
  


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
iptables port forwarding geoff3425 Slackware 13 12-20-2011 11:50 AM
IPCHAINS port forwarding and IPTABLES port forwarding ediestajr Linux - Networking 26 01-14-2007 08:35 PM
port forwarding with iptables kkennedy Linux - Networking 1 09-01-2005 07:48 PM
iptables port forwarding jefmwols Linux - Networking 9 05-20-2005 05:08 PM
IPTABLES and port forwarding freibuis Linux - Networking 5 04-21-2004 10:06 PM

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

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