Access wan gateway from router

I connected a modem with ip 192.168.1.1 to a router with ip 192.168.0.1
installed on both of these devices Openwrt
How can I access gui in modem with ip 192.168.1.1 when connected to router?

If the modem is connected on the WAN port of the router, and the router's WAN has an IP address on the 192.168.1.0/24 range, then you should not need to do anything; otherwise, you should tell us how are devices connected and configured.

1 Like

Maybe this one? https://openwrt.org/docs/guide-user/network/wan/access.modem.through.nat

1 Like

That's right: if you're in the upstream side of the NAT, you don't need anything to access the downstream side of the NAT.
You case is the opposite, you're in the downstream side of the NAT trying to reach the upstream side of the NAT.
In this case either you need an static route or to configure an interface (an letting OpenWrt handle the routes) as @trendy pointed out.
Static route: no need for extra interface. But your client need an IP in the network range of the gateway.
Extra interface with masquerading: a bit more involved to configure but once done it should work without any further configuration in the clients.

1 Like

my wan ip is 192.168.1.166 that modem get this ip to wan interface of router

I didn't get it right
In which part do I need to make changes to access the modem correctly?

Better explain the situation with a diagram, where you can show the devices, the interfaces, the links, and the IPs.

2 Likes

this is my network config in router

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

config globals 'globals'
	option ula_prefix 'fdd3:0ad2:041b::/48'

config interface 'lan'
	option type 'bridge'
	option proto 'static'
	option netmask '255.255.255.0'
	option ip6assign '60'
	option ipaddr '192.168.0.1'
	option ifname 'eth0.1 tap-server tap0'

config device 'lan_dev'
	option name 'eth0.1'
	option macaddr '40:d6:3c:2c:03:56'

config interface 'wan'
	option ifname 'eth0.2'
	option proto 'dhcp'
	option metric '1'

config device 'wan_dev'
	option name 'eth0.2'
	option macaddr '40:d6:3c:2c:03:57'

config interface 'wan6'
	option ifname 'eth0.2'
	option proto 'dhcpv6'

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

config switch_vlan
	option device 'switch0'
	option vlan '1'
	option ports '1 2 3 4 6t'

config switch_vlan
	option device 'switch0'
	option vlan '2'
	option ports '0 6t'

this is my firewall config in router


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

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

config zone
	option name 'wan'
	option input 'REJECT'
	option output 'ACCEPT'
	option forward 'REJECT'
	option masq '1'
	option mtu_fix '1'
	option network 'wan wan6 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 src_ip 'fc00::/6'
	option dest_ip 'fc00::/6'
	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 include
	option path '/etc/firewall.user'

This should work as is... What happens when you ping / traceroute from the router to the modem? And from a computer connected to the router?

2 Likes

I can get Ping 192.168.1.1 from the router but not from the computer

Do I set up a modem? For example on the lan interface ?

You CAN ping from the computer, by the results are not what you expected... :wink:

Could you do a traceroute, and post the results here, please?

1 Like

Your setup looks perfect to me, now let's try to find out why it doesn't work.

1 Like

only is it possible to ping through the router
What exactly do I do?
Problems with openwrt firewall settings on modem?

I would suspect the PC more. You are trying to use it to access a private IP that is not the LAN, and some strict PC firewall setups may consider that something not normal-- a security threat.

In a default configuration(*) everything that is not in the LAN subnet (192.168.0.X) by default routed to the Internet and will be sent out the WAN port. Thus OpenWrt doesn't know if 192.168.1.1 is your modem or something else far away but it does know that the route to it is through the WAN port.

(*) What is tap0 and tap_server?

1 Like