Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision Next revisionBoth sides next revision | ||
| docs:guide-user:firewall:fw3_configurations:bridge [2021/12/13 10:45] – [Selective forwarding] vgaetera | docs:guide-user:firewall:fw3_configurations:bridge [2023/10/14 05:41] – use service invocation vgaetera | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Bridge firewall ====== | ====== Bridge firewall ====== | ||
| - | {{section> | + | {{section> |
| ===== Introduction ===== | ===== Introduction ===== | ||
| Line 8: | Line 8: | ||
| ===== Goals ===== | ===== Goals ===== | ||
| - | * Filter traffic | + | * Filter |
| ===== Command-line instructions ===== | ===== Command-line instructions ===== | ||
| + | Assuming a setup with bridged LAN and WAN interfaces. | ||
| Install the required packages. | Install the required packages. | ||
| - | Enable bridge firewall. | + | Enable bridge firewall |
| <code bash> | <code bash> | ||
| # Install packages | # Install packages | ||
| opkg update | opkg update | ||
| - | opkg install kmod-br-netfilter | + | opkg install kmod-nft-bridge |
| - | # Configure | + | # Configure |
| - | cat << EOF >> /etc/sysctl.conf | + | cat << |
| - | net.bridge.bridge-nf-call-arptables=1 | + | . / |
| - | net.bridge.bridge-nf-call-iptables=1 | + | network_flush_cache |
| - | net.bridge.bridge-nf-call-ip6tables=1 | + | network_find_wan NET_IF |
| + | network_get_device NET_DEV " | ||
| + | NET_MAC=" | ||
| + | " | ||
| + | nft add table bridge | ||
| + | nft flush table bridge | ||
| + | nft add chain bridge filter prerouting \ | ||
| + | { type filter hook prerouting priority dstnat\; } | ||
| + | nft add rule bridge filter prerouting meta \ | ||
| + | l4proto { tcp, udp } th dport 53 pkttype set host \ | ||
| + | ether daddr set " | ||
| + | nft add chain bridge | ||
| + | { type filter hook forward priority filter\; } | ||
| + | nft add rule bridge | ||
| + | oifname " | ||
| EOF | EOF | ||
| - | /etc/init.d/sysctl | + | uci -q delete firewall.bridge |
| + | uci set firewall.bridge=" | ||
| + | uci set firewall.bridge.path=" | ||
| + | uci commit firewall | ||
| + | service firewall | ||
| </ | </ | ||
| + | |||
| + | Set up [[docs: | ||
| ===== Testing ===== | ===== Testing ===== | ||
| - | Use [[man>ping(8)|ping]], [[man>ping6(8)|ping6]] or [[man>nmap(1)|nmap]] between | + | Use [[man>nslookup(1)|nslookup]], [[man>ping(1)|ping]], [[man>ping6(1)|ping6]] on LAN clients to verify |
| ===== Troubleshooting ===== | ===== Troubleshooting ===== | ||
| Line 36: | Line 57: | ||
| <code bash> | <code bash> | ||
| # Log and status | # Log and status | ||
| - | / | + | service |
| # Runtime configuration | # Runtime configuration | ||
| - | iptables-save -c; ip6tables-save -c; brctl show | + | lsmod | grep -e bridge |
| - | lsmod | grep -e br_netfilter; | + | nft list ruleset |
| # Persistent configuration | # Persistent configuration | ||
| - | uci show firewall; grep -v -e " | + | uci show firewall |
| </ | </ | ||
| ===== Extras ===== | ===== Extras ===== | ||
| - | ==== Restrict forwarding | + | ==== References |
| - | Restrict traffic forwarding between bridged interfaces. | + | |
| - | + | * [[https://netdevconf.info//1.1/ | |
| - | <code bash> | + | |
| - | # Disable LAN to LAN forwarding | + | |
| - | uci rename firewall.@zone[0]=" | + | |
| - | uci set firewall.lan.forward=" | + | |
| - | uci commit firewall | + | |
| - | /etc/init.d/firewall restart | + | |
| - | </code> | + | |
| - | + | ||
| - | ==== Selective forwarding ==== | + | |
| - | Selective traffic forwarding between bridged interfaces. | + | |
| - | + | ||
| - | <code bash> | + | |
| - | # Install packages | + | |
| - | opkg update | + | |
| - | opkg install iptables-mod-physdev | + | |
| - | + | ||
| - | # Disable LAN1 to LAN2 forwarding | + | |
| - | uci -q delete firewall.lan1_lan2 | + | |
| - | uci set firewall.lan1_lan2=" | + | |
| - | uci set firewall.lan1_lan2.name=" | + | |
| - | uci set firewall.lan1_lan2.src=" | + | |
| - | uci set firewall.lan1_lan2.dest=" | + | |
| - | uci set firewall.lan1_lan2.extra=" | + | |
| - | uci set firewall.lan1_lan2.proto=" | + | |
| - | uci set firewall.lan1_lan2.target=" | + | |
| - | uci commit firewall | + | |
| - | / | + | |
| - | </ | + | |