This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DNAT Madness

We have an ASG120 between our Cable internet connection and our internal network (Masquaraded).

Going OUT from the internal network works no problem. I've checked a few features (blocking certain sites etc) and they work fine, but I want to enable ssh access to a server from outside our network, and eventually HTTP to a webserver.

Despite following the knowledgebase article 239708 to the letter, I am never forwarded to the server on our internal network. I continually time out.

My DNAT rule is as follows:
Name: SSH to Server
Traffic Source: Any
Traffic Service: SSH
Traffic Destination: External(Address)
NAT Mode: DNAT (Destination)
Destination: Main Server (established in Definitions)
Destination Service: SSH
Auto Packet Filter: unchecked

In Packet Filter I have a rule:
Position: Bottom
Source: External(Address)
Service: SSH
Destination: Main Server
Action: Allow

Both DNAT and Packet Filter rule are enabled, however, it still times out.

However, if i disable the DNAT rule, I can ssh into the Astaro box itself.

Am I missing the obvious here?

Many thanks,
Grant


This thread was automatically locked due to age.
Parents
  • Hello,

    You have to set "Source:" to "Any" or the specific host/network from where you want to access the SSH service.
    Alternativley, set  "Auto Packet Filter" to "yes".

    regards,
      martin
  • Thanks for the reply Martin, but can you clarify?

    "You have to set "Source:" to "Any" or the specific host/network from where you want to access the SSH service."

    Are you referring to the Source on my Packet Filter Rule, or on the DNAT rule?


    Thanks,
    Grant
  • Hello,

    Thanks for the reply Martin, but can you clarify?

    "You have to set "Source:" to "Any" or the specific host/network from where you want to access the SSH service."

    Are you referring to the Source on my Packet Filter Rule, or on the DNAT rule?


    Thanks,
    Grant


    I mean the Source in the Packet Filter rule.
    And yes, if you want to access both SSH daemons on the firewall and your server you have to change
    the port of one of them to a different port (2222 for example).

    regards,
      martin
  • Or use a different port for either your SSH DNAT, or Astaro's SSH.


    Barry,

    I changed to port 2222 for my ASG ssh access, and I can ssh into that, but still no luck being forwarded to my server.

    This is also not just an ssh thing. I set up a similar DNAT rule to access my webserver, but I have the same problem. At least in the HTTP case when it times out I get an Astaro page with the error message "Connection to server timed out"

    Is there a recommended simple test I can do just to confirm the DNAT forwarding IS working?

    Thanks. This is my last setup task (ssh & http DNAT) before I can put this into production. 

    Grant
  • As others have mentioned, the source in your packet filter rule needs to be "any", not the external network.
    Also, make sure you have not bound the internal server's definition to an interface, leave the i/f set to any.
  • As others have mentioned, the source in your packet filter rule needs to be "any", not the external network.
    Also, make sure you have not bound the internal server's definition to an interface, leave the i/f set to any.


    I have made the suggested adjustments, but still no luck. My current configuration is as follows:

    Definition

    Name: Main Server
    Type: Host
    Address: 192.168.219.10
    Interface: >

    DNAT Rule

    Traffic Source: any
    Traffic Service: SSH
    Traffic Destination: External(Address)
    NAT Mode: DNAT (Destination)
    Destination: Main Server

    Packet Filter Rule

    Source: Any
    Service: SSH
    Destination: Main Server
    Action: Allow
  • Are there and DNAT rules higher in the list which might be intercepting traffic before this rule?
    It is also possible that a bad NAT rule is causing problems for all of the NATs on the system, this would be obvious by looking at iptables from the shell.
  • Are there and DNAT rules higher in the list which might be intercepting traffic before this rule?


    No higher DNAT rules.

    One NAT Masquarading rule defined:

    Network: Internal(Network)
    Interface: External

    I do appreciate your suggestions.
  • Starting to get to long shots, but...
    Is the Cable modem doing NAT? Do you need to configure port forwarding on it?
    Maybe the ISP is blocking some inbound traffic?

    Are you an Nmap user?
    If you scan the public IP, can you see any open ports? Identify the OS?

    Finally, have support?
  • Starting to get to long shots, but...
    Is the Cable modem doing NAT? Do you need to configure port forwarding on it?
    Maybe the ISP is blocking some inbound traffic?


    Nope...modem isn't doing NAT. I also confirmed that the ISP doesn't block traffic.

    I did discover, however, that If I set my DNAT rule to any -> any -> External(Address) I can ping my internal server.  However, as an extreme test setting my DNAT rule to any -> any -> External(Address), and my PF rule to any -> any -> Internal Server, nothing is passed (except a ping works).

    I do, however have a packet filter rule higher up that is Internal(Network) -> any -> any. This wouldn't be stopping rule processing would it? 

    Grant
  • Check the PacketFilter and IPS logs.

    If nothing shows up as Dropped or Rejected, 
    Run tcpdump on external and internal interfaces, and see if the traffic is getting forwarded.

    Barry
  • Does a dump of iptables match your NAT rules in the GUI?  (iptables -nlV -t nat)

    You may have a bad NAT rule, possibly using a group definition in a field requiring a single entry or a definition inappropriately bound to an interface.
Reply
  • Does a dump of iptables match your NAT rules in the GUI?  (iptables -nlV -t nat)

    You may have a bad NAT rule, possibly using a group definition in a field requiring a single entry or a definition inappropriately bound to an interface.
Children
  • I have exactly same issue on my AGP110.  No matter what dnat i setup, it simply will not forward the service through to the appropriate server.

    Did you ever get resolve on this?
  • I would guess that there is an invalid NAT rule in the system somewhere, does the output of a "iptables -nvL" match the NAT rules set in the WebAdmin interface?
  • Hi there, was reading this hoping to find an answer but I didn't, but will throw this in for what it's worth. I have the same problem but I am reasonably sure I know what is causing it but don't know how to make it work. What if the server that you want to make available on the public IP does not have the Astaro box as it's default gateway ? ie I am testing firewalls in paralell here, so I have a web server that is already published to the internet with another firewall, and that firewall is the default gateway of the web server, the Astaro box is not the default gateway. Would not packets try to go back out the default gateway ?

    On the Endian Firewall I was testing this is a no brainer, add a packet forward rule and tick Snat, then packets come back through the firewall no matter what, I can't seem to work out how to do the same with Astaro however.

    Phill
  • Hi there, was reading this hoping to find an answer but I didn't, but will throw this in for what it's worth. I have the same problem but I am reasonably sure I know what is causing it but don't know how to make it work. What if the server that you want to make available on the public IP does not have the Astaro box as it's default gateway ? ie I am testing firewalls in paralell here, so I have a web server that is already published to the internet with another firewall, and that firewall is the default gateway of the web server, the Astaro box is not the default gateway. Would not packets try to go back out the default gateway ?Phill


    This is one use for the Full NAT function; create the rule with the external and internal IPs and services, then add the Astaro's internal address for the LAN in the bottom "Source" field.  This will DNAT inbound packets to the correct host and tag them with the Astaro's LAN gateway.
  • Thanks for that, will give it a shot, I thought that was what someone was going to say but I could not get it to work, will give it another shot later today. I wanted to be sure that was what I should be trying.

    Phill
  • hmm, I got it to work but it was not easy, my problem was that the server was not being published on the interface with the default route, if that makes sense, so packets were going back via another interface, took me a while to catch on, here is what I want to do.

    default g/w --internet 1---|           |-----internal net 1
                                        |  Astaro |-----internal net 2
                    internet 2-----|           |----internal net 3 ----- host 1

    that's something like what I have, internet 1 has the default gateway set, this is a high speed ADSL, where I want most everything to go. Internet 2 is a fully routed leased line but slow, this is where I publish my servers as I have a class c there, for testing purposes a web server on internal net 3 called host 1 that does NOT have the Astaro box as it's default gateway, but I want to make this web server available via internet 2.

    So, as per what Jack has said above I set up a full NAT rule, this sort of half worked, it worked for anything on the internet 2 network but nowhere else. After a while the penny dropped, it would work for there because Astaro would route the packets back to that network because it knew what was there as it is one of it's interfaces. Packets from anywhere else would go back out the default gateway, and this does not work. When I removed the default gateway from Internet one and enabled one on internet 2 the web server was visible from anywhere in the world, so far so good, but I could not leave it like that as I wanted Internet one as the default gateway for all traffic.

    So, I made a "Policy Route" using Route Type "Gateway Route" and said that any traffic from host 1 for anywhere use the gateway of internet 2, et voila, it all works as it should.

    Does this sound right to anyone or have I just complicated my life ? I thought the full NAT would have taken care of taking the packets back via the right path ?

    Phill
  • sorry, diagram should look like this

    default g/w --internet 1---|========|-----internal net 1
    --------------------------|= Astaro =|-----internal net 2
    internet 2-----------------|========|----internal net 3 ----- host 1
  • sorry, diagram should look like this

    default g/w --internet 1---|========|-----internal net 1
    --------------------------|= Astaro =|-----internal net 2
    internet 2-----------------|========|----internal net 3 ----- host 1


    Hi all, would be real happy to get some help here [:)] I am on the last stage of evaluating Astaro but I am having major problems trying to publish servers as per my diagram above. This is the same whether the boxes have my Astaro firewall as default gateway or not.

    As above, internet 1 is a fast ADSL, this is where I want most of my traffic to go out, this interface has the default gateway set in Astaro, my host 1 when trying to go to the internet goes out here if allowed.

    Internet 2 is a fully routed leased line, this is where all my servers are published to the internet via the firewall. 

    So say for example host 1 is a web server, and I want to make this available to the internet via Internet 2. This is how I see it, can someone tell me if this is the right way ? because while I can get it to work it breaks other things, in particular the "Policy Routes" do not seem to work as advertised.

    I make a DNAT rule

    Traffic Source: Any
    Traffic Service: HTTP
    Traffic Destination: Internet 2

    NAT mode: DNAT

    Destination: Host 1
    Destination Service:HTTP

    On it's own this does not work, from what I can see packets from the internet try to go back out the default gateway of Astaro, ie Internet 1, making this a Full NAT changes nothing unless I am doing it wrong somehow ?

    So, I figured whats needed is a Policy Route

    Route Type: Gateway route
    Source Interface:  Internal Net 3
    Source Network: Host 1

    Service: Any
    Destination Network:Any
    Gateway: The default gateway of Internet 2

    As soon as I enable this rule it works, I can access the web server from outside, so far so good. 

    2 problems, it breaks all ICMP from host 1 to the Internet, not good.
    Secondly, if I change the policy route to say service HTTP, then ICMP works again and goes out internet 1, but the web server is now not accessible from the Internet ?

    I gotta be missing something here it simply cannot be that complex ? I have 4-5 other firewalls here and have set the same thing up many many times on ISA 2000, ISA 2004, Endian, Clark Connect, and many others.

    Any help appreciated, as this is a stumbling block for me right now in my choice of Astaro to replace my current setup.

    Cheers

    Phill
  • If you just want to policy route the http traffic for host 1 out the 2nd internet connection you need to create a new service for the http reply traffic with a source port 80. You may also need to create a SNAT rule for the traffic if you haven't done so already.
  • If you just want to policy route the http traffic for host 1 out the 2nd internet connection you need to create a new service for the http reply traffic with a source port 80. You may also need to create a SNAT rule for the traffic if you haven't done so already.


    Thanks mate, that works [[:)]] Never thought about it that way, that 80 would have to be source port ! So now web traffic goes back out where it should (internet 2), and everything else goes out internet 1. Having said that it seems a lot do to just get a server published, I also split the DNAT and SNAT rules as you suggested on another post. 

    I continue testing and learning [[:)]]

    Cheers

    Phill