Have hostname point to WAN2 gateway address


Hello,
I am hoping to find out if it is possible to set a hostname in OpenWRT to automatically point to the gateway IP address of my WAN2 modem which is a Netgear LB2120 in bridge mode. It is in the same subnet as the address given by my LTE connection to the modem. By default, a machine connected directly to the LB2120 can access the administrator page by visiting 192.168.5.1.

My APU4D4 does not have Wifi. It is set up with a LAN (for all devices connected directly by Ethernet) and LAN2 (exclusively for a Ubiquiti UniFi U6 LR also running OpenWRT) to segregate my Wifi devices from my Ethernet devices. Prior adding a IPv6 in IPv4 connection via Hurricane Electric, devices on both LAN and LAN2 could access the LB2120 on its default IP address with a rule I set in mwan3, and later by following this guide instead.

Since adding the IPv6 in IPv4 connection, only devices on Wifi, and hence via LAN2 can access the LB2120 at 192.168.5.1.

Devices connected via Ethernet to the LAN fail to reach 192.168.5.1. I found another guide online that stated it was possible to access the LB2120 admin page by instead visiting the gateway address of that modem (public IP = xxx.xxx.xxx.134, gateway = xxx.xxx.xxx.1). To my surprise, that works from both the LAN and LAN2. Because the IP address given to the LB2120 by my LTE connection is dynamic, and not static, having a hostname always automatically point to the WAN2 gateway address would simplify browser bookmark access to the LB2120 admin page.

Looking forward to any advice. Thanks all.

Yes, just add a hostname/A record entry for the device/IP.

See:

1 Like

Thanks for your reply. Unfortunately this doesn't work from LAN1, in that I cannot ping 192.168.5.1 from anything connected via Ethernet LAN1, only from LAN2, since adding the 6in4 connection. For some reason I can still reach the LB2120 via the WAN2 gateway address from LAN1. I have found a command that does output the WAN2 gateway address, so if there's a way to automatically map a hostname or A record to that address, which changes automatically every couple of months or so, that would solve this problem, I think.

For the wan2 interface, why don't you do static ip with the ip set to 192.168.5.2 instead?

Leave the gateway address field blank, uncheck the Use default gateway box (advanced tab), and make sure that the wan2 interface is in the wan firewall zone (for masquerading nat). This will configure a private subnet for accessing the modem exclusively, and then you can create a hostname for your modem that permanently points to 192.168.5.1.

1 Like

I’ll give this a go upon return home. At the moment I already have a static interface IP 192.168.5.2 alias of @wan2 but I can’t reach it from LAN1, only LAN2, since setting up 6in4 for some strange reason.

Hi all, just sharing that I found a convenient workaround to this problem using the Shortcuts app that works on both my Mac mini M1 at home, and remotely via VPN on my MacBook Pro and iPhone, as follows:


I seem to have properly resolved this issue by adjusting a seemingly unrelated setting. I had manually set the MTU for eth0, which the LB2120 is connected to as WAN2, to 1430, as indicated in that modem's manual. By changing the MTU, it seems to have re-ordered the items on the OpenWRT Devices screen. The LB2120 can now be accessed from LAN1 via 192.168.5.1, as was the case prior to setting up 6in4 via Hurricane Electric.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.