Port Forwarding only works on certain types of connections

Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking
Author Message
mburgoon
DD-WRT Novice


Joined: 18 Mar 2017
Posts: 8

PostPosted: Fri May 19, 2017 18:14    Post subject: Port Forwarding only works on certain types of connections Reply with quote
Update 5/22
If I ssh into the router and try to access the forwarded ports using the full domain name, I get "Connection refused". But if I try to access those same ports from the system inside the network from which I ssh'd into the router, the connection goes through.

Anyone have any ideas?


I have a Netgear R6700 running DD-WRT v3.0-r31722 (03/21/17).
I have my own mail server running on a Synology NAS. I have opened up SMTP, IMAP, and POP3 through the router and as long as I am in my home, using a device (laptop, tablet, handheld, desktop) that is connected via my internal network, either direct or wifi, everything forwards fine. I'm able to resolve and connect to my external fully qualified domain name (via DynDNS) from these devices, being forwarded to my mail server.
However, if I disable wifi on my handheld/tablet and rely solely on cellular (using the exact same mail settings), the connection does not get forwarded and I can't retrieve my mail.

I'm stumped...

I've included a listing of my iptables below.


Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
1845 321K ACCEPT 0 -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
0 0 ACCEPT 47 -- * vlan2 192.168.1.0/24 0.0.0.0/0
0 0 ACCEPT tcp -- * vlan2 192.168.1.0/24 0.0.0.0/0 tcp dpt:1723
285 44783 lan2wan 0 -- * * 0.0.0.0/0 0.0.0.0/0
58 19872 ACCEPT 0 -- br0 br0 0.0.0.0/0 0.0.0.0/0
0 0 ACCEPT tcp -- * * 192.168.1.0/24 192.168.1.111 tcp dpt:110
0 0 ACCEPT udp -- * * 192.168.1.0/24 192.168.1.111 udp dpt:110
0 0 ACCEPT tcp -- * * 192.168.1.0/24 192.168.1.111 tcp dpt:995
0 0 ACCEPT udp -- * * 192.168.1.0/24 192.168.1.111 udp dpt:995
0 0 ACCEPT tcp -- * * 192.168.1.0/24 192.168.1.111 tcp dpt:143
0 0 ACCEPT udp -- * * 192.168.1.0/24 192.168.1.111 udp dpt:143
0 0 ACCEPT tcp -- * * 192.168.1.0/24 192.168.1.111 tcp dpt:993
0 0 ACCEPT udp -- * * 192.168.1.0/24 192.168.1.111 udp dpt:993
0 0 ACCEPT tcp -- * * 192.168.1.0/24 192.168.1.111 tcp dpt:25
0 0 ACCEPT udp -- * * 192.168.1.0/24 192.168.1.111 udp dpt:25
0 0 ACCEPT tcp -- * * 192.168.1.0/24 192.168.1.111 tcp dpt:465
0 0 ACCEPT udp -- * * 192.168.1.0/24 192.168.1.111 udp dpt:465
0 0 ACCEPT tcp -- * * 192.168.1.0/24 192.168.1.148 tcp dpt:5000
0 0 ACCEPT udp -- * * 192.168.1.0/24 192.168.1.148 udp dpt:5000
0 0 ACCEPT tcp -- * * 192.168.1.0/24 192.168.1.148 tcp dpt:5001
0 0 ACCEPT udp -- * * 192.168.1.0/24 192.168.1.148 udp dpt:5001
0 0 ACCEPT tcp -- * * 192.168.1.0/24 192.168.1.148 tcp dpt:9920
0 0 ACCEPT udp -- * * 192.168.1.0/24 192.168.1.148 udp dpt:9920
0 0 TRIGGER 0 -- vlan2 br0 0.0.0.0/0 0.0.0.0/0 TRIGGER type:in match:0 relate:0
227 24911 trigger_out 0 -- br0 * 0.0.0.0/0 0.0.0.0/0
192 23199 ACCEPT 0 -- br0 * 0.0.0.0/0 0.0.0.0/0 state NEW
35 1712 DROP 0 -- * * 0.0.0.0/0 0.0.0.0/0
Sponsor
mburgoon
DD-WRT Novice


Joined: 18 Mar 2017
Posts: 8

PostPosted: Mon May 22, 2017 19:03    Post subject: Reply with quote
No one?
mburgoon
DD-WRT Novice


Joined: 18 Mar 2017
Posts: 8

PostPosted: Fri May 26, 2017 2:50    Post subject: Reply with quote
Did I post to the wrong thread?
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12884
Location: Netherlands

PostPosted: Fri May 26, 2017 11:54    Post subject: Reply with quote
No you did not post in the wrong thread, but the answer is not obvious Sad

One possibility is that your ISP is blocking this kind of traffic. Ask your ISP or use different ports

_________________
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
mburgoon
DD-WRT Novice


Joined: 18 Mar 2017
Posts: 8

PostPosted: Fri May 26, 2017 14:36    Post subject: Reply with quote
Hi EGC, thanks for the reply. I checked with my ISP and they don't block anything. Plus, if I use my fully qualified domain name from inside my network, I'm using DynDNS to resolve my external IPA and domain name, it works fine, even stating the external IPA that its attempting to access. Its just simple mail, POP3, SMTP, and IMAP that I'm attempting to contact, so the ports aren't anything special. I've turned on logging but port accesses and denials don't seem to be logged. I must have configured something wrong in the router, but I can't think of anything I haven't looked at.
Any suggestions on what to try?
Thanks!
mburgoon
DD-WRT Novice


Joined: 18 Mar 2017
Posts: 8

PostPosted: Fri May 26, 2017 21:55    Post subject: Reply with quote
Does this iptables list help any?

Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT 0 -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT udp -- anywhere anywhere udp spt:bootps dpt:bootpc
DROP udp -- anywhere anywhere udp dpt:route
DROP udp -- anywhere anywhere udp dpt:route
ACCEPT udp -- anywhere anywhere udp dpt:route
DROP icmp -- anywhere anywhere
DROP igmp -- anywhere anywhere
ACCEPT 0 -- anywhere anywhere state NEW
ACCEPT 0 -- anywhere anywhere state NEW
DROP 0 -- anywhere anywhere

Chain FORWARD (policy ACCEPT)
target prot opt source destination
ACCEPT 0 -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT gre -- 192.168.1.0/24 anywhere
ACCEPT tcp -- 192.168.1.0/24 anywhere tcp dpt:1723
lan2wan 0 -- anywhere anywhere
ACCEPT 0 -- anywhere anywhere
ACCEPT tcp -- 192.168.1.0/24 192.168.1.111 tcp dpt:pop3
ACCEPT udp -- 192.168.1.0/24 192.168.1.111 udp dpt:pop3
ACCEPT tcp -- 192.168.1.0/24 192.168.1.111 tcp dpt:pop3s
ACCEPT udp -- 192.168.1.0/24 192.168.1.111 udp dpt:995
ACCEPT tcp -- 192.168.1.0/24 192.168.1.111 tcp dpt:imap2
ACCEPT udp -- 192.168.1.0/24 192.168.1.111 udp dpt:imap2
ACCEPT tcp -- 192.168.1.0/24 192.168.1.111 tcp dpt:imaps
ACCEPT udp -- 192.168.1.0/24 192.168.1.111 udp dpt:993
ACCEPT tcp -- 192.168.1.0/24 192.168.1.111 tcp dpt:smtp
ACCEPT udp -- 192.168.1.0/24 192.168.1.111 udp dpt:25
ACCEPT tcp -- 192.168.1.0/24 192.168.1.111 tcp dpt:ssmtp
ACCEPT udp -- 192.168.1.0/24 192.168.1.111 udp dpt:465
ACCEPT tcp -- 192.168.1.0/24 192.168.1.148 tcp dpt:5000
ACCEPT udp -- 192.168.1.0/24 192.168.1.148 udp dpt:5000
ACCEPT tcp -- 192.168.1.0/24 192.168.1.148 tcp dpt:5001
ACCEPT udp -- 192.168.1.0/24 192.168.1.148 udp dpt:5001
ACCEPT tcp -- 192.168.1.0/24 192.168.1.148 tcp dpt:9920
ACCEPT udp -- 192.168.1.0/24 192.168.1.148 udp dpt:9920
ACCEPT tcp -- 192.168.1.0/24 192.168.1.71 tcp dpt:5005
ACCEPT udp -- 192.168.1.0/24 192.168.1.71 udp dpt:5005
TRIGGER 0 -- anywhere anywhere TRIGGER type:in match:0 relate:0
trigger_out 0 -- anywhere anywhere
ACCEPT 0 -- anywhere anywhere state NEW
DROP 0 -- anywhere anywhere

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

Chain advgrp_1 (0 references)
target prot opt source destination

Chain advgrp_10 (0 references)
target prot opt source destination

Chain advgrp_2 (0 references)
target prot opt source destination

Chain advgrp_3 (0 references)
target prot opt source destination

Chain advgrp_4 (0 references)
target prot opt source destination

Chain advgrp_5 (0 references)
target prot opt source destination

Chain advgrp_6 (0 references)
target prot opt source destination

Chain advgrp_7 (0 references)
target prot opt source destination

Chain advgrp_8 (0 references)
target prot opt source destination

Chain advgrp_9 (0 references)
target prot opt source destination

Chain grp_1 (0 references)
target prot opt source destination

Chain grp_10 (0 references)
target prot opt source destination

Chain grp_2 (0 references)
target prot opt source destination

Chain grp_3 (0 references)
target prot opt source destination

Chain grp_4 (0 references)
target prot opt source destination

Chain grp_5 (0 references)
target prot opt source destination

Chain grp_6 (0 references)
target prot opt source destination

Chain grp_7 (0 references)
target prot opt source destination

Chain grp_8 (0 references)
target prot opt source destination

Chain grp_9 (0 references)
target prot opt source destination

Chain lan2wan (1 references)
target prot opt source destination

Chain logaccept (0 references)
target prot opt source destination
ACCEPT 0 -- anywhere anywhere

Chain logdrop (0 references)
target prot opt source destination
DROP 0 -- anywhere anywhere

Chain logreject (0 references)
target prot opt source destination
REJECT tcp -- anywhere anywhere reject-with tcp-reset

Chain trigger_out (1 references)
target prot opt source destination
Per Yngve Berg
DD-WRT Guru


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

PostPosted: Sat May 27, 2017 7:28    Post subject: Reply with quote
I believe "Connection refused" is coming from the NAS. Does it have a firewall? Is it open to addresses outside of your lan?
mburgoon
DD-WRT Novice


Joined: 18 Mar 2017
Posts: 8

PostPosted: Sat May 27, 2017 16:09    Post subject: Reply with quote
I did a couple tests to try out your thought. I disabled all firewalls on the NAS, no change. I then disabled the forward for one of the ports and tried to access it from my internal network (using the fully qualified, external domain name). I received the same connection refused error that I get from a device not directly connected to the internal network. Once I re-enabled the forwarded port, I was able to access the device.
As far as the NAS is concerned, the request is coming from my router, 192.168.1.1, whether I'm connected internally or not, since in all cases I'm using the fully qualified domain name, which DynDNS resolves properly in either case. So the router thinks the request is coming from outside, no matter how the device is connected.
Its VERY weird and I'm out of ideas.
Is there a log on the router that I'm unaware of that would show this activity?
Crying or Very sad


Last edited by mburgoon on Sat May 27, 2017 16:40; edited 1 time in total
Per Yngve Berg
DD-WRT Guru


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

PostPosted: Sat May 27, 2017 16:28    Post subject: Reply with quote
mburgoon wrote:
I did a couple tests to try out your thought. I disabled all firewalls on the NAS, no change. I then disabled the forward for one of the ports and tried to access it from my internal network (using the fully qualified, external domain name). I received the same connection refused error that I get from a device not directly connected to the internal network. Once I re-enabled the forwarded port, I was able to access the device.

Are you describing what is called "NAT Loopback"? Connections from the lan is sent to the wan interface and then NAT'ed and sent back to the lan. A better approach here is to use a local dns that resolves the FQN to the private ip on the lan, while the public dns resolves to the Public ip for external clients.

mburgoon wrote:
As far as the NAS is concerned, the request is coming from my router, 192.168.1.1, whether I'm connected internally or not

This is not true. Only the destination address is replaced to the private address of the NAS. The NAS will se the public address of the source device.
mburgoon
DD-WRT Novice


Joined: 18 Mar 2017
Posts: 8

PostPosted: Sun May 28, 2017 14:55    Post subject: Reply with quote
mburgoon wrote:
As far as the NAS is concerned, the request is coming from my router, 192.168.1.1, whether I'm connected internally or not

"This is not true. Only the destination address is replaced to the private address of the NAS. The NAS will se the public address of the source device."

I got to thinking about this and realized you are correct, how else would the NAS know were to send the reply? Shocked

I removed the source IP from the rules and that did the trick. The router allows the connection to be forwarded from anywhere now, not just internal addresses.

Thanks for your assistance.
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking 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 cannot attach files in this forum
You cannot download files in this forum