Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
12-29-2001, 02:19 PM
|
#1
|
Member
Registered: Dec 2001
Posts: 66
Rep:
|
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?
|
|
|
12-31-2001, 10:13 AM
|
#2
|
LQ Newbie
Registered: Dec 2001
Distribution: Redhat / Mandrake / Suse / Debian
Posts: 6
Rep:
|
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
|
|
|
12-31-2001, 03:18 PM
|
#3
|
Member
Registered: Dec 2001
Posts: 66
Original Poster
Rep:
|
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.
|
|
|
01-01-2002, 03:45 AM
|
#4
|
Member
Registered: Dec 2001
Posts: 66
Original Poster
Rep:
|
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.
|
|
|
All times are GMT -5. The time now is 06:33 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|