define netif = enp0s3
define dmzif = enp0s8
define lanif = enp0s9

define firewall = 192.168.0.120
define ipdmz = 172.16.0.254
define iplan = 10.0.0.254

table ip ipfilter{
	chain prerouting {
                type filter hook prerouting priority filter; policy drop;
		icmp type echo-reply accept
		ct state established, related accept
		icmp type echo-request iif {$lanif} ip daddr 172.16.0.1-172.16.0.254 accept
		icmp type echo-request iif {$lanif} ip daddr {$iplan} accept
		tcp dport 22 accept
        }
	chain system_in {
                type filter hook input priority filter; policy drop;
		icmp type echo-reply accept
		icmp type echo-request iif {$lanif} accept
		ct state established, related accept
                tcp dport 22 accept
        }
 	chain routing {
                type filter hook forward priority filter; policy drop;
        	icmp type echo-request iif {$lanif} oif {$dmzif} accept
		icmp type echo-reply iif {$dmzif} oif {$lanif} accept
	}
 	chain system_out {
                type filter hook output priority filter; policy drop;
		icmp type echo-reply oif {$lanif} accept
		icmp type echo-request accept
		ip daddr 10.121.38.7-10.121.38.8 accept
		tcp sport 22 accept
        }
	chain postrouting {
                type filter hook postrouting priority filter; policy drop;
		ip daddr 10.121.38.7-10.121.38.8 accept
		icmp type echo-request ip saddr {$iplan, $ipdmz, $firewall} accept
		icmp type echo-reply iif {$dmzif}  oif {$lanif} accept
		icmp type echo-request iif {$lanif} oif {$dmzif} accept
		icmp type echo-request ip saddr $iplan oif $lanif accept
		tcp sport 22 accept
        }
}