Problem with simple iptables rule with newer fw

Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware
Author Message
jaru
DD-WRT Novice


Joined: 22 Aug 2016
Posts: 9

PostPosted: Tue Nov 27, 2018 16:51    Post subject: Problem with simple iptables rule with newer fw Reply with quote
Hello,

I have a problem with simple rule on newer kong builds.
It seems like no support for prerouting/postrouting here is my "rule":
iptables -t nat -A PREROUTING -p tcp --dport 10101 -j DNAT --to-destination 192.168.102.1:9040

It worked on older builds, and yes I'm after nvram erase before and after fw upgrade:)

DD-WRT v3.0-r37015M kongac (09/23/1Cool
Sponsor
newsboost
DD-WRT User


Joined: 05 Jul 2018
Posts: 83

PostPosted: Wed Nov 28, 2018 14:43    Post subject: Re: Problem with simple iptables rule with newer fw Reply with quote
jaru wrote:
Hello,

I have a problem with simple rule on newer kong builds.
It seems like no support for prerouting/postrouting here is my "rule":
iptables -t nat -A PREROUTING -p tcp --dport 10101 -j DNAT --to-destination 192.168.102.1:9040

It worked on older builds, and yes I'm after nvram erase before and after fw upgrade:)

DD-WRT v3.0-r37015M kongac (09/23/1Cool
Just a suggestion, but have you tried INSERTING the rule instead of APPENDING it (option "-I" instead of "-A")? This way, your rule will be in the top of the other rules instead of in the end...
Per Yngve Berg
DD-WRT Guru


Joined: 13 Aug 2013
Posts: 6870
Location: Romerike, Norway

PostPosted: Wed Nov 28, 2018 19:25    Post subject: Reply with quote
Input interface is missing (-i get_wanface`)
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12917
Location: Netherlands

PostPosted: Thu Nov 29, 2018 9:22    Post subject: Reply with quote
Why are you using this rule?
For port forward you can use the GUI

_________________
Routers:Netgear R7000, R6400v1, R6400v2, EA6900 (XvortexCFE), E2000, E1200v1, WRT54GS v1.
Install guide R6400v2, R6700v3,XR300:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399
Install guide R7800/XR500: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614
Forum Guide Lines (important read):https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
NovakJokovic
DD-WRT Novice


Joined: 16 Nov 2018
Posts: 5

PostPosted: Thu Nov 29, 2018 9:43    Post subject: Reply with quote
iptables is a user-space utility program that allows a system administrator to configure the tables provided by the Linux kernel firewall (implemented as different Netfilter modules) and the chains and rules it stores.
Mile-Lile
DD-WRT Guru


Joined: 24 Feb 2013
Posts: 1634
Location: Belgrade

PostPosted: Thu Nov 29, 2018 9:51    Post subject: Reply with quote
I would do it like this:

Code:
iptables -t nat -I PREROUTING -p tcp -d `nvram get wan_ipaddr` --dport 10101 -j DNAT --to-destination 192.168.102.1:9040
jaru
DD-WRT Novice


Joined: 22 Aug 2016
Posts: 9

PostPosted: Thu Nov 29, 2018 12:07    Post subject: Reply with quote
egc wrote:
Why are you using this rule?
For port forward you can use the GUI


Not really... I want to pass traffic for one port thru tor proxy on my router not from wan to lan Smile

For example:
machine from lan (192.168.102.200) connecting to x.x.x.x:10101, so I need pass this traffic thru tor proxy binded on port 9040 on my router 192.168.102.1.
Previously my rule worked but unfortunately not now.
jaru
DD-WRT Novice


Joined: 22 Aug 2016
Posts: 9

PostPosted: Thu Nov 29, 2018 12:08    Post subject: Re: Problem with simple iptables rule with newer fw Reply with quote
newsboost wrote:
jaru wrote:
Hello,

I have a problem with simple rule on newer kong builds.
It seems like no support for prerouting/postrouting here is my "rule":
iptables -t nat -A PREROUTING -p tcp --dport 10101 -j DNAT --to-destination 192.168.102.1:9040

It worked on older builds, and yes I'm after nvram erase before and after fw upgrade:)

DD-WRT v3.0-r37015M kongac (09/23/1Cool
Just a suggestion, but have you tried INSERTING the rule instead of APPENDING it (option "-I" instead of "-A")? This way, your rule will be in the top of the other rules instead of in the end...


It was my first idea, but tried that Sad
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12917
Location: Netherlands

PostPosted: Thu Nov 29, 2018 12:13    Post subject: Reply with quote
As you erased nvram, are you sure the destination adress is still the same?
Because the rule should actually work

_________________
Routers:Netgear R7000, R6400v1, R6400v2, EA6900 (XvortexCFE), E2000, E1200v1, WRT54GS v1.
Install guide R6400v2, R6700v3,XR300:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399
Install guide R7800/XR500: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614
Forum Guide Lines (important read):https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
jaru
DD-WRT Novice


Joined: 22 Aug 2016
Posts: 9

PostPosted: Thu Nov 29, 2018 16:11    Post subject: Reply with quote
egc wrote:
As you erased nvram, are you sure the destination adress is still the same?
Because the rule should actually work


Yes I'm sure Sad Address is the same, without erasing nvram there was a problems with firewall as overall (maquerade etc.) As I See at tcpdump all traffic to mentioned port goes to internet bypassing rule. Dunno where is a problem.
<Kong>
DD-WRT Guru


Joined: 15 Dec 2010
Posts: 4339
Location: Germany

PostPosted: Thu Nov 29, 2018 19:00    Post subject: Reply with quote
jaru wrote:
egc wrote:
Why are you using this rule?
For port forward you can use the GUI


Not really... I want to pass traffic for one port thru tor proxy on my router not from wan to lan Smile

For example:
machine from lan (192.168.102.200) connecting to x.x.x.x:10101, so I need pass this traffic thru tor proxy binded on port 9040 on my router 192.168.102.1.
Previously my rule worked but unfortunately not now.


Rule works here, just run "iptables -vnL -t nat" to check if it was inserted and to see any rules that may pass the traffic before it reaches your rule.

_________________
KONG PB's: http://www.desipro.de/ddwrt/
KONG Info: http://tips.desipro.de/
jaru
DD-WRT Novice


Joined: 22 Aug 2016
Posts: 9

PostPosted: Fri Nov 30, 2018 7:14    Post subject: Reply with quote
<Kong> wrote:
jaru wrote:
egc wrote:
Why are you using this rule?
For port forward you can use the GUI


Not really... I want to pass traffic for one port thru tor proxy on my router not from wan to lan Smile

For example:
machine from lan (192.168.102.200) connecting to x.x.x.x:10101, so I need pass this traffic thru tor proxy binded on port 9040 on my router 192.168.102.1.
Previously my rule worked but unfortunately not now.


Rule works here, just run "iptables -vnL -t nat" to check if it was inserted and to see any rules that may pass the traffic before it reaches your rule.


It's very very strange, I can see packets that match rule:
Chain PREROUTING (policy ACCEPT 165 packets, 13404 bytes)
pkts bytes target prot opt in out source destination
7 420 DNAT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:10101 to:192.168.102.1:9040
(...) other rules

But on tcpdump (port 10101):
listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes
08:07:09.872167 ethertype IPv4, IP 192.168.102.200.33434 > some.internet.host.10101: Flags [S], seq 3832230864, win 29200, options [mss 1460,sackOK,TS val 1698529080 ecr 0,nop,wscale 7], length 0
08:07:09.873509 IP 192.168.102.200.33434 > some.internet.host.10101: Flags [S], seq 3832230864, win 29200, options [mss 1460,sackOK,TS val 1698529080 ecr 0,nop,wscale 7], length 0
08:07:09.875266 IP 192.168.102.200.33434 > some.internet.host.10101: Flags [S], seq 3832230864, win 29200, options [mss 1460,sackOK,TS val 1698529080 ecr 0,nop,wscale 7], length 0
08:07:09.876935 IP some.internet.host.10101 > 192.168.102.200.33434: Flags [S.], seq 1942564665, ack 3832230865, win 28960, options [mss 1460,sackOK,TS val 17665 ecr 1698529080,nop,wscale 4], length 0
08:07:09.878458 IP some.internet.host.10101 > 192.168.102.200.33434: Flags [S.], seq 1942564665, ack 3832230865, win 28960, options [mss 1460,sackOK,TS val 17665 ecr 1698529080,nop,wscale 4], length 0

And nothing on 9040...
newsboost
DD-WRT User


Joined: 05 Jul 2018
Posts: 83

PostPosted: Wed Dec 05, 2018 13:03    Post subject: Reply with quote
jaru wrote:
...192.168.102.200.33434: Flags [S.], seq 1942564665, ack 3832230865, win 28960, options [mss 1460,sackOK,TS val 17665 ecr 1698529080,nop,wscale 4], length 0

And nothing on 9040...
So... your tor-daemon is running and fully functional? AFAIR "netstat -tulpn" or similar should show if anything is listening on port 9040... Sounds like iptables- forwarding IS active, but your daemon is not...
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum