Connect two IP classes

I just registered, greetings to everyone
Can anyone help me solve this problem?
My main network has this class 192.168.10.xx, homeassistant is present in the network
which works perfectly, I would have to connect the inerter of the photovoltaic system to get data.
To get data from the inverter I have to connect port 6670 to its accesspoint with class 192.168.200.xx.
How can I connect my 192.168.10.xx network to an inverter with class 192.168.200.xx
you can do it with openwrt or you need another external router
Right now I'm using version 23.05 on NETGEAR R6620 router
Thank you

Can't you configure your inverter to connect to your existing network? Often, they provide their own AP for configuration purposes and you can then, using the manufacturer's app, configure it to connect to an existing network.

2 Likes

IP ranges with different prefix bits are called "subnets", not "classes."

If the inverter only operates as an AP you can set up OpenWrt to be a client of it and hold a 192.168.200.0/24 IP. OpenWrt will also route packets to the inverter (presumably 192.168.200.1) from its other subnets, such as your main lan of 192.168.10.0/24.

First though you should see if it can operate as a client as @andyboeh said, as this is more conventional.

Yes, that's exactly what I wanted to do, you wrote to check if it can work as a client, are you referring to my netgear router? I think so, I saw that in the wifi configuration there is the possibility of configuring a network as a client. Could you explain to me how to do it? What does @andyboeh mean?
Thank you

Check the manual of your inverter or tell us which inverter you are talking about - I'm relatively sure it can be connected to a network as a client.

The inverter is "Huawei Sun 2000", I don't have an APP to connect to the inverter, the accesspoint
the technicians use it to provide assistance, my app connects to the huawei server which
receives data from my network 192.168.10.6, but it is impossible to connect to this address, the only way
and connecting to your accesspoint.

I'm not sure how this works on the Huawei. According to the manual, it has internal WiFi but it's not clear to me whether it can be used to join a network.

There is, however, a dongle that features WiFi and Ethernet which is supposed to connect to the Huawei cloud.

The dongle you mention is already installed, it is used to connect the inverter to my 192.168.10.xx network
but it is impossible to access this address, the Huawei server uses it to access the inverter when using the APP.
Then inside the inverter there is an access point 192.168.200.1 which is used by the technician in case of maintenance. Homeassistant integration (huawei) says that to receive data from the inverter you need to connect to this accesspoint via port 6670.

Ah, now I understand your problem!
There seem to be a few integrations, some using Modbus TCP to connect to the dongle.

Do you use your OpenWrt device as an access point? If yes, you will run into trouble when connecting to the inverter at the same time because the channel for your own AP needs to match the channel of the inverter's AP. While this can be solved by using the travelmate package, I strongly suggest to look into other HA integrations that avoid having to connect to the inverter's AP.

This is the wiki of the homeassistant huawei integration, it says to use a tplink 802n configured as a client.
I have this router available and I tried to configure it as a client but I didn't understand how to connect via LAN to my network, seeing as tplink has the address 12.168.200.xx and my network has 192.168.10.xx, how to route the packets from my network to another.

Thanks, I got you now and I also read parts of the Wiki page you mentioned. I'm sorry that I have a few more questions on your setup:

  • Is your main router also running OpenWrt? If yes, which version?
  • You mentioned you had a TL-WR802N - this one is also running the latest version of OpenWrt, right?

You have several options to achieve your goal, the easiest not requiring any configuration on your main router is probably:

  1. Configure the TP-Link's LAN address to a static address within your main subnet - e.g. 192.168.10.10
  2. Connect the TP-Link to the Inveter as described on the wiki page you mentioned
  3. Configure Masquerading and Port-Forwarding on the TP-Link
  4. Use the TP-Link's address of 192.168.10.10 with port 6607 in Home Assistant to connect to the inverter. The TP-Link will do all the translation magic.

My main router is a modified netgear R6220 with openwrt 23.05
Tp-link tl-wr802n has original firmware because openwrt site says not to modify because little memory

Which WR802N do you have? If it is something like the v4 with 8/64 memory, it will be usable for this project. 8 and 64 is now the bare minimum to do anything with OpenWrt. If flash is less than 8 and/or RAM less than 64, it is not suitable.

Ok I also updated the WR802N v4 with openwrt version 23.05

But are you referring to the tplink with original firmware or with wrt firmware?
I updated the tplink with openwrt 23.05 firmware but I can't get it to work
I configured the LAN with static IP 192.168.10.123 and the WiFi as a client that connects to the inverter
but nothing I can't connect, 192.168.10.123 takes me to the tplink configuration page
and via homeassistant 192.168.10.123:6607, replies "unable to connect"

OpenWrt. Let's see the WR's config files:

Connect via SSH and post redacted versions of /etc/config/wireless, /etc/config/network and /etc/config/firewall.

Also, both routers need to be connected LAN-LAN, the WAN port is unused on the WR.

this is DHCP

config dnsmasq
        option domainneeded '1'
        option boguspriv '1'
        option filterwin2k '0'
        option localise_queries '1'
        option rebind_protection '1'
        option rebind_localhost '1'
        option local '/lan/'
        option domain 'lan'
        option expandhosts '1'
        option nonegcache '0'
        option cachesize '1000'
        option authoritative '1'
        option readethers '1'
        option leasefile '/tmp/dhcp.leases'
        option resolvfile '/tmp/resolv.conf.d/resolv.conf.auto'
        option nonwildcard '1'
        option localservice '1'
        option ednspacket_max '1232'
        option filter_aaaa '0'
        option filter_a '0'

config dhcp 'lan'
        option interface 'lan'
        option start '100'
        option limit '150'
        option leasetime '12h'
        option dhcpv4 'server'
        option dhcpv6 'server'
        option ra 'server'
        option ra_slaac '1'
        list ra_flags 'managed-config'
        list ra_flags 'other-config'

config dhcp 'wan'
        option interface 'wan'
        option ignore '1'

config odhcpd 'odhcpd'
        option maindhcp '0'
        option leasefile '/tmp/hosts/odhcpd'
        option leasetrigger '/usr/sbin/odhcpd-update'
        option loglevel '4'

this is FIREWALL

config defaults
        option syn_flood '1'
        option input 'REJECT'
        option output 'ACCEPT'
        option forward 'REJECT'

config zone
        option name 'lan'
        option input 'ACCEPT'
        option output 'ACCEPT'
        option forward 'ACCEPT'
        list network 'lan'

config zone
        option name 'wan'
        option input 'REJECT'
        option output 'ACCEPT'
        option forward 'REJECT'
        option masq '1'
        option mtu_fix '1'
        list network 'wan'
        list network 'wan6'
        list network 'wwan'

config forwarding
        option src 'lan'
        option dest 'wan'

config rule
        option name 'Allow-DHCP-Renew'
        option src 'wan'
        option proto 'udp'
        option dest_port '68'
        option target 'ACCEPT'
        option family 'ipv4'

config rule
        option name 'Allow-Ping'
        option src 'wan'
        option proto 'icmp'
        option icmp_type 'echo-request'
        option family 'ipv4'
        option target 'ACCEPT'

config rule
        option name 'Allow-IGMP'
        option src 'wan'
        option proto 'igmp'
        option family 'ipv4'
        option target 'ACCEPT'

config rule
        option name 'Allow-DHCPv6'
        option src 'wan'
        option proto 'udp'
        option dest_port '546'
        option family 'ipv6'
        option target 'ACCEPT'

config rule
        option name 'Allow-MLD'
        option src 'wan'
        option proto 'icmp'
        option src_ip 'fe80::/10'
        list icmp_type '130/0'
        list icmp_type '131/0'
        list icmp_type '132/0'
        list icmp_type '143/0'
        option family 'ipv6'
        option target 'ACCEPT'

config rule
        option name 'Allow-ICMPv6-Input'
        option src 'wan'
        option proto 'icmp'
        list icmp_type 'echo-request'
        list icmp_type 'echo-reply'
        list icmp_type 'destination-unreachable'
        list icmp_type 'packet-too-big'
        list icmp_type 'time-exceeded'
        list icmp_type 'bad-header'
        list icmp_type 'unknown-header-type'
        list icmp_type 'router-solicitation'
        list icmp_type 'neighbour-solicitation'
        list icmp_type 'router-advertisement'
        list icmp_type 'neighbour-advertisement'
        option limit '1000/sec'
        option family 'ipv6'
        option target 'ACCEPT'

config rule
        option name 'Allow-ICMPv6-Forward'
        option src 'wan'
        option dest '*'
        option proto 'icmp'
        list icmp_type 'echo-request'
        list icmp_type 'echo-reply'
        list icmp_type 'destination-unreachable'
        list icmp_type 'packet-too-big'
        list icmp_type 'time-exceeded'
        list icmp_type 'bad-header'
        list icmp_type 'unknown-header-type'
        option limit '1000/sec'
        option family 'ipv6'
        option target 'ACCEPT'

config rule
        option name 'Allow-IPSec-ESP'
        option src 'wan'
        option dest 'lan'
        option proto 'esp'
        option target 'ACCEPT'

config rule
        option name 'Allow-ISAKMP'
        option src 'wan'
        option dest 'lan'
        option dest_port '500'
        option proto 'udp'
        option target 'ACCEPT'

this is NETWORK

config interface 'loopback'
        option device 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'fda2:b04a:284e::/48'

config device
        option name 'br-lan'
        option type 'bridge'
        list ports 'eth0'

config interface 'lan'
        option device 'br-lan'
        option proto 'static'
        option ipaddr '192.168.1.1'
        option netmask '255.255.255.0'
        option ip6assign '60'

config switch
        option name 'switch0'
        option reset '1'
        option enable_vlan '0'

config interface 'wwan'
        option proto 'dhcp'

this is WIRELESS

config wifi-device 'radio0'
        option type 'mac80211'
        option path 'platform/10300000.wmac'
        option channel '1'
        option band '2g'
        option htmode 'HT20'
        option cell_density '0'

config wifi-iface 'default_radio0'
        option device 'radio0'
        option network 'lan'
        option mode 'ap'
        option ssid 'OpenWrt'
        option encryption 'none'
        option disabled '1'

config wifi-iface 'wifinet1'
        option device 'radio0'
        option mode 'sta'
        option network 'wwan'
        option ssid 'SUN2000-102170094965'
        option encryption 'psk2'
        option key 'Changeme'

So it is configured to connect to the inverter and I left the default IP 192.168.1.1

OK, let's change it to the way the example is built. Please try the following (NB: Untested on my end) - whole files shown, please make sure to not miss any changes to existing sections!

/etc/config/wireless untouched.
/etc/config/dhcp untouched.
/etc/config/network:

config interface 'loopback'
        option device 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'fda2:b04a:284e::/48'

config device
        option name 'br-lan'
        option type 'bridge'
        list ports 'eth0'

config interface 'lan'
        option device 'br-lan'
        option proto 'static'
        option ipaddr '192.168.10.123'
        option netmask '255.255.255.0'
        option ip6assign '60'

config switch
        option name 'switch0'
        option reset '1'
        option enable_vlan '0'

config interface 'wwan'
        option proto 'dhcp'
        option defaultroute '0'

/etc/config/firewall:

config defaults
        option syn_flood '1'
        option input 'REJECT'
        option output 'ACCEPT'
        option forward 'REJECT'

config zone
        option name 'lan'
        option input 'ACCEPT'
        option output 'ACCEPT'
        option forward 'ACCEPT'
        list network 'lan'

config zone
        option name 'wan'
        option input 'REJECT'
        option output 'ACCEPT'
        option forward 'REJECT'
        option masq '1'
        option mtu_fix '1'
        list network 'wan'
        list network 'wan6'

config forwarding
        option src 'lan'
        option dest 'wan'

config rule
        option name 'Allow-DHCP-Renew'
        option src 'wan'
        option proto 'udp'
        option dest_port '68'
        option target 'ACCEPT'
        option family 'ipv4'

config rule
        option name 'Allow-Ping'
        option src 'wan'
        option proto 'icmp'
        option icmp_type 'echo-request'
        option family 'ipv4'
        option target 'ACCEPT'

config rule
        option name 'Allow-IGMP'
        option src 'wan'
        option proto 'igmp'
        option family 'ipv4'
        option target 'ACCEPT'

config rule
        option name 'Allow-DHCPv6'
        option src 'wan'
        option proto 'udp'
        option dest_port '546'
        option family 'ipv6'
        option target 'ACCEPT'

config rule
        option name 'Allow-MLD'
        option src 'wan'
        option proto 'icmp'
        option src_ip 'fe80::/10'
        list icmp_type '130/0'
        list icmp_type '131/0'
        list icmp_type '132/0'
        list icmp_type '143/0'
        option family 'ipv6'
        option target 'ACCEPT'

config rule
        option name 'Allow-ICMPv6-Input'
        option src 'wan'
        option proto 'icmp'
        list icmp_type 'echo-request'
        list icmp_type 'echo-reply'
        list icmp_type 'destination-unreachable'
        list icmp_type 'packet-too-big'
        list icmp_type 'time-exceeded'
        list icmp_type 'bad-header'
        list icmp_type 'unknown-header-type'
        list icmp_type 'router-solicitation'
        list icmp_type 'neighbour-solicitation'
        list icmp_type 'router-advertisement'
        list icmp_type 'neighbour-advertisement'
        option limit '1000/sec'
        option family 'ipv6'
        option target 'ACCEPT'

config rule
        option name 'Allow-ICMPv6-Forward'
        option src 'wan'
        option dest '*'
        option proto 'icmp'
        list icmp_type 'echo-request'
        list icmp_type 'echo-reply'
        list icmp_type 'destination-unreachable'
        list icmp_type 'packet-too-big'
        list icmp_type 'time-exceeded'
        list icmp_type 'bad-header'
        list icmp_type 'unknown-header-type'
        option limit '1000/sec'
        option family 'ipv6'
        option target 'ACCEPT'

config rule
        option name 'Allow-IPSec-ESP'
        option src 'wan'
        option dest 'lan'
        option proto 'esp'
        option target 'ACCEPT'

config rule
        option name 'Allow-ISAKMP'
        option src 'wan'
        option dest 'lan'
        option dest_port '500'
        option proto 'udp'
        option target 'ACCEPT'

config zone
        option input 'ACCEPT'
        option name 'wwan'
        option output 'ACCEPT'
        option forward 'ACCEPT'
        option masq '1'
        option network 'wwan'

config redirect
        option name 'SUN2000'
        option target 'DNAT'
        option src 'lan'
        option src_dport '6607'
        option dest 'wwan'
        option dest_ip '192.168.200.1'
        option dest_port '6607'
        list proto 'tcp'

With these changes in effect, you should be able to connect to 192.168.10.123:6607 and reach your inverter.

It works perfectly, thank you so much, I was finally able to connect to the photovoltaic system.
Thanks again for the help.

1 Like

If your problem is solved, please consider marking this topic as [Solved]. See How to mark a topic as [Solved] for a short how-to.
Thanks! :slight_smile: