View previous topic :: View next topic |
Author |
Message |
sbrenneis n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 08 Dec 2006 Posts: 9
|
Posted: Fri Jun 19, 2009 2:49 am Post subject: Problem with port forwarding |
|
|
I have a Gentoo server that I am using for a firewall/DMZ. It has two NICsOn my LAN, I have a Fedora system that is running jboss on port 8080. I want to forward port 8080 traffic to the internal server.
I have set up the following iptables rules on the Gentoo server:
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 8080 -j DNAT --to 192.168.0.101:8080
iptables -A INPUT -p tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -p tcp --dport 25 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -p tcp --dport 8080 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -p tcp --dport 993 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -p udp --dport 1194 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -p tcp --dport 3306 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -p tcp --dport 3690 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -p tcp --dport 10080 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -p tcp --dport 10081 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -i eth0 -m state --state NEW,INVALID -j DROP
I have verified that nothing is running on port 8080 on the firewall/DMZ server, and I have verified that jboss is listening on port 8080 on the internal server. WHen i give the URL for the jboss console to my browser, it times out. I have had other people attempt to get to the URL as well.
Any ideas? I have no idea how to troubleshoot an iptables issue, as there are no logs that I know of. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Hu Administrator
![Administrator Administrator](/images/ranks/rank-admin.gif)
Joined: 06 Mar 2007 Posts: 23100
|
Posted: Fri Jun 19, 2009 3:15 am Post subject: |
|
|
Have you turned on IP forwarding? What is the output of iptables-save -c? Have you conducted your tests from outside? Your PREROUTING rule will only cover traffic coming from the Internet, so if you test this from inside the LAN, it will not work.
You can use the LOG target to record when traffic matches a rule. Additionally, each rule maintains counters of how many packets and bytes have matched it. You could also use tcpdump to monitor the interface to confirm that the request arrives from the Internet. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Bones McCracker Veteran
![Veteran Veteran](/images/ranks/rank_rect_5_vet.gif)
![](images/avatars/20601834835104a1059a7d6.jpg)
Joined: 14 Mar 2006 Posts: 1611 Location: U.S.A.
|
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
bbgermany Veteran
![Veteran Veteran](/images/ranks/rank_rect_5_vet.gif)
![](images/avatars/14656390143b65679294bf.jpg)
Joined: 21 Feb 2005 Posts: 1844 Location: Oranienburg/Germany
|
Posted: Fri Jun 19, 2009 6:40 am Post subject: |
|
|
Instead of an input rule, you need a forward rule like this:
Code: |
iptables -t nat -A PREROUTING -p tcp --dport 8080 -j DNAT --to 192.168.0.101:8080
iptables -A FORWARD -p tcp --dport 8080 -d 192.168.0.101 -m state --state NEW,ESTABLISHED -j ACCEPT
|
in some cases, you may need RELATED as state as well.
bb _________________ Desktop: Ryzen 5 5600G, 32GB, 2TB, RX7600
Notebook: Dell XPS 13 9370, 16GB, 1TB
Server #1: Ryzen 5 Pro 4650G, 64GB, 16.5TB
Server #2: Ryzen 4800H, 32GB, 22TB |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
xtz Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
![](images/avatars/gallery/Star Wars/movie_star_wars_darth_vader.gif)
Joined: 29 Oct 2007 Posts: 181 Location: Singapore
|
Posted: Fri Jun 19, 2009 6:49 am Post subject: |
|
|
MASQUERADE is obsolete, a simple DNAT rule should do the work, since SNAT/DNAT work in both ways. Also, as bbgermany mentioned, it's the FORWARD table you need to modify - not the INPUT one. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Bones McCracker Veteran
![Veteran Veteran](/images/ranks/rank_rect_5_vet.gif)
![](images/avatars/20601834835104a1059a7d6.jpg)
Joined: 14 Mar 2006 Posts: 1611 Location: U.S.A.
|
Posted: Fri Jun 19, 2009 8:44 am Post subject: |
|
|
the input table is for traffic destined for the firewall machine itself
the forward table is for everything else _________________
patrix_neo wrote: | The human thought: I cannot win.
The ratbrain in me : I can only go forward and that's it. |
|
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
sbrenneis n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 08 Dec 2006 Posts: 9
|
Posted: Fri Jun 19, 2009 1:32 pm Post subject: |
|
|
Thanks to all. The FORWARD table entry fixed it. I appreciate the help. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Bones McCracker Veteran
![Veteran Veteran](/images/ranks/rank_rect_5_vet.gif)
![](images/avatars/20601834835104a1059a7d6.jpg)
Joined: 14 Mar 2006 Posts: 1611 Location: U.S.A.
|
Posted: Fri Jun 19, 2009 5:40 pm Post subject: |
|
|
Spend some time with the resources at those links. They are very informative. _________________
patrix_neo wrote: | The human thought: I cannot win.
The ratbrain in me : I can only go forward and that's it. |
|
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Hu Administrator
![Administrator Administrator](/images/ranks/rank-admin.gif)
Joined: 06 Mar 2007 Posts: 23100
|
Posted: Sat Jun 20, 2009 2:00 am Post subject: |
|
|
xtz wrote: | MASQUERADE is obsolete |
Not entirely. MASQUERADE has the useful property that it will automatically determine the IP address to place on the outbound packet, which can be useful if the interface is dynamically configured and could have its address changed outside your control. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
xtz Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
![](images/avatars/gallery/Star Wars/movie_star_wars_darth_vader.gif)
Joined: 29 Oct 2007 Posts: 181 Location: Singapore
|
Posted: Mon Jun 22, 2009 12:02 pm Post subject: |
|
|
Well, it could be done with SNAT/DNAT also (and some scripting)... but if the address changes on the fly, it surely will miss some packets, even if the scripts are run immediately. I guess MASQUERADE is better, if that is the situation. Thanks ![Smile :)](images/smiles/icon_smile.gif) |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
|