DrayTek UK Users' Community Forum

Help, Advice and Solutions from DrayTek Users

Hairpin NAT / NAT Loopback / NAT Reflection

More
11 Feb 2019 14:25 #7 by x64

cwager990 wrote:

x64 wrote: From my experience with a 2862.I've had significant issues some of which involve NAT loopback.

Consider the following possibilities.
Default firewall rule set to BLOCK might affect reverse NAT include NAT loopback I found that I'ls impossible to write a rule to 're-allow' the traffic. (This WAS an issue for me in 2.8.9.2_BT- not sure if it was fixed in 3.8.9.3_BT). In the 2862 this does seem better in 3.9.0_BT. I worked around this by leaving the rule to allow and writing explicit f/w rules to block other traffic (in addition of course to rules to allow the traffic I wanted to pass)

Interaction of Use of multiple external IP addresses, IP Aliases to support them, and IP routed subnet (to a separate network LAN definition), alongside 'normal' NAT. The underlying issue remains even to 3.9.0_BT on the 2862. With the IP routed subnet configuration, NAT loopback from a device behind NAT on the default IP could not access a device published behind reverse NAT on an alias.



Okay, well that made some difference as you said I changed the default rule to pass, and then WAN > LAN Block if not further matches with all my allow rules below.

LOOPBACK now works for the main WAN IP Address but as you say not for any of the VIP's regardless of weather they are in the nat pool or not, is this the point at which I raise a support request with draytek? this was an expensive router that can not do something most basic models can do, really makes me mad.



Do you use a mix of public IP routed subnet and NAT/reverse NAT configurations? If so, I might have a workaround to provide limited functionality.....

Please Log in or Create an account to join the conversation.

  • cwager990
  • Topic Author
  • User is blocked
  • User is blocked
More
16 Feb 2019 18:20 #8 by cwager990
Replied by cwager990 on topic Re: Hairpin NAT / NAT Loopback / NAT Reflection

x64 wrote:

cwager990 wrote:

x64 wrote: From my experience with a 2862.I've had significant issues some of which involve NAT loopback.

Consider the following possibilities.
Default firewall rule set to BLOCK might affect reverse NAT include NAT loopback I found that I'ls impossible to write a rule to 're-allow' the traffic. (This WAS an issue for me in 2.8.9.2_BT- not sure if it was fixed in 3.8.9.3_BT). In the 2862 this does seem better in 3.9.0_BT. I worked around this by leaving the rule to allow and writing explicit f/w rules to block other traffic (in addition of course to rules to allow the traffic I wanted to pass)

Interaction of Use of multiple external IP addresses, IP Aliases to support them, and IP routed subnet (to a separate network LAN definition), alongside 'normal' NAT. The underlying issue remains even to 3.9.0_BT on the 2862. With the IP routed subnet configuration, NAT loopback from a device behind NAT on the default IP could not access a device published behind reverse NAT on an alias.



Okay, well that made some difference as you said I changed the default rule to pass, and then WAN > LAN Block if not further matches with all my allow rules below.

LOOPBACK now works for the main WAN IP Address but as you say not for any of the VIP's regardless of weather they are in the nat pool or not, is this the point at which I raise a support request with draytek? this was an expensive router that can not do something most basic models can do, really makes me mad.



Do you use a mix of public IP routed subnet and NAT/reverse NAT configurations? If so, I might have a workaround to provide limited functionality.....



X64 , Yes I do use a mix of IP Routed Subnet and NAT/reverse NAT.

Thanks Chris

Please Log in or Create an account to join the conversation.

More
16 Feb 2019 19:59 #9 by x64
OK,

Draytek support passed me a partial workaround. Obviously everyone's situation is different so this might or might not be of use to you as it does limit both how many addresses can be allocated to the NAT/reverse NAT system, and to the routed IPs. Additionally my router is a 2862ac. Additionally, you may also need to juggle the external IPs that you allocate to your services. Your public allocation might be larger than mine, which would (if this is any use to you at all) give you more flexibility.

My goal was to allocate my public range to one or the routers LAN subnets (LAN8), and to use a VLAN (VLAN7) to present that on a physical LAN port.

You might want to get a pencil and paper to map out the idea below - it will make more sense then, and you will be able to figure out how to apply it to your situation.

The IP range allocated by my ISP is a /29, and the seventh IP address (the one just below the broadcast address) is the IP address of the outside of the WAN1 configuration. If we call the individual IPs in my range IP0 to IP7, then that makes it my default ext IP IP6. My range is therefore written as IP0/29.

In an ideal world we allocate my entire range IP0/29 to LAN8 and everything would work... Of course it does not - that's why we're here.

Instead we think of my public IP range as half of that range - as a /30. The IPs NOT in that range work correctly for reverse NAT. Those in that range will fail[*]. For the /30, the gateway needs to match the ISPs default IP, so that defined which half of my range I had to overlay with the sawn-off public subnet. For me it was the upper half of my assignment, so the public range was entered as IP4/30 in the LAN8 configuration. As it is not a 'real' subnet - you can use IP4 as well as IP5 for the systems not behind NAT. (IP4 would usually be the 'subnet address' and not configurable for devices - in this case that does not mater - you can use it.

That leaves IP6 as the default NAT IP, and IP1, IP2 and IP3 available for aliases (for NAT/reverse NAT).

As this workaround dictates which half of your range has to be public IPs and which can have NAT aliases, you may need to juggle your allocations.

[edited for spelling and to add the following qualification]
[*] - I've not tried it, but reverse NAT to the gateway IP might work even though that IP is in the sawn-off public subnet range. My tests were against reverse NAT on alias IPs

Please Log in or Create an account to join the conversation.

  • cwager990
  • Topic Author
  • User is blocked
  • User is blocked
More
17 Feb 2019 19:58 #10 by cwager990
Replied by cwager990 on topic Re: Hairpin NAT / NAT Loopback / NAT Reflection

x64 wrote: OK,

Draytek support passed me a partial workaround. Obviously everyone's situation is different so this might or might not be of use to you as it does limit both how many addresses can be allocated to the NAT/reverse NAT system, and to the routed IPs. Additionally my router is a 2862ac. Additionally, you may also need to juggle the external IPs that you allocate to your services. Your public allocation might be larger than mine, which would (if this is any use to you at all) give you more flexibility.

My goal was to allocate my public range to one or the routers LAN subnets (LAN8), and to use a VLAN (VLAN7) to present that on a physical LAN port.

You might want to get a pencil and paper to map out the idea below - it will make more sense then, and you will be able to figure out how to apply it to your situation.

The IP range allocated by my ISP is a /29, and the seventh IP address (the one just below the broadcast address) is the IP address of the outside of the WAN1 configuration. If we call the individual IPs in my range IP0 to IP7, then that makes it my default ext IP IP6. My range is therefore written as IP0/29.

In an ideal world we allocate my entire range IP0/29 to LAN8 and everything would work... Of course it does not - that's why we're here.

Instead we think of my public IP range as half of that range - as a /30. The IPs NOT in that range work correctly for reverse NAT. Those in that range will fail[*]. For the /30, the gateway needs to match the ISPs default IP, so that defined which half of my range I had to overlay with the sawn-off public subnet. For me it was the upper half of my assignment, so the public range was entered as IP4/30 in the LAN8 configuration. As it is not a 'real' subnet - you can use IP4 as well as IP5 for the systems not behind NAT. (IP4 would usually be the 'subnet address' and not configurable for devices - in this case that does not mater - you can use it.

That leaves IP6 as the default NAT IP, and IP1, IP2 and IP3 available for aliases (for NAT/reverse NAT).

As this workaround dictates which half of your range has to be public IPs and which can have NAT aliases, you may need to juggle your allocations.

[edited for spelling and to add the following qualification]
[*] - I've not tried it, but reverse NAT to the gateway IP might work even though that IP is in the sawn-off public subnet range. My tests were against reverse NAT on alias IPs



Don't suppose you have a drawing you could show me ? I am not sure I am understanding it right

Please Log in or Create an account to join the conversation.

  • cwager990
  • Topic Author
  • User is blocked
  • User is blocked
More
17 Feb 2019 20:51 #11 by cwager990
Replied by cwager990 on topic Re: Hairpin NAT / NAT Loopback / NAT Reflection
Oh, I have got it working now x64, you are an absolute star, I can confirm this works for the 2860 :D

Please Log in or Create an account to join the conversation.

  • cwager990
  • Topic Author
  • User is blocked
  • User is blocked
More
18 Feb 2019 03:28 #12 by cwager990
Replied by cwager990 on topic Re: Hairpin NAT / NAT Loopback / NAT Reflection
There is one addition I would make to those instructions, if you are using more than one WAN, with some devices going out on WAN1 and some on WAN2, the devices that are on WAN2 will only be able to reach the Default WAN1 address using reverse NAT, the way to correct this is to add a static route as follows:

Destination IP Address: IP Alias you are trying to reach using reverse NAT

Subnet Mask: 255.255.255.255 / 32

Gateway IP Address: Address assigned to WAN1

Network Interface: WAN2

However counter intuitive this may sound it resolves the issue do you have a better suggestion than this x64 ?

Please Log in or Create an account to join the conversation.