I am despairing. By switching to fw4 I am forced to replace the firewall.user.
Here's how it worked perfectly:
/usr/sbin/iptables -t nat -A PREROUTING -p tcp --dport 4431 -d $WAN -j DNAT --to 192.168.166.11
If I deactivate this and activate the following in /etc/config/firewall it doesn't work:
config redirect
option target 'DNAT'
option proto 'tcp'
option src 'wan'
option src_dport '4431'
option dest 'dmz'
option dest_ip '192.168.166.11'
option dest_port '4431'
In the iptables rule you are defining the IP of the interface WAN and applying in PREROUTING.
In the UCI redirect you are applying to all interfaces of wan firewall zone.
Please run the following commands (copy-paste the whole block) and paste the output here, using the "Preformatted text </> " button:
Remember to redact passwords, MAC addresses and any public IP addresses you may have
ubus call system board; \
uci export network; uci export firewall; \
nft list ruleset
previously had a snapshot on it, so that it still works with iptable
I would like to implement it on another router, but with the implementation on fw4 I have the same problem
{
"kernel": "5.10.146",
"hostname": "router-home1",
"system": "ARMv8 Processor rev 4",
"model": "Linksys E8450 (UBI)",
"board_name": "linksys,e8450-ubi",
"rootfs_type": "squashfs",
"release": {
"distribution": "OpenWrt",
"version": "22.03.2",
"revision": "r19803-9a599fee93",
"target": "mediatek/mt7622",
"description": "OpenWrt 22.03.2 r19803-9a599fee93"
}
}
package 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 'fd79:105b:269a::/48'
config device
option name 'br-lan'
option type 'bridge'
option bridge_empty '1'
list ports 'lan1'
list ports 'lan2'
list ports 'lan3'
list ports 'lan4'
config bridge-vlan
option device 'br-lan'
option vlan '1'
list ports 'lan1'
list ports 'lan2'
config interface 'lan'
option device 'br-lan.1'
option proto 'static'
option ipaddr '192.168.115.1'
option netmask '255.255.255.0'
option delegate '0'
config interface 'wan'
option device 'wan'
option proto 'dhcp'
config interface 'wan6'
option device 'wan'
option proto 'dhcpv6'
option reqaddress 'try'
option reqprefix 'auto'
config bridge-vlan
option device 'br-lan'
option vlan '3'
list ports 'lan1:t'
list ports 'lan2:t'
list ports 'lan4:u*'
config interface 'dmz'
option device 'br-lan.3'
option proto 'static'
option ipaddr '192.168.166.1'
option netmask '255.255.255.0'
option delegate '0'
config bridge-vlan
option device 'br-lan'
option vlan '4'
list ports 'lan1:t'
list ports 'lan2:t'
config interface 'gast'
option device 'br-lan.4'
option proto 'static'
option ipaddr '192.168.177.1'
option netmask '255.255.255.0'
option delegate '0'
config bridge-vlan
option device 'br-lan'
option vlan '5'
list ports 'lan1:t'
list ports 'lan2:t'
config interface 'iot'
option device 'br-lan.5'
option proto 'static'
option ipaddr '192.168.188.1'
option netmask '255.255.255.0'
option delegate '0'
...
package firewall
config defaults
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'REJECT'
option synflood_protect '1'
option flow_offloading '0'
config zone
option name 'lan'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'ACCEPT'
list network 'lan'
config forwarding
option src 'lan'
option dest 'wan'
config forwarding
option src 'lan'
option dest 'dmz'
config forwarding
option src 'lan'
option dest 'gast'
config forwarding
option src 'lan'
option dest 'iot'
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 zone
option name 'dmz'
option input 'REJECT'
option output 'ACCEPT'
option forward 'REJECT'
option log '1'
option masq '1'
list network 'dmz'
config forwarding
option src 'dmz'
option dest 'wan'
config forwarding
option src 'dmz'
option dest 'lan'
config forwarding
option src 'dmz'
option dest 'iot'
config zone
option name 'gast'
option output 'ACCEPT'
option forward 'REJECT'
option log '1'
option masq '1'
option input 'ACCEPT'
list network 'gast'
config forwarding
option src 'gast'
option dest 'wan'
config zone
option name 'iot'
option output 'ACCEPT'
option forward 'REJECT'
option log '1'
option masq '1'
option input 'ACCEPT'
list network 'iot'
config forwarding
option src 'iot'
option dest 'wan'
config forwarding
option src 'iot'
option dest 'lan'
config forwarding
option src 'iot'
option dest 'dmz'
...
config redirect
option name 'nc 4431'
option target 'DNAT'
option proto 'tcp'
option src 'wan'
option src_dport '4431'
option dest 'dmz'
option dest_ip '192.168.166.11'
option dest_port '4431'
config rule
option name 'allow nc 4431'
option target 'ACCEPT'
option proto 'tcp'
option src '*'
option src_port '4431'
option dest 'dmz'
option dest_ip '192.168.166.11'
option dest_port '4431'
...
/etc/init.d/firewall restart
Warning: Section @defaults[0] requires unavailable target extension FLOWOFFLOAD, disabling
Warning: Section @defaults[0] requires unavailable target extension FLOWOFFLOAD, disabling
* Flushing IPv4 filter table
* Flushing IPv4 nat table
* Flushing IPv4 mangle table
* Flushing IPv4 raw table
* Flushing conntrack table ...
* Populating IPv4 filter table
* Rule 'allow nc 4431'
...
* Set tcp_ecn to off
* Set tcp_syncookies to on
* Set tcp_window_scaling to on
* Running script '/etc/firewall.user'
iptables: No chain/target/match by that name.
iptables: No chain/target/match by that name.
As I look through your firewall file, I see masquerading enabled on the other zones, too. It should only be enabled on the wan zone. The others should not have it.
Also, you appear to have redirect (port forwarding) as well as a traffic rule for the same port. Remove the rule.
* Populating IPv4 raw table
* Zone 'lan'
- Using automatic conntrack helper attachment
* Zone 'wan'
* Zone 'dmz'
- Using automatic conntrack helper attachment
* Zone 'gast'
- Using automatic conntrack helper attachment
for many years up to version 21 everything ran perfectly, now with the switch to fw4 / version 22 it doesn't want to work. sorry, I'm still a layman here.
...
config redirect
option name 'nextcloud 4431'
option target 'DNAT'
option proto 'tcp'
option src 'wan'
option src_dport '4431'
option dest 'dmz'
option dest_ip '192.168.166.11'
option dest_port '4431'
...
config rule
option name 'allow DHCP'
option target 'ACCEPT'
option proto 'udp'
option family 'ipv4'
option src '*'
option src_port '67-68'
option dest_port '67-68'
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'
...
In principle, nothing has changed compared to the publication above.
What should the solution be if I omit the firewall.user entirely?
Obviously the redirect isn't working.