Firewall traffic rules not working after upgrading to 24.10.0

As the title says, after upgrading to 24.10.0 my firewall traffic rules stopped working.

For example, I have this rule to block cloud gaming:

config rule
	list proto 'udp'
	option src 'wan'
	option dest 'lan'
	option target 'REJECT'
	option dest_port '49003-49006'
	option name 'Block-GFN-XXXX'
	option enabled '1'
	list dest_ip '192.168.X.XXX'
	option family 'ipv4'

It worked fine on 23.05.5.
I even downgraded back to verify this and yes it works again after downgrading.

I also have this reorder script to handle established connections but I think it's not relevant to the issue as the traffic rule now ignores even new connections with 24.10.0.

I haven't seen any changes related to the firewall in the release notes, so the configuration from 23.05.5 should be working properly with no changes.

I haven't verified the other traffic rules, but if none of them are working, it's a serious security issue. So, in the meantime, I'm downgrading back to 23.05.5.

Device: Xiaomi Mi Router 4A Gigabit Edition
Platform: ramips/mt7621

This rule should be unnecessary in most configurations since unsolicited wan connections are not allowed. So with or without this rule, I'd expect that this traffic would not have an ingress path.

Let's see the full firewall config file to better understand what is happening.

P.S. You don't need to redact RFC1918 addresses (such as 192.168.x.x, 10.x.x.x, 172.16.x.x - 172.31.x.x) -- they are not sensitive information.

1 Like

This rule does have an effect and I've been using it for a few years now (and even on older OpenWrt versions since 21 or something).
Even though the client connects to the cloud server, not vice versa, the traffic is returning from the cloud to the client via the same connection.

Unfortunately, I already downgraded to 23.05.5 as I was concerned with traffic rules not working. So I can't provide any relevant logs at the moment, but I'm sure this behavior can be reproduced with other similar rules on 24.10.0.

Maybe I can try it one more time to save logs later as I don't want to disrupt my home network now.

Are you using the same config files for 23.05 as you were trying to use for 24.10? If so, let's see the configs so we can understand two things:

  1. Why the rule is having an effect in 23.05 (as I mentioned, it shouldn't with a default type config, but I'm guessing there are deviations from the default such that the rule has a purpose and effect).
  2. Why the rule might not be working in 24.10.

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:
grafik
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/firewall

Yes, I've been using exactly the same config on both versions. I haven't made any changes just sysupgrade between versions.

See https://nvidia.custhelp.com/app/answers/detail/a_id/5482/~/how-can-i-adjust-my-network-firewall-to-work-with-geforce-now%3F as to why it has an effect.

The output of the commands:

root@MIR4A-Travel:~# ubus call system board
{
	"kernel": "5.15.167",
	"hostname": "MIR4A-Travel",
	"system": "MediaTek MT7621 ver:1 eco:3",
	"model": "Xiaomi Mi Router 4A Gigabit Edition",
	"board_name": "xiaomi,mi-router-4a-gigabit",
	"rootfs_type": "squashfs",
	"release": {
		"distribution": "OpenWrt",
		"version": "23.05.5",
		"revision": "r24106-10cc5fcd00",
		"target": "ramips/mt7621",
		"description": "OpenWrt 23.05.5 r24106-10cc5fcd00"
	}
}

root@MIR4A-Travel:~# 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 packet_steering '1'
	option ula_prefix 'fd03:bb95:6ff8::/48'

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

config device
	option name 'wan.40'
	option type '8021q'
	option ifname 'wan'
	option vid '40'

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

config interface 'wan'
	option device 'wan.40'
	option proto 'pppoe'
	option username 'XXXXXXXX'
	option password 'XXXXXXXX'
	option ipv6 'auto'

root@MIR4A-Travel:~# cat /etc/config/firewall

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'
	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'

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'
	option enabled '1'

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 rule
	option name 'Support-UDP-Traceroute'
	option src 'wan'
	option dest_port '33434-33689'
	option proto 'udp'
	option family 'ipv4'
	option target 'REJECT'
	option enabled '0'

config rule
	option name 'Block-GFN-XXXX'
	option src 'wan'
	option dest 'lan'
	option dest_port '49003-49006'
	option proto 'udp'
	list dest_ip '192.168.2.165'
	option family 'ipv4'
	option target 'REJECT'
	option enabled '1'

config include 'estab'
	option path '/etc/nftables.d/estab.sh'

So this is the summary from the NVIDIA page:

49003 – UDP Inbound AUDIO
49004 – UDP Outbound AUDIO
49005 – UDP Inbound VIDEO
49006 – TCP/UDP Outbound/Inbound Remote Input

You don't have any port forwards that would allow this traffic to ingress unsolicited, so I'm guessing that these are the return paths for traffic that is initiated on by the game. Is your intent to block these ports such that the games don't work? That would be the only reason to block those ports.

Your rule covers inbound audio and video, and part of the inbound remote input (there's also a TCP component).

You may need to add TCP for 49006 -- either in a separate rule or by removing the UDP proto (by default, if nothing is specified, it is UDP + TCP).

You might try removing the destination IP and the destination zone from the rule. This will cause the ports to be blocked for all hosts on your lan (and if that's specifically not desired, it will at least be a good test to see if the rule works when the destinations are not specified).

The reason I think this is needed is because the incoming packets are not destined for 192.168.2.165 -- they're actually destined for your router's address, and then the router will route them to the system that is running the game.

The other issue might be that the game opens a port on its local host, but the port that's actually opened on the router for established/related return traffic may or may not actually be these ports... so the traffic might not be coming into these ports from the internet to the router, but rather from the router (post NAT) to the game.

Yes, the rule is intended to block cloud gaming (return traffic) for a specific device only. It is enough to block a new session or terminate an existing one. I've been using it for many years even with older firmware versions. It's always been working like a charm until 24.10.0, which I don't see a reason not to work.

I don't know the deep details of a technical implementation on the cloud provider's side but I think it's irrelevant as it works on any other version up to 23.05.5.
So regardless of how this is implemented, it must be something different in the firmware itself related to the firewall.
As I don't see any firewall changes in the release notes, I think that could be a bug.

If you have IPv6 enabled then it could also be escaping this rule if your client uses IPv6.

1 Like

When I open "Status - Realtime Graphs - Connections" I see that the connection is established with IPv4 only.

Also, why it escapes on 24.10.0 and doesn't on other versions if all configs are exactly the same?

This is your friend:

nft list ruleset

:slight_smile:

root@MIR4A-Travel:~# nft list chain inet fw4 forward
table inet fw4 {
        chain forward {
                type filter hook forward priority filter; policy drop;
                iifname "br-lan" jump forward_lan comment "!fw4: Handle lan IPv4/IPv6 forward traffic"
                iifname "pppoe-wan" jump forward_wan comment "!fw4: Handle wan IPv4/IPv6 forward traffic"
                ct state established,related accept comment "!fw4: Allow forwarded established and related flows"
                jump handle_reject
        }
}

I can post the entire ruleset but this is the chain that matters in the context of the issue.

Unfortunately, I can't get similar output from 24.10.0 now as I downgraded back already and don't want to disrupt my home network with router reboots. I'll post it also if I get a chance to play around with my router.

The order is not from fw4, established/related/invalid first, then interface dispatch. Same in fw3

The order is different because of reorder script to handle established connections.

That is by @vgaetera , nothing to do with standard firewall.
EDIT: you are welcome to re-arrange forward chain in /usr/share/firewall4/templates/ruleset.uc (backup is under /rom if fw4 check barfs out)

Sorry, I didn't get your recommendation.
What do you mean by standard firewall?
And why do I need to manually re-arrange fw4 templates, which I never did before?
My current configuration works fine (unless I upgrade to 24.10.0), could you please explain what exactly seems wrong to you in it?

This is the default firewall of 23.05.5:

        chain forward {
                type filter hook forward priority filter; policy drop;
                ct state established,related accept comment "!fw4: Allow forwarded established and related flows"
                iifname "br-lan" jump forward_lan comment "!fw4: Handle lan IPv4/IPv6 forward traffic"
                iifname "eth0.2" jump forward_wan comment "!fw4: Handle wan IPv4/IPv6 forward traffic"
                iifname "br-iot" jump forward_iot comment "!fw4: Handle iot IPv4/IPv6 forward traffic"
                jump upnp_forward comment "Hook into miniupnpd forwarding chain"
                jump handle_reject
        }

So it looks like you (or someone else) has altered your firewall, those changes do not carry over automatically if you upgrade
Hint: the script to alter the firewall rules needs an update

1 Like

You used some guide to patch fw4 template files, I perfectly remember changing precisely those lines.

You can get future firewall.uc version here (moving drop invalid earlier in ruleset away from forward chain):

Click "view file" on top right, then download raw file and save into /usr....templates/ and the vgaetera's patch will work again. Or you do the modification yourself with e.g. notepad++

I tagged your patch author, wait a week if they want to assist. OK?

IP Set DNS Filtering - Reorder Firewall Rules - #2 by vgaetera

Assuming it is actually new, there should be no matching conntrack records.
If the source is in the Internet, the destination should match the WAN IP of your router.
Unless you have a matching DNAT rule, it will retain the destination IP.
It will not be routed, will not reach the forward chain, and will be filtered in the input chain.
Meanwhile, the rule in the OP only applies to the forward chain, not the input chain.