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

UTMv9 question about port forwarding

Hi!

I'm new with using Sophos UTM v9. I have a problem with port forwarding and i hope someone here can help me.

I'm using UTM with an extra IP (1.2.3.4), that needs to port forward to our web server (5.6.7.8). But i want to keep the IP of the user that request the website. So the situation:

client (9.10.11.12) -> gateway (1.2.3.4) -> web server (5.6.7.8)

I've got that working. But in my website I'm using $_SERVER['REMOTE_ADDR']. Normally that returns the IP of the client (9.10.11.12), but now its the gateway's address(1.2.3.4).

I understand that's because I've used SNAT and DNAT rules. But i can't get it to work without.

Can someone help me with this? I've been using Google the whole morning and can't find a solution.

Kind regards,

Nick


This thread was automatically locked due to age.
  • Wellcome 
    a bit confused about "But i want to keep the IP of the user that request the website"
    anyway you can use Webserver Protection for this purpose (and in UTM you will find the logs of day requests) and not nat rules 
    if you have home license
  • Hi, your DNAT should look like:

    Source: ANY
    Dest: External Address 1.2.3.4
    Service: HTTP and/or HTTPS
    Change Destination to: WebServer 5.6.7.8

    You also need a PacketFilter rule.

    Turn off the SNAT and see if the incoming traffic works. If it works, then you can try the SNAT again. Post the SNAT if you still have trouble with it.

    Barry
  • Hi oldeda,

    Thank you for your reply! We're bought a licence for network protection, so no webserver protection. But if webserver protection can do what i want we will buy that!

    Underneed you find a simple network overview how we want to build our network. Maybe that clears some confusion.


    Both examples are working. We can view the websites and everything is working fine. But because we want to give some users more rights on specified parts of the website we need there real IP address (autologin on IP base for example). But because we are using NAT we can't do that because the IP the webservers receive is the IP of the firewall (10.0.0.1).

    Will webserver protection be able to do what i want? Or are there other ways to do it? 

    Kind regards,

    Nick

    Edit
    I'm going to test your tips BarryG. I will edit this post with the results!

    Edit2
    BarryG. That saves a lot of NAT records ^^ I've been testing, its working with only DNAT. But i still get the wrong IP. You can see it here: http://testen.test0.nl/ip.php

    You will see 10.0.0.10 (that is the current IP of internal interface of the firewall, its a test configuration). The goal is to see your IP on that page. 

    My DNAT rule:
  • Hi, 

    1. your SNATs, as configured, will not do anything useful and may be contributing to your problems. Turn them off for now, or fix them (see below).

    2. you are mixing IPs up in your examples. Earlier you implied that 1.2.3.4 is one of your external interface IPs, and your web server's internal address is 5.6.7.8, but in your last post, 5.6.7.8 seems to be an external IP.
    Therefore, I can't say for sure if your DNATs are correct as I'm confused.

    SNATs (OPTIONAL):
    Source: webserver1
    Dest: Internet
    Change source to: External Address1
    (note there's no point in using SNATs if you're going to use the same External Address for all of the servers; you might as well just use a single MASQ instead)

    Source: webserver2
    Dest: Internet
    Change source to: External Address2
    ...

    Barry
  • Hi BarryG,

    Sorry about the confusion. The drawing i've made tonight is from my official documentation. I've only changed the IP's. My openingspost is writen from my work so i've hadn't the correct drawing with me.

    SNAT is turned off. I've only have a DNAT rule now:


    As you can see here: http://testen.test0.nl/ip.php the IP the webserver receives is the internal interface of the Astaro UTM. 

    I Would like to see that the webserver receives your real home IP address. 

    I've also just tested the "generic" Proxy. But that doesn't do the job.

    Is the only solution to buy 'Webserver Protection' then? Or I'm i missing something with the NAT rules?
  • I'm using DNATs and my webservers see the public IPs of the clients.

    "development..." is defined as the internal IP of one of the servers, right?

    Do you have any other DNATs or SNATs that might be causing problems? Can you post a screenshot of your NAT page?
    Also post a screenshot of your MASQ page.

    Barry
  • Hi, Nick, and I second Olsi's welcome to the User BB!

    http://testen.test0.nl/ip.php

    Those of us here who do security seriously are hesitant to click on links we don't know.  I happened to have a sandbox open, so I tried this there with a result of 10.0.0.10 - I assume that that's the IP of "Internal (Address)" instead of 10.0.0.1 as in your diagram.

    That shouldn't happen unless you have a NAT rule on the Internal interface.  Please check 'Masquerading' to confirm that you don't have a masq rule for it, and check the 'NAT' tab to be sure you don't have a Full NAT or SNAT involved.  Did you find it?

    The generic proxy only works for clients.  This DNAT-only approach should work for you.

    If the primary reason for the UTM is to protect the web servers, you might indeed want the additional protection offered by Webserver Protection.  You will need to disable the DNATs if you try webserver protection.  Your reseller can get a 30-day demo license for you to see if this is something that would work for you.

    Cheers - Bob
  • Hi BarryG and BAlfson,

    Good morning from the Netherlands. 

    I've made some screenshots from the NAT and MASQ page. I have a MASQ rule because without it won't work. 

    @BAlfson, i understand you don't normally click on a unknown URL. But thank you for looking [;)] 10.0.0.10 is the internal interface as you said. Because its a testing envirmont it hasn't got the real IP yet.

    Is there another way to do this?



    Thank you all for the support so far!
  • The masq rule is the problem, and it should be deleted.  It seemed necessary because of another problem that continues to be a pet peeve of mine...

    Bob's Rule #3:
    Never create a Host/Network definition bound to a specific interface.
    Always leave all definitions with 'Interface: >'.



    Once you've made that change to the "development" definition, your DNAT will work.  You will want to check your other definitions.

    Cheers - Bob

  • The masq rule is the problem, and it should be deleted.  It seemed necessary because of another problem that continues to be a pet peeve of mine...

    Bob's Rule #3:
    Never create a Host/Network definition bound to a specific interface.
    Always leave all definitions with 'Interface: >'.



    Once you've made that change to the "development" definition, your DNAT will work.  You will want to check your other definitions.

    Cheers - Bob



    i've had issues NOT binding hosts to certain interfaces.  it's setup dependent..