config defaults
	option synflood_protect	'1'
	option input		'ACCEPT'
	option output		'ACCEPT'
	option forward		'DROP'

config zone
	option name		'lan'
	list   network		'lan'
	option input		'ACCEPT'
	option output		'ACCEPT'
	option forward		'ACCEPT'
	option log		'0'

config zone
	option name		'wan'
	list   network		'wan'
	option input		'DROP'
	option output		'ACCEPT'
	option forward		'DROP'
	option masq		'1'
	option mtu_fix		'1'
	option log		'0'

config zone
	option name		'wwan'
	list   network		'wwan'
	list   network		'wwwan'
	option input		'DROP'
	option output		'ACCEPT'
	option forward		'DROP'
	option masq		'1'
	option mtu_fix		'1'

config zone
	option name		'vpn'
	option input		'ACCEPT'
	option output		'ACCEPT'
	option forward		'ACCEPT'
	option masq		'0'
	option network		'vpn'

config forwarding
	option src		'lan'
	option dest		'wan'

config forwarding
	option src		'vpn'
	option dest		'lan'

config forwarding
	option src		'vpn'
	option dest		'wwan'

config forwarding
	option src		'lan'
	option dest		'vpn'

# allow WAN to access ssh port
config rule
	option name		Allow-WAN-SSH
	option src		wan
	option dest_port	22
	option proto		tcp
	option target		ACCEPT

# allow WAN to access http port
config rule
	option name		Allow-WAN-HTTP
	option src		wan
	option dest_port	80
	option proto		tcp
	option target		ACCEPT

# allow WAN to access https port
config rule
	option name		Allow-WAN-HTTPS
	option src		wan
	option dest_port	443
	option proto		tcp
	option target		ACCEPT

# redirect wan interface SSH connections to Windows CNC PC
config redirect
	option src		wan
	option src_dport	9022
	option dest		lan
	option dest_ip		192.168.10.154
	option dest_port	22
	option proto		tcp
	option target		dnat

# redirect wan interface SSH connections to Linux CNC PC
config redirect
	option src		wan
	option src_dport	9122
	option dest		lan
	option dest_ip		192.168.10.155
	option dest_port	22
	option proto		tcp
	option target		dnat

# redirect wan interface RDP connections to Windows CNC PC
config redirect
	option src		wan
	option src_dport	3389
	option dest		lan
	option dest_ip		192.168.10.154
	option dest_port	3389
	option proto		tcp
	option target		dnat

# redirect wan interface RDP connections to Linux CNC PC
config redirect
	option src		wan
	option src_dport	3489
	option dest		lan
	option dest_ip		192.168.10.155
	option dest_port	3389
	option proto		tcp
	option target		dnat

# redirect wan interface HTTP connections to plasma web server
config redirect
	option src		wan
	option src_dport	8080
	option dest		lan
	option dest_ip		192.168.10.11
	option dest_port	80
	option proto		tcp
	option target		dnat

# redirect wan interface SSH connections to plasma sshd server
config redirect
	option src		wan
	option src_dport	8022
	option dest		lan
	option dest_ip		192.168.10.11
	option dest_port	22
	option proto		tcp
	option target		dnat

# redirect wan interface HTTPS connections to plasma web server
config redirect
	option src		wan
	option src_dport	8443
	option dest		lan
	option dest_ip		192.168.10.11
	option dest_port	443
	option proto		tcp
	option target		dnat

# redirect vpn interface SSH connections to Windows CNC PC
config redirect
	option src		vpn
	option src_dport	9022
	option dest		lan
	option dest_ip		192.168.10.154
	option dest_port	22
	option proto		tcp
	option target		dnat

# redirect vpn interface SSH connections to Linux CNC PC
config redirect
	option src		vpn
	option src_dport	9122
	option dest		lan
	option dest_ip		192.168.10.155
	option dest_port	22
	option proto		tcp
	option target		dnat

# redirect vpn interface RDP connections to Windows CNC PC
config redirect
	option src		vpn
	option src_dport	3389
	option dest		lan
	option dest_ip		192.168.10.154
	option dest_port	3389
	option proto		tcp
	option target		dnat

# redirect vpn interface RDP connections to Linux CNC PC
config redirect
	option src		vpn
	option src_dport	3489
	option dest		lan
	option dest_ip		192.168.10.155
	option dest_port	3389
	option proto		tcp
	option target		dnat

# redirect vpn interface HTTP connections to plasma web server
config redirect
	option src		vpn
	option src_dport	8080
	option dest		lan
	option dest_ip		192.168.10.11
	option dest_port	80
	option proto		tcp
	option target		dnat

# redirect vpn interface SSH (port 8022) connections to plasma (port 22)
config redirect
	option src		vpn
	option src_dport	8022
	option dest		lan
	option dest_ip		192.168.10.11
	option dest_port	22
	option proto		tcp
	option target		dnat

# redirect vpn interface HTTPS connections to plasma web server
config redirect
	option src		vpn
	option src_dport	8443
	option dest		lan
	option dest_ip		192.168.10.11
	option dest_port	443
	option proto		tcp
	option target		dnat

# We need to accept udp packets on port 68,
# see https://dev.openwrt.org/ticket/4108
config rule
	option name		Allow-DHCP-Renew-wan
	option src		wan
	option proto		udp
	option dest_port	68
	option target		ACCEPT
	option family		ipv4

config rule
	option name		Allow-DHCP-Renew-wwan
	option src		wwan
	option proto		udp
	option dest_port	68
	option target		ACCEPT
	option family		ipv4

# Allow IPv4 ping
config rule
	option name		Allow-Ping-wan
	option src		wan
	option proto		icmp
	option icmp_type	echo-request
	option family		ipv4
	option target		ACCEPT

config rule
	option name		Allow-Ping-wwan
	option src		wwan
	option proto		icmp
	option icmp_type	echo-request
	option family		ipv4
	option target		ACCEPT

config rule
	option name		Allow-IGMP-wan
	option src		wan
	option proto		igmp
	option family		ipv4
	option target		ACCEPT

	option name		Allow-IGMP-wwan
	option src		wwan
	option proto		igmp
	option family		ipv4
	option target		ACCEPT

config rule
	option name		Allow-IPSec-ESP-wan
	option src		wan
	option dest		lan
	option proto		esp
	option target		ACCEPT

	option name		Allow-IPSec-ESP-wwan
	option src		wwan
	option dest		lan
	option proto		esp
	option target		ACCEPT

config rule
	option name		Allow-ISAKMP-wan
	option src		wan
	option dest		lan
	option dest_port	500
	option proto		udp
	option target		ACCEPT

config rule
	option name		Allow-ISAKMP-wwan
	option src		wwan
	option dest		lan
	option dest_port	500
	option proto		udp
	option target		ACCEPT

# allow PL (Plasma Source) to access wwan
config rule
	option name		Allow-Plasma-PL-wwan
	option src		lan
	option dest		wwan
	option src_ip		192.168.10.11
	option proto		tcpudp
	option target		ACCEPT

# # allow LAN to access wwan's modem 1
# config rule
# 	option name		Allow-LAN-modem1
# 	option src		lan
# 	option dest_ip		192.168.1.1
# 	option proto		tcpudp
# 	option target		ACCEPT

# # allow LAN to access wwan's modem 8
# config rule
# 	option name		Allow-LAN-modem8
# 	option src		lan
# 	option dest_ip		192.168.8.1
# 	option proto		tcpudp
# 	option target		ACCEPT

# allow Win to access wwan for TeamViewer
config rule
	option name		Allow-Win-TW-5938-wwan
	option src		lan
	option dest		wwan
	option src_ip		192.168.10.154
	option proto		tcpudp
	option dest_port	5938
	option target		ACCEPT

# allow Linux to access wwan for TeamViewer
config rule
	option name		Allow-Linux-TW-5938-wwan
	option src		lan
	option dest		wwan
	option src_ip		192.168.10.155
	option proto		tcpudp
	option dest_port	5938
	option target		ACCEPT

# allow Win to access wwan for Anydesk
config rule
	option name		Allow-Win-AD-6568-wwan
	option src		lan
	option dest		wwan
	option src_ip		192.168.10.154
	option proto		tcpudp
	option dest_port	6568
	option target		ACCEPT

# allow Linux to access wwan for Anydesk
config rule
	option name		Allow-Linux-AD-6568-wwan
	option src		lan
	option dest		wwan
	option src_ip		192.168.10.155
	option proto		tcpudp
	option dest_port	6568
	option target		ACCEPT

# allow Win to access wwan for Ammyy Admin
config rule
	option name		Allow-Win-AA-8080-wwan
	option src		lan
	option dest		wwan
	option src_ip		192.168.10.154
	option proto		tcpudp
	option dest_port	8080
	option target		ACCEPT

# allow Linux to access wwan for Ammyy Admin
config rule
	option name		Allow-Linux-AA-8080-wwan
	option src		lan
	option dest		wwan
	option src_ip		192.168.10.155
	option proto		tcpudp
	option dest_port	8080
	option target		ACCEPT

# allow Win to access wwan for Kontur.Dostup (HTTPS 8443)
config rule
	option name		Allow-WinKD-https-8443-wwan
	option src		lan
	option dest		wwan
	option src_ip		192.168.10.154
	option proto		tcpudp
	option dest_port	8443
	option target		ACCEPT

# allow Win to access wwan for Kontur.Dostup (HTTPS 5938)
config rule
	option name		Allow-WinKD-https-5938-wwan
	option src		lan
	option dest		wwan
	option src_ip		192.168.10.154
	option proto		tcpudp
	option dest_port	5938
	option target		ACCEPT

# allow Linux to access wwan for Kontur.Dostup (HTTPS 8443)
config rule
	option name		Allow-LinuxKD-https-8443-wwan
	option src		lan
	option dest		wwan
	option src_ip		192.168.10.155
	option proto		tcpudp
	option dest_port	8443
	option target		ACCEPT

# allow Linux to access wwan for Kontur.Dostup (HTTPS 5938)
config rule
	option name		Allow-LinuxKD-https-5938-wwan
	option src		lan
	option dest		wwan
	option src_ip		192.168.10.155
	option proto		tcpudp
	option dest_port	5938
	option target		ACCEPT

# allow Win to access wwan for Kontur.Dostup (WebSockets 8444)
config rule
	option name		Allow-WinKD-ws-8444-wwan
	option src		lan
	option dest		wwan
	option src_ip		192.168.10.154
	option proto		tcpudp
	option dest_port	8444
	option target		ACCEPT

# allow Linux to access wwan for Kontur.Dostup (WebSockets 8444)
config rule
	option name		Allow-LinuxKD-ws-8444-wwan
	option src		lan
	option dest		wwan
	option src_ip		192.168.10.155
	option proto		tcpudp
	option dest_port	8444
	option target		ACCEPT

# allow Win to access wwan for Kontur.Dostup (WebSockets 5939)
config rule
	option name		Allow-WinKD-ws-5939-wwan
	option src		lan
	option dest		wwan
	option src_ip		192.168.10.154
	option proto		tcpudp
	option dest_port	5939
	option target		ACCEPT

# allow Linux to access wwan for Kontur.Dostup (WebSockets 5939)
config rule
	option name		Allow-LinuxKD-ws-5939-wwan
	option src		lan
	option dest		wwan
	option src_ip		192.168.10.155
	option proto		tcpudp
	option dest_port	5939
	option target		ACCEPT

# allow Win to access wwan for Kontur.Dostup (VNC 3478)
config rule
	option name		Allow-WinKD-vnc-3478-wwan
	option src		lan
	option dest		wwan
	option src_ip		192.168.10.154
	option proto		tcpudp
	option dest_port	3478
	option target		ACCEPT

# allow Linux to access wwan for Kontur.Dostup (VNC 3478)
config rule
	option name		Allow-LinuxKD-vnc-3478-wwan
	option src		lan
	option dest		wwan
	option src_ip		192.168.10.155
	option proto		tcpudp
	option dest_port	3478
	option target		ACCEPT

# allow Win to access wwan for Kontur ipv4 networks
config rule
	option name		Allow-WinKontur-ipv4-net1-wwan
	option src		lan
	option dest		wwan
	option src_ip		192.168.10.154
	option dest_ip		185.161.180.0/22
	option proto		all
	option target		ACCEPT

config rule
	option name		Allow-WinKontur-ipv4-net2-wwan
	option src		lan
	option dest		wwan
	option src_ip		192.168.10.154
	option dest_ip		46.17.200.0/21
	option proto		all
	option target		ACCEPT

config rule
	option name		Allow-WinKontur-ipv4-net3-wwan
	option src		lan
	option dest		wwan
	option src_ip		192.168.10.154
	option dest_ip		89.169.16.0/22
	option proto		all
	option target		ACCEPT

# allow Linux to access wwan for Kontur ipv4 networks
config rule
	option name		Allow-LinuxKontur-ipv4-net1-wwan
	option src		lan
	option dest		wwan
	option src_ip		192.168.10.155
	option dest_ip		185.161.180.0/22
	option proto		all
	option target		ACCEPT

config rule
	option name		Allow-LinuxKontur-ipv4-net2-wwan
	option src		lan
	option dest		wwan
	option src_ip		192.168.10.155
	option dest_ip		46.17.200.0/21
	option proto		all
	option target		ACCEPT

config rule
	option name		Allow-LinuxKontur-ipv4-net3-wwan
	option src		lan
	option dest		wwan
	option src_ip		192.168.10.155
	option dest_ip		89.169.16.0/22
	option proto		all
	option target		ACCEPT

# allow Win to access wwan for TektonIT RMS
config rule
	option name		Allow-WinRMS-wwan
	option src		lan
	option dest		wwan
	option src_ip		192.168.10.154
	option proto		tcpudp
	option dest_port	5650
	option target		ACCEPT

# allow Linux to access wwan for TektonIT RMS
config rule
	option name		Allow-LinuxRMS-wwan
	option src		lan
	option dest		wwan
	option src_ip		192.168.10.155
	option proto		tcpudp
	option dest_port	5650
	option target		ACCEPT

# allow Win to access wwan for Git repo
config rule
	option name		Allow-WinGit-wwan
	option src		lan
	option dest		wwan
	option src_ip		192.168.10.154
	option proto		tcpudp
	option dest_port	8022
	option target		ACCEPT

# allow any hosts to ping wwan
config rule
	option name		Enable-ICMP-wwan
	option src		lan
	option dest		wwan
	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 target		ACCEPT

# include a file with users custom iptables rules
config include
	option fw4_compatible	1
	option path 		/etc/firewall.user
