Port forwarding / NAT loopback / NAT reflection / NAT hairpinning solution...

Discussions for BiPAC 8800 series: 8800NL, 8800NLR2, 8800AXL, 8800AXLR2
Post Reply
rob8800nl
Posts: 1
Joined: Wed Dec 07, 2016 2:35 pm

Port forwarding / NAT loopback / NAT reflection / NAT hairpinning solution...

Post by rob8800nl »

Hi,

Not so much a question as a solution. I had this problem, spent a couple of days tearing my hair out, and finally solved it... so perhaps this'll help someone else, too.

I have an mailserver running on my lan, and wanted to set it up to be externally accessible on my domain name pointing to a static IP address (so I could check my mail while I'm out and about), but also so that I could access it from inside the LAN without having to change anything on my laptop each time... That meant using port forwarding (or Virtual Servers as they're called on this router) and making use of NAT loopback which is just something that "works"...

At least that was the theory. I got the port forwarding working fine, and using my mobile on a 4G connection (so external) I could get to the server and pick up my mail without a problem. But inside the LAN it didn't work. I tried everything, even packet sniffing, with the following results...

I've put the TCPdump from the mailserver (Ubuntu on a RaspPi2) at the bottom for those who are interested...

Anyway... the long and the short of it was that I'd set up the port forwarding, but neglected to change the port of the admin website from port 80 :oops: ... As soon as I did that (set the admin site to show on :8080) lo and behold, up it popped, fully working.

So the moral of the story is... check you haven't left the admin site on port 80 when you want to use nat loopback with virtual servers. It'll break nat loopback for ports that have nothing to do with port 80.

Hope that helps someone, and that they end up with more hair than I have left! :D

Rob

TCPdump follows:

FAILED NAT LOOPBACK FROM INTERNAL CONNECTION...
07:23:47.044690 IP 192.168.1.254.37050 > 192.168.1.252.25: Flags [S], seq 2701562951, win 65535, options [mss 1460,sackOK,TS val 1828594 ecr 0,nop,wscale 7], length 0
...NO RESPONSE! (DOESN'T EVEN TRY!)

EXTERNAL CONNECTION ...
07:23:59.921441 IP 185.69.145.253.58707 > 192.168.1.252.25: Flags [S], seq 110374713, win 14600, options [mss 1452,sackOK,TS val 869008641 ecr 0,nop,wscale 7], length 0
...RESPONDS AS EXPECTED
07:23:59.922052 IP 192.168.1.252.25 > 185.69.145.253.58707: Flags [S.], seq 3248198840, ack 110374714, win 28960, options [mss 1460,sackOK,TS val 14877144 ecr 869008641,nop,wscale 7], length 0
07:23:59.945062 IP 185.69.145.253.58707 > 192.168.1.252.25: Flags [.], ack 1, win 115, options [nop,nop,TS val 869008647 ecr 14877144], length 0
07:24:00.166087 IP 192.168.1.252.25 > 185.69.145.253.58707: Flags [P.], seq 1:36, ack 1, win 227, options [nop,nop,TS val 14877205 ecr 869008647], length 35: SMTP: 220 mail.[MYDOMAIN.COM] ESMTP Postfix
07:24:00.188599 IP 185.69.145.253.58707 > 192.168.1.252.25: Flags [.], ack 36, win 115, options [nop,nop,TS val 869008708 ecr 14877205], length 0
Andrue
Posts: 5
Joined: Tue Dec 13, 2016 11:50 am

Re: Port forwarding / NAT loopback / NAT reflection / NAT hairpinning solution...

Post by Andrue »

There is another way to do this (at least it's what I did with my 6300 and hope will work for my 8800). Add a static routing of your_domain->LAN address of your server eg;

yourdomain.com -> 192.168.1.1

Of course this won't work if you have more than one machine that is visible from the WAN but it means that you can leave your router set at the default port ;)
Post Reply