Community discussions

MikroTik App
 
asyvan
just joined
Topic Author
Posts: 2
Joined: Thu Jul 01, 2021 8:04 pm

NAT, masquerading, src, dst? Confused (picture)

Thu Jul 01, 2021 8:25 pm

So, my goal is to be able to have Home Assistant read Modbus from my Solar Inverter (red in the picture below).
Issue #1: The inverter only responds on Modbus requests on it's built-in Wifi (192.168.200.1) where it acts as AP (192.168.200.0/24, SSID "SUN2000-HV..."). Can't be changed.
Issue #2: My internet provider delivers a NAT solution that gives me 192.168.200.0/24 internal network. Can't be changed.
Issue #3: There is a distance between the inverter and my AP of roughly 50m.

So what do I have? See the picture for current setup including 2x MikroTik mAP Lite that I hope can be configured to solve the issues. I have included them in the picture to show how I thought they could bridge the wireless distance.
But how do I configure them (the Mikrotik mAP Lite)? Maybe I can have the mAP Lite to translate IP addresses, so when my Home Assistant requests Modbus (port 502) from a "fake" IP 192.168.20.100 the MikroTik mAP Lite translates this to 192.168.200.1 which is the inverter internal IP.
Is this even possible?
Are there any better solutions?

Image
 
asyvan
just joined
Topic Author
Posts: 2
Joined: Thu Jul 01, 2021 8:04 pm

Re: NAT, masquerading, src, dst? Confused (picture)

Thu Jul 01, 2021 11:16 pm

Would this work???

On one of the MikroTik mAP Lite I will set up a bridge, probably the one that connects to my AP 192.168.20.0/24
The other mAP Lite I will do this:
1. Assign IP 192.168.20.100 on ethernet port
2. Assign IP 192.168.200.100 on wlan port
3. Add dst-nat rule dst=192.168.20.100 to=192.168.200.1 and src-nat rule src=192.168.20.194 to=192.168.200.100
4. Add dst-nat rule dst=192.168.200.100 to=192.168.20.194 and src-nat rule src=192.168.200.1 to=192.168.20.100

My idea here is that Home Assistant (192.168.20.194) reads Modbus from 192.168.20.100 (mAP Lite). The mAP Lite changes both src and dst address as per above NAT rules. This should make sure the packet gets to the Inverter (192.168.200.1) I think.

Do I have to have some manual routing here? I think not... ????
 
jonah1810
Frequent Visitor
Frequent Visitor
Posts: 98
Joined: Tue Jul 30, 2019 10:19 pm

Re: NAT, masquerading, src, dst? Confused (picture)

Sat Jul 03, 2021 5:58 am

Could you not just create a virtual wlan on the ap to connect to the wifi instead of using the 2 mAP's?
 
User avatar
mkx
Forum Guru
Forum Guru
Posts: 11590
Joined: Thu Mar 03, 2016 10:23 pm

Re: NAT, masquerading, src, dst? Confused (picture)

Sat Jul 03, 2021 4:09 pm

You can't use single mAP. It would have to connect to two APs at the same time. Both APs will likely use different channels and client which has single radio can not deal with it.
 
msatter
Forum Guru
Forum Guru
Posts: 2912
Joined: Tue Feb 18, 2014 12:56 am
Location: Netherlands / Nīderlande

Re: NAT, masquerading, src, dst? Confused (picture)

Sat Jul 03, 2021 5:45 pm

I have a similar situation here and solved it differently. The inverter has an STA (station) and AP (access point) like yours and I disabled the STA side here. The AP side has it's own address and DHCP server. So when I connect I get a IP in the 10.10.100.150/24 range.

I put a cAP near the inverter and have it connect to the inverters AP. In the NAT of the cAP Lite I do the address translation from my local network (192.168.0.0/24) and the traffic is going to a lan cable from the cAP Lite to first switch of my local lan. The PoE injector or the PoE of the switch powers the cAP Liter through the lan cable and it needs at least 18V to have enough power reaching the cAP Liter.

Because the AP has a DHCP your other DHCP in the Unify is going to complain about there being an other DHCP server and you can block the inverter DHCP server in the bridge of the cAP Lite.

If you need the inverter to connect to the internet it could be doable having that happening trough the active connection or use the STA side of the inverter.
 
Guscht
Member Candidate
Member Candidate
Posts: 236
Joined: Thu Jul 01, 2010 5:32 pm

Re: NAT, masquerading, src, dst? Confused (picture)  [SOLVED]

Mon Jul 05, 2021 12:17 am

Home Assistant:
Request to 192.168.20.100:502 (mAP Lite)

mAP Lite does:
DNAT: 192.168.20.100:502 to 192.168.200.1:502
SNAT: 192.168.20.194 to 192.168.200.2

Assuming:
192.168.20.100 = mAP Lite in your .20 LAN
192.168.200.2 = mAP Lite in the Inverter-LAN

The Inverter will see a packet:
Source: 192.168.200.2 (mAP Lite)
Destination: 192.168.200.1 (itself)

They way back does the mAP for you (reversed DNAT/SNAT).

I have done this a few times with Canon-Camcorder, who creates their own WLAN for controlling purposes. But with a fixed IP-range and DHCP.

Who is online

Users browsing this forum: 4l4R1, erhtun, Google [Bot], jason9456402, rudivd, voytecky and 76 guests