LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   adsl+iptables+port forward+"-m tcp" strange problem (https://www.linuxquestions.org/questions/linux-networking-3/adsl-iptables-port-forward-m-tcp-strange-problem-346964/)

icry0000 07-26-2005 11:35 AM

adsl+iptables+port forward+"-m tcp" strange problem
 
adsl+iptables+port forward+"-m tcp" strange problem
I.state the situation
i'm using a iptables gateway dialing up adsl connection to connect the internet,
and port forwad LAN services to the internet, the classic situation.

II.problem
when i use DNAT with "-m tcp" , it works fine:
/sbin/iptables -t nat -A PREROUTING -p tcp -m tcp --dport 12000 -j DNAT --to 192.168.0.24

but, without "-m tcp" , it's all over , failed.
/sbin/iptables -t nat -A PREROUTING -p tcp --dport 12000 -j DNAT --to 192.168.0.24

In the formal/informal docs of netfilter i have read, i cant find anything about "-m tcp" ,but almost every DNAT uses this option

I guess without "-m tcp" the static IP situation will work , but without it ,
an adsl connection will not.

Maybe implicit rules do not take effect when using dynamic IP, so the explicit -m tcp must be added.

Anyone could help ? thank a lot!

deoren 07-26-2005 02:43 PM

From: http://www.die.net/doc/linux/man/man8/iptables.8.html

Quote:

iptables can use extended packet matching modules. These are loaded in two ways: implicitly, when -p or --protocol is specified, or with the -m or --match options, followed by the matching module name; after these, various extra command line options become available, depending on the specific module. You can specify multiple extended match modules in one line, and you can use the -h or --help options after the module has been specified to receive help specific to that module.

Code:

--dport 12000
That is a command option passed to the tcp module.



BTW, an awesome book to pick up is Linux Firewalls
http://print.google.com/print?id=rIW...-US:unofficial
http://www.amazon.com/exec/obidos/tg...31843?v=glance
http://half.ebay.com/cat/buy/prod.cgi?cpid=1076493453

mpeg4codec 07-26-2005 08:18 PM

Try including the port in the DNAT command. Instead of running this:

/sbin/iptables -t nat -A PREROUTING -p tcp -m tcp --dport 12000 -j DNAT --to 192.168.0.24

Run this:

/sbin/iptables -t nat -A PREROUTING -p tcp --dport 12000 -j DNAT --to 192.168.0.24:12000

Notice that the --to address includes the port now. See if that gives you any luck.

icry0000 07-31-2005 09:31 PM

Thank You
 
Thank You
And the version WITHOUT "-m tcp" was documented in the official HOW-TO provided by the netfilter.org .
SO , i posted this message.


All times are GMT -5. The time now is 11:12 PM.