Dear Community User! We have started the migration process.
This community is now in READ ONLY mode.
Read more: Important information on the platform change.

cancel
Showing results for 
Search instead for 
Did you mean: 
SOLVED

Confused with the firewall application for NAT port forwarding

Confused with the firewall application for NAT port forwarding

Marc_Smaak
Long-established Member

My usecase is pretty simple. I have an internal network onnected to XF-51 and an external network connected to XF-10

The internal is subnet 192.168.2.0/24 This network has devices with a web interface

The external subnet 192.168.100.0/24

I try to configure the firewall to port forward tcp (http) traffic from the external to the internal network. For instance incomming to the IP of XF-10 on port 8443 needs to be forwarded to 192.168.2.2 port 443

The confusion already starts from port naming shoudl it be XF-10, ETH0 or XF10. I think the latter is correct beacuse this is the name Linux reports. 

I understand have to enable packet forwarding for both XF-10 & XF-51 which I did.

According the this diagram I need to configurer Dnat, forwarding and SNAT rules

Marc_Smaak_0-1711110540620.png

Which seems to be a lot since I only have a few coonfiguration parameters to play with:

  1. Incomming interface XF10(??)
  2. Incomming protocol TCP
  3. Incomming port: 8443
  4. Destination interface XF51
  5. Destination IP: 192.68.2.2
  6. Destination port: 443

Al that information can go into the destination NAT

Marc_Smaak_1-1711110992478.png

Is this correct? And if yes what should I put in the forwarding dan SNAT entries?

An example which uses OS 1.20 (new port names) is appriciated 

 

10 REPLIES 10

Sgilk
Frequent Contributor

Hi @Marc_Smaak ,

If I understand your architecture correctly, you should only need to set SNAT rules and make a routing rule on the XF10 subnet devices.

You shouldn't need to match meta data oifname. It's redundant since you have seperate subnets on the interfaces.

Take a look at some of the How-Tos on this topic, specifically:

"How to use ctrlX CORE as a “router” using the Firewall App"

Marc_Smaak
Long-established Member

@Sgilk Thank you for your reply. I have seen the post you mentioned but thought this is not exactly what I want since it is using the firwall as router while I want to use it as a NAT firewall. The diffrence is that for the client accesing the Webpage of a device behind the ctrlX it should simply think it comunicates to the ctrlx core IP address
Therefore this step should not be needed since this will not work in our usecase many diffrent PC will need to use this connection

Marc_Smaak_0-1711122591236.png

 

Marc_Smaak
Long-established Member

I tested a bit more. Only if I configure a Destination NAT rule the ctrlX open a port. NMAP scan proves this, the browser response change from "connection refused' took 'took long to respond' So the massage is not corrcetly forwarded to the other network or the answer is not coming back.
Using Destination NAT makes sense since the desciption say port forwarding which is what I need.

I cannot help thinking this is far too complicated, iI need get this to work by Monday else I must advise my customer to use someting else e.g. a router running openwrt (3 minute task, just did it) Any tips??

Sgilk
Frequent Contributor

Hi @Marc_Smaak ,

I believe at this point, you also need a SNAT rule to direct the response message. 

As an example, if I had a device on the internal subnet at 192.168.2.100 and the internal subnet adapter IP is 192.168.2.1, I would use the following rules.

Sgilk_0-1711139849554.png

 

Marc_Smaak
Long-established Member

@Sgilk Thank you this indeed works.
So for testing this is my setup

Marc_Smaak_0-1711285568858.png

 

 

And these are my firewall rules:

Destination NAT

Marc_Smaak_1-1711284338889.png

 

Which I beleive can even be simplified to

Marc_Smaak_2-1711284424275.png

But I suspect this only works beacuse the traffic is https so defaults to port 443. If it would be another port I need to add the port info somewhere

Source NAT

Marc_Smaak_4-1711284601079.png
Also after a reboot (saving the firwall first) this all still works
Thanks at lot!!!

If you can explain better wat the Source net rule does this would be ewelcomed. I already worked with it but I thought it was intended for the return path to replace the source address of the device on my internal network (172.20.0.2) into the IP of the CtrlX core on the external network (192.168.2.137) This did not work.

 

Marc_Smaak
Long-established Member

On 2nd tought I think I get it. The Source IP address of my message towards the internal IP (172.20.0.2) would noramlly be the IP address of my laptop (192.168.2.138) With this rule it gets replaced with the IP of the ctrlX core on the internal network (172.20.0.1 ) Therfore the internal device just replies to 172.20.0.1 and does not need a Default gateway. Is this indeed the correct assumption?

Sgilk
Frequent Contributor

Exactly. I believe if you set the default gateway on the internal network devices to the ctrlX CORE internal network adapter IP, you should not need the SNAT rule.

Marc_Smaak
Long-established Member

@Sgilk wrote:
Exactly. If you set the default gateway on the internal network devices to the ctrlX CORE internal network adapter IP, you would not need the SNAT rule.

Strange, that is what I did as sown in the picture but it did not work. Will trey again later I am not at my system right now. 

Marc_Smaak
Long-established Member

Tested again with only a DNAT rule and correct default gateway config and can confirm it is working. (I had a type in my default gateway)
So this is the only rule needed to make the conif of my picture working

Marc_Smaak_0-1711529712474.png

This is how I started initially  😖

Just some clear examples for diffrent usecases would for sure help.

aFouraker
Occasional Contributor

I thought I would also share my use case here and what worked for me for anyone trying to do something similiar.

I have a local network with multiple XM control. I am using the ctrlX as a NAT. I want to assign one IP address that is publicly available to a local address. In this case, when I login at 192.168.3.6 I should login to 192.168.1.2 and if I login at 192.168.3.7 then I should login to 192.168.1.5.

 

aFouraker_0-1715966058232.png

 

I am using the firewall app with rules set for DNAT and SNAT. Here I have no ports configured so that the address should act just as if the device was on the same network. 

Here is the DNAT configuration:

aFouraker_2-1715964896194.png

and here is the SNAT configuration:

aFouraker_3-1715964960513.png

XM at 192.168.3.6:

aFouraker_4-1715965118904.png

XM at 192.168.3.7:

aFouraker_5-1715965235593.png

Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist