1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-02-13 19:11:51 +00:00
openmptcprouter-feeds/openmptcprouter/files/etc/uci-defaults/1980-omr-firewall

226 lines
7 KiB
Text
Raw Normal View History

2018-03-21 10:04:29 +00:00
#!/bin/sh
# Set REJECT as default rule if an interface is not in a zone
uci -q batch <<-EOF >/dev/null
set firewall.@defaults[0].input='REJECT'
set firewall.@defaults[0].output='REJECT'
set firewall.@defaults[0].forward='REJECT'
EOF
2018-06-07 14:53:32 +00:00
if [ "$(uci -q get firewall.@zone[2].name)" = "vpn" ]; then
uci -q batch <<-EOF >/dev/null
del firewall.@zone[2]
commit firewall
EOF
fi
if [ "$(uci -q get firewall.@zone[1].name)" = "wan" ]; then
uci -q batch <<-EOF >/dev/null
rename firewall.@zone[1]="zone_wan"
del_list firewall.zone_wan.network="wan"
del_list firewall.zone_wan.network="wan6"
commit firewall
EOF
fi
if [ "$(uci -q get firewall.@zone[0].name)" = "lan" ]; then
uci -q batch <<-EOF >/dev/null
rename firewall.@zone[0]="zone_lan"
commit firewall
EOF
fi
2018-06-07 14:53:32 +00:00
if [ "$(uci -q get firewall.zone_vpn)" = "" ]; then
2020-10-30 18:30:46 +00:00
uci -q batch <<-EOF >/dev/null
set firewall.zone_vpn=zone
set firewall.zone_vpn.name=vpn
set firewall.zone_vpn.network=glorytun
set firewall.zone_vpn.masq=1
set firewall.zone_vpn.input=REJECT
set firewall.zone_vpn.forward=ACCEPT
set firewall.zone_vpn.output=ACCEPT
commit firewall
EOF
2018-06-07 14:53:32 +00:00
fi
if [ "$(uci -q get firewall.@rule[5].name)" = "Allow-ICMPv6-Input" ]; then
uci -q batch <<-EOF >/dev/null
del firewall.@rule[5]
commit firewall
EOF
fi
if [ "$(uci -q get firewall.@rule[6].name)" = "Allow-ICMPv6-Forward" ]; then
uci -q batch <<-EOF >/dev/null
del firewall.@rule[6]
commit firewall
EOF
fi
if [ "$(uci -q show firewall | grep Allow-All-Ping)" = "" ]; then
uci -q batch <<-EOF >/dev/null
add firewall rule
set firewall.@rule[-1].enabled='1'
set firewall.@rule[-1].target='ACCEPT'
set firewall.@rule[-1].name='Allow-All-Ping'
set firewall.@rule[-1].proto='icmp'
set firewall.@rule[-1].dest='*'
set firewall.@rule[-1].src='*'
set firewall.@rule[-1].icmp_type='echo-request'
commit firewall
EOF
fi
2018-05-31 13:44:40 +00:00
if [ "$(uci -q show firewall | grep Allow-VPN-ICMP)" = "" ]; then
uci -q batch <<-EOF >/dev/null
add firewall rule
set firewall.@rule[-1].enabled='1'
set firewall.@rule[-1].target='ACCEPT'
set firewall.@rule[-1].name='Allow-VPN-ICMP'
set firewall.@rule[-1].proto='icmp'
set firewall.@rule[-1].src='vpn'
commit firewall
EOF
fi
2018-05-28 15:27:14 +00:00
if [ "$(uci -q show firewall | grep Allow-Lan-to-Wan)" = "" ]; then
uci -q batch <<-EOF >/dev/null
add firewall rule
set firewall.@rule[-1].enabled='1'
set firewall.@rule[-1].target='ACCEPT'
set firewall.@rule[-1].name='Allow-Lan-to-Wan'
set firewall.@rule[-1].dest='wan'
set firewall.@rule[-1].src='lan'
commit firewall
EOF
fi
2018-07-14 05:25:08 +00:00
if [ "$(uci -q show firewall | grep ICMPv6-Lan-to-OMR)" = "" ]; then
uci -q batch <<-EOF >/dev/null
add firewall rule
set firewall.@rule[-1].enabled='1'
set firewall.@rule[-1].target='ACCEPT'
set firewall.@rule[-1].name='ICMPv6-Lan-to-OMR'
set firewall.@rule[-1].src='lan'
set firewall.@rule[-1].family='ipv6'
set firewall.@rule[-1].proto='icmp'
set firewall.@rule[-1].limit='1000/sec'
set firewall.@rule[-1].icmp_type='echo-reply destination-unreachable echo-request router-advertisement router-solicitation time-exceeded'
commit firewall
EOF
fi
2021-03-03 10:28:08 +00:00
#uci -q batch <<-EOF >/dev/null
# del_list firewall.zone_wan.masq_dest='!10.0.0.0/8'
# del_list firewall.zone_wan.masq_dest='!172.16.0.0/12'
# del_list firewall.zone_wan.masq_dest='!192.168.0.0/16'
# add_list firewall.zone_wan.masq_dest='!10.0.0.0/8'
# add_list firewall.zone_wan.masq_dest='!172.16.0.0/12'
# add_list firewall.zone_wan.masq_dest='!192.168.0.0/16'
#EOF
2019-07-15 20:35:38 +00:00
if [ "$(ubus call system board | jsonfilter -e '@.board_name')" = "bananapi,bpi-r2" ] || [ "$(ubus call system board | jsonfilter -e '@.board_name' | grep -i wrt)" != "" ]; then
2018-10-16 06:21:03 +00:00
uci -q batch <<-EOF >/dev/null
set firewall.@defaults[0].flow_offloading='1'
set firewall.@defaults[0].flow_offloading_hw='1'
EOF
fi
2018-08-16 14:57:53 +00:00
2020-01-02 20:03:38 +00:00
if [ "$(uci -q get firewall.omr_server)" = "" ]; then
uci -q batch <<-EOF >/dev/null
2020-01-02 20:03:38 +00:00
set firewall.omr_server=include
set firewall.omr_server.path=/etc/firewall.omr-server
set firewall.omr_server.reload=1
commit firewall
EOF
fi
2020-07-22 13:44:12 +00:00
if [ "$(uci -q get firewall.gre_tunnel)" = "" ]; then
uci -q batch <<-EOF >/dev/null
set firewall.gre_tunnel=include
set firewall.gre_tunnel.path=/etc/firewall.gre-tunnel
set firewall.gre_tunnel.reload=1
commit firewall
EOF
fi
2020-10-09 15:38:31 +00:00
if [ "$(uci -q get firewall.fwlantovpn)" = "" ]; then
uci -q batch <<-EOF >/dev/null
set firewall.zone_lan.auto_helper='0'
2020-10-09 15:38:31 +00:00
set firewall.fwlantovpn=forwarding
set firewall.fwlantovpn.src='lan'
set firewall.fwlantovpn.dest='vpn'
commit firewall
EOF
fi
2020-10-28 12:09:26 +00:00
if [ "$(uci -q get firewall.blockquicproxy)" = "" ]; then
uci -q batch <<-EOF >/dev/null
set firewall.blockquicproxy=rule
set firewall.blockquicproxy.name='Block QUIC Proxy'
set firewall.blockquicproxy.proto='udp'
set firewall.blockquicproxy.dest_port='443'
set firewall.blockquicproxy.target='DROP'
set firewall.blockquicproxy.src='lan'
set firewall.blockquicall=rule
set firewall.blockquicall.name='Block QUIC All'
set firewall.blockquicall.proto='udp'
set firewall.blockquicall.src='*'
set firewall.blockquicall.dest='*'
set firewall.blockquicall.dest_port='443'
set firewall.blockquicall.target='DROP'
commit firewall
EOF
fi
if [ "$(uci -q get firewall.allowicmpipv6)" = "" ]; then
uci -q batch <<-EOF >/dev/null
set firewall.allowicmpipv6=rule
set firewall.allowicmpipv6.proto='icmp'
set firewall.allowicmpipv6.target='ACCEPT'
set firewall.allowicmpipv6.src='wan'
set firewall.allowicmpipv6.name='Allow IPv6 ICMP'
set firewall.allowicmpipv6.family='ipv6'
set firewall.allowicmpipv6.icmp_type='neighbour-advertisement neighbour-solicitation router-advertisement router-solicitation'
commit firewall
EOF
fi
2021-01-21 18:01:30 +00:00
if [ "$(uci -q get firewall.allowdhcpv6546)" = "" ]; then
uci -q batch <<-EOF >/dev/null
set firewall.allowdhcpv6546=rule
set firewall.allowdhcpv6546.target='ACCEPT'
set firewall.allowdhcpv6546.src='wan'
set firewall.allowdhcpv6546.proto='udp'
set firewall.allowdhcpv6546.dest_port='547'
set firewall.allowdhcpv6546.name='Allow DHCPv6 (546-to-547)'
set firewall.allowdhcpv6546.family='ipv6'
set firewall.allowdhcpv6546.src_port='546'
set firewall.allowdhcpv6547=rule
set firewall.allowdhcpv6547.target='ACCEPT'
set firewall.allowdhcpv6547.src='wan'
set firewall.allowdhcpv6547.proto='udp'
set firewall.allowdhcpv6547.dest_port='546'
set firewall.allowdhcpv6547.name='Allow DHCPv6 (547-to-546)'
set firewall.allowdhcpv6547.family='ipv6'
set firewall.allowdhcpv6547.src_port='547'
commit firewall
EOF
fi
2020-11-01 09:03:47 +00:00
# Fix firewall config from some old config
allintf=$(uci -q get firewall.zone_wan.network)
uci -q del firewall.zone_wan.network
2020-11-01 09:03:47 +00:00
for intf in $allintf; do
uci -q add_list firewall.zone_wan.network=$intf
2020-11-01 09:03:47 +00:00
done
2020-11-27 17:13:36 +00:00
allintf=$(uci -q get firewall.zone_vpn.network)
uci -q del firewall.zone_vpn.network
for intf in $allintf; do
uci -q add_list firewall.zone_vpn.network=$intf
done
2020-11-01 09:03:47 +00:00
2019-05-21 19:37:45 +00:00
uci -q batch <<-EOF >/dev/null
set firewall.zone_lan.mtu_fix='1'
2019-05-21 19:37:45 +00:00
set firewall.zone_vpn.mtu_fix='1'
set firewall.@include[0].reload='1'
2020-10-09 15:38:31 +00:00
commit firewall
2019-05-21 19:37:45 +00:00
EOF
2018-03-21 10:04:29 +00:00
rm -f /tmp/luci-indexcache
exit 0