Am trying to Build a Firewall for Unbound DNS resolver since a month and was not successful, solved almost all the configs except the IPFW rules, using FreeBSD 12.1-RELEASE-p5
Below are my rule list
NOTE: a.a.a.a , b.b.b.b, c.c.c.c and d.d.d.d are my ipv4 Public IP pools
hhhh:hhhh::/32 is my ipv6 public IP pool
Problems I have
a) IPV6 host are unable to connect/establish to port 53 (no count in IPFW SHOW)
b) ping6 doesn't work (there is count in IPFW SHOW but can't ping Facebook.com yahoo.com and ipv6.google.com)
c) can't establish IPV6 connectivity over TLS at port 853 (there is count in IPFW SHOW but can establish the connection once verified with netstat -b)
if I stop/disable IPFW every works amazingly fine, kindly help me where did i go wrong in the below rule set.
copy of my IPFW.rules below
Below are my rule list
NOTE: a.a.a.a , b.b.b.b, c.c.c.c and d.d.d.d are my ipv4 Public IP pools
hhhh:hhhh::/32 is my ipv6 public IP pool
Problems I have
a) IPV6 host are unable to connect/establish to port 53 (no count in IPFW SHOW)
b) ping6 doesn't work (there is count in IPFW SHOW but can't ping Facebook.com yahoo.com and ipv6.google.com)
c) can't establish IPV6 connectivity over TLS at port 853 (there is count in IPFW SHOW but can establish the connection once verified with netstat -b)
if I stop/disable IPFW every works amazingly fine, kindly help me where did i go wrong in the below rule set.
copy of my IPFW.rules below
Code:
#!/bin/sh
# Flush out the list before we begin.
ipfw -q -f flush
# Set rules command prefix
cmd="ipfw -q add"
pif="vtnet0" # interface name of NIC attached to Internet
# Loopback
$cmd 00009 allow ip6 from any to any via lo0
$cmd 00010 allow all from any to any via lo0
$cmd 00101 check-state
# Allow access to public DNS over TLS using Unbound
$cmd 00111 allow ip6 from me6 to any proto tcp dst-port 853 out via $pif setup keep-state
$cmd 00112 allow tcp from me to any 853 out via $pif setup keep-state
# Allow outbound Ping
$cmd 00249 allow ipv6-icmp from me6 to any out via $pif keep-state
$cmd 00250 allow icmp from any to any out via $pif keep-state
# Allow outbound NTP
$cmd 00260 allow udp from any to any 123 out via $pif keep-state
# deny and log all other outbound connections
$cmd 00299 deny log all from any to any out via $pif
# Deny all inbound traffic from non-routable reserved address spaces
$cmd 00300 deny all from 192.168.0.0/16 to any in via $pif #RFC 1918 private IP
$cmd 00301 deny all from 172.16.0.0/12 to any in via $pif #RFC 1918 private IP
$cmd 00302 deny all from 10.0.0.0/8 to any in via $pif #RFC 1918 private IP
$cmd 00303 deny all from 127.0.0.0/8 to any in via $pif #loopback
$cmd 00304 deny all from 0.0.0.0/8 to any in via $pif #loopback
$cmd 00305 deny all from 169.254.0.0/16 to any in via $pif #DHCP auto-config
$cmd 00306 deny all from 192.0.2.0/24 to any in via $pif #reserved for docs
$cmd 00307 deny all from 204.152.64.0/23 to any in via $pif #Sun cluster interconnect
$cmd 00308 deny all from 224.0.0.0/3 to any in via $pif #Class D & E multicast
# allow ping only ip pools
$cmd 00310 allow icmp from a.a.a.a/24 to any in via $pif
$cmd 00311 allow icmp from b.b.b.b/22 to me in via $pif
$cmd 00312 allow icmp from c.c.c.c/22 to me in via $pif
$cmd 00313 allow icmp from d.d.d.d/22 to me in via $pif
# Deny ident
$cmd 00315 deny tcp from any to any 113 in via $pif
# Deny all Netbios services.
$cmd 00320 deny tcp from any to any 137 in via $pif
$cmd 00321 deny tcp from any to any 138 in via $pif
$cmd 00322 deny tcp from any to any 139 in via $pif
$cmd 00323 deny tcp from any to any 81 in via $pif
# Deny fragments
$cmd 00330 deny all from any to any frag in via $pif
# Deny ACK packets that did not match the dynamic rule table
$cmd 00332 deny tcp from any to any established in via $pif
# Allow inbound SSH connections from Office pool
$cmd 00410 allow tcp from a.a.a.a/24 to me 22 in via $pif setup limit src-addr 2
#Allow Inbound DNS requests from Public IP Pools
$cmd 00440 allow ip6 from hhhh:hhhh::/32 to me6 53 proto udp in via $pif keep-state
$cmd 00441 allow ip6 from hhhh:hhhh::/32 to me6 53 proto tcp in via $pif setup keep-state
$cmd 00450 allow udp from b.b.b.b/22 to me 53 in via $pif keep-state
$cmd 00451 allow udp from c.c.c.c/22 to me 53 in via $pif keep-state
$cmd 00452 allow udp from d.d.d.d/22 to me 53 in via $pif keep-state
$cmd 00453 allow tcp from b.b.b.b/22 to me 53 in via $pif setup keep-state
$cmd 00454 allow tcp from c.c.c.c/22 to me 53 in via $pif setup keep-state
$cmd 00455 allow tcp from d.d.d.d/22 to me 53 in via $pif setup keep-state
# Allow SNMPD Server
$cmd 00475 allow udp from a.a.a.a/24 to me 161 in via $pif keep-state
# Reject and log all other incoming connections
$cmd 00499 deny log all from any to any in via $pif
# Everything else is denied and logged
$cmd 00999 deny log all from any to any
Last edited by a moderator: