Linux - NetworkingThis 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.
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.
You might need to specify the interfaces. To get forwarding to work with my webserver, I did the following:
In the NAT table:
-A PREROUTING -d XXX.XXX.XXX.XXX -i eth0 -p tcp -m tcp --dport 80 -j DNAT --to-destination 192.168.0.2
And in the filter table, I have:
-A FORWARD -i eth0 -o eth1 -p tcp -m tcp --dport 80 -m state --state NEW,RELATED -j ACCEPT
-A FORWARD -i eth0 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i eth1 -o eth0 -j ACCEPT
So substitute eth1 with eth2 and it should work. Also, you're not editing the actual /etc/sysconfig/iptables directly are you?
to test, i started apache on the firewall. then i stopped iptables, and tried to access x.x.x.x via a browser from a computer on a different network. i got to the page on the firewall ok, so then i started iptables back up, and refreshed the browser. ok so if i all went well, it should have fwd'd me to the real webserver behind the firewall... the browser sat there for a while and then replied an error message. so, because the web page on the firewall didnt show up, i can only assume that iptables is trying to do something with port 80 traffic.. but for some reason its not getting to the web server.
Flush all of the old rules in the NAT table and set it up like this:
*nat
:PREROUTING ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A PREROUTING -d xxx.xxx.xxx.xxx -i eth0 -p tcp -m tcp --dport 80 -j DNAT --to-destination 192.168.25.4
-A POSTROUTING -o eth0 -j MASQUERADE
Some of those other NAT rules might be the problem. The above NAT rules work for the exactly same setup you have. Make sure to keep the 3 FORWARDING rules that I posted in the filter. You might also want to fireup tcpdump or ethereal and see directly what is happening to the packets. It sounds like they're being forwarded, but not getting back out properly or something. Also set the Apache log level to DEBUG and look at what's going on.
HTH
Try changing your default OUTPUT policy to ACCEPT. It's usually easier to just filter out all the bad outgoing packets, rather than specifically specify which ones you want to allow out (it can be tricky to do it like that). I didn't catch it the first time I looked at your rules.
im starting to think there might be somethign wrong with something else besides iptables. ive tried a ton of different rules and the same problem each time.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.