I am new to openwrt. Needing assistance on create a NAT Rules so that when I visit sites like ipchicken it will show the ip address of an loopback interface that I have created. I have configured the loopback interface as a br-lan interface. Please advise.
Please connect to your OpenWrt device using ssh and copy the output of the following commands and post it here using the "Preformatted text </>
" button:
Remember to redact passwords, MAC addresses and any public IP addresses you may have:
ubus call system board
cat /etc/config/network
cat /etc/config/wireless
cat /etc/config/dhcp
cat /etc/config/firewall
Broadly speaking, if the site uses the IP address from which the request originates, that will be, by definition, the actual or apparent[1] wan IP of the system. It has to be since the only way to reach the site would be via the internet, thus requiring the use of a publicly routable IP. With that in mind, I'm not sure that you can 'fool' one of these sites to use a local loopback (unless the site itself runs a local script on your computer).
in the case of CG-NAT or a VPN, the apparent IP that the system uses to route to the internet will be different than the actual wan IP on the device âŠī¸
I am trying to mirror the config on my spectrum router. My spectrum router has a br-lan interface that is configured with my static public IP address.
So your OpenWrt router is downstream of the Spectrum router? My guess is that you're always going to see the results of the public IP on the wan side of the Spectrum device, unless the script runs truly locally on your computer.
I plan on swapping the spectrum router with the openwrt router. I have included the current route table.
If you intend to make the OpenWrt router the main one, then it will have a public IPv4 address on the wan interface. That address will be NAT'd such that all devices on your internal network will have the same effective public IP.
When you run an IP check from a site on the internet, it will then report the IP that is held on the wan of your OpenWrt router. As stated earlier, there isn't anything you can do to mask that (except for the use of a VPN which simply shifts that public IP to another provider).
Here is the config that you have requested.
root@OpenWrt:~# ubus call system board
{
"kernel": "6.6.93",
"hostname": "OpenWrt",
"system": "ARMv8 Processor rev 4",
"model": "Linksys E8450 (UBI)",
"board_name": "linksys,e8450-ubi",
"rootfs_type": "squashfs",
"release": {
"distribution": "OpenWrt",
"version": "24.10.2",
"revision": "r28739-d9340319c6",
"target": "mediatek/mt7622",
"description": "OpenWrt 24.10.2 r28739-d9340319c6",
"builddate": "1750711236"
}
}
root@OpenWrt:~# cat /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 'fd52:5a0b:f457::/48'
option packet_steering '1'
config device
option name 'br-lan'
option type 'bridge'
list ports 'lan1'
list ports 'lan2'
list ports 'lan3'
list ports 'lan4'
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 interface 'wan'
option device 'wan'
option proto 'dhcp'
config interface 'wan6'
option device 'wan'
option proto 'dhcpv6'
config interface 'loopback2'
option proto 'static'
option device 'br-lan'
option ipaddr 'x.x.X.X'
option netmask '255.255.255.252'
root@OpenWrt:~# cat /etc/config/wireless
config wifi-device 'radio0'
option type 'mac80211'
option phy 'wl0'
option cell_density '0'
config wifi-iface 'default_radio0'
option device 'radio0'
option network 'lan'
option mode 'ap'
option ssid 'judyhome-2.4ghz'
option encryption 'sae-mixed'
option key 'X'
option ocv '0'
config wifi-device 'radio1'
option type 'mac80211'
option phy 'wl1'
option cell_density '0'
option htmode 'HE20'
option band '5g'
option channel 'auto'
config wifi-iface 'default_radio1'
option device 'radio1'
option network 'lan'
option mode 'ap'
option ssid 'judyhome'
option encryption 'sae-mixed'
option key 'X'
option ocv '0'
root@OpenWrt:~# cat /etc/config/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'
option start '100'
option limit '150'
option leasetime '12h'
config odhcpd 'odhcpd'
option maindhcp '0'
option leasefile '/tmp/hosts/odhcpd'
option leasetrigger '/usr/sbin/odhcpd-update'
option loglevel '4'
root@OpenWrt:~# cat /etc/config/firewall
config defaults
option syn_flood 1
option input REJECT
option output ACCEPT
option forward REJECT
# Uncomment this line to disable ipv6 rules
# option disable_ipv6 1
config zone
option name lan
list network 'lan'
option input ACCEPT
option output ACCEPT
option forward ACCEPT
config zone
option name wan
list network 'wan'
list network 'wan6'
option input REJECT
option output ACCEPT
option forward REJECT
option masq 1
option mtu_fix 1
config forwarding
option src lan
option dest wan
# We need to accept udp packets on port 68,
# see https://dev.openwrt.org/ticket/4108
config rule
option name Allow-DHCP-Renew
option src wan
option proto udp
option dest_port 68
option target ACCEPT
option family ipv4
# Allow IPv4 ping
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
# Allow DHCPv6 replies
# see https://github.com/openwrt/openwrt/issues/5066
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
# Allow essential incoming IPv6 ICMP traffic
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
# Allow essential forwarded IPv6 ICMP traffic
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
### EXAMPLE CONFIG SECTIONS
# do not allow a specific ip to access wan
#config rule
# option src lan
# option src_ip 192.168.45.2
# option dest wan
# option proto tcp
# option target REJECT
# block a specific mac on wan
#config rule
# option dest wan
# option src_mac 00:11:22:33:44:66
# option target REJECT
# block incoming ICMP traffic on a zone
#config rule
# option src lan
# option proto ICMP
# option target DROP
# port redirect port coming in on wan to lan
#config redirect
# option src wan
# option src_dport 80
# option dest lan
# option dest_ip 192.168.16.235
# option dest_port 80
# option proto tcp
# port redirect of remapped ssh port (22001) on wan
#config redirect
# option src wan
# option src_dport 22001
# option dest lan
# option dest_port 22
# option proto tcp
### FULL CONFIG SECTIONS
#config rule
# option src lan
# option src_ip 192.168.45.2
# option src_mac 00:11:22:33:44:55
# option src_port 80
# option dest wan
# option dest_ip 194.25.2.129
# option dest_port 120
# option proto tcp
# option target REJECT
#config redirect
# option src lan
# option src_ip 192.168.45.2
# option src_mac 00:11:22:33:44:55
# option src_port 1024
# option src_dport 80
# option dest_ip 194.25.2.129
# option dest_port 120
# option proto tcp
root@OpenWrt:~#```
What is this address? You've redacted it, so it's not clear what kind of address it is (public, RFC1918, true loopback).
It also won't work because you're attaching 2 interfaces to the same bridge. This is not a valid approach.
The current spectrum router has the WAN interface assigned dynamically. The static interface is configured as a br_lan interface that is NATed out to the network. I have included the screen shots from IP Chicken showing the BR_LAN interface as the public IP.
the redacted Ip address is 76.53.137.41
You may be misunderstanding things...
Yes, and that is the public IP address that is assigned to the wan side of the router. You'll get the same thing (although the actual IP may change, but it'll still be a spectrum IP like that) if you put the OpenWrt router in place of the current router.
br-lan
is a device, not an interface. The lan
network interface is the thing that holds an address. (at least as it is defined in OpenWrt).
The NAT is actually happening on the wan via the wan
firewall zone (masquerading is enabled).
As described above, this is the wan address, not the lan.
Are you trying to have ipchicken report a different IP??
I want to mirror the config from the spectrum to the Openwrt. So when I swapped out the router. When I go to a website such as IP chicken I want to show the same results.
You don't necessarily have control of that since the address is dynamically assigned by Spectrum. It could change at any time (more accurately, anytime the DHCP lease is renewed).
Typically, the IP address that is assigned is related in some way to the MAC address. So if you change out your main router for the OpenWrt router, it is likely the IP will change since the two devices have different MACs.
The solution is to clone the MAC address that is used on the wan side of your Spectrum router into the wan device on your OpenWrt router. This will make the new router appear to be the same physical device as the current one (even though it isn't) from the perspective of the ISP. The IP is not guaranteed, though, unless you specifically have a static IP as part of your service plan.
Remove the loopback2
address, clone your spectrum MAC into your OpenWrt wan, and then swap the devices.
I pay for a static IP address from Spectrum using their equipment. The WAN interface is assigned dynamic. I have connected my laptop to my spectrum modem with is separate from the router and was able to get an assigned IP address dynamically. By default that static ip address is not assigned to the WAN interface but is assigned to the BR_LAN interface.
Youll need to check with spectrum. Likely use wan MAC from whatever it originally was connected there.
Thank you for your assistance. I thought it would be possibility to overload a loopback interface.
Ok. That's good... so you can guarantee the IP (generally speaking).
A common method of ISP issued static IP's is to have the CPE setup with DHCP, and the ISP simply sets up a DHCP reservation for the static IP. This makes the user's setup much easier, and the experience is indistinguishable from a manually assigned static IP.
I don't think that's the case, but maybe the Spectrum router works differently and/or presents this information to the user even if it's not what's happening under the hood.
Anyway, my expectation is that it should 'just work' if you clone the MAC address as I suggested earlier. Please try that.
If it doesn't work, it will be a question for Spectrum -- it's always possible that they have some more complicated setup where they use a transport IP on the wan itself and then a second public IP to provide the static IP service.
That is how the spectrum router is configured. I did call spectrum and try to get them to share how they configure the router, but they would not provide me with the information on how they did the NAT with the br_lan interface. Thank you for your assistance.
Did you try what I recommended: