{% import 'macros.j2' as macros with context %} # pf ~~ /etc/pf.conf # managed by Ansible # common configuration set block-policy drop set loginterface egress set skip on { lo tun0 } block all # host services {% for service in services %} pass in quick on egress proto {{ service["proto"] }} to port {{ service["port"] }} {% endfor %} # redirection {% call(h) macros.loop_valid_hosts("servers") %} {% if h.services is defined %} {% for service in h.services if h.ansible_host != global.dcontroller and service.public is defined and service.public %} pass in on egress proto {{ service.proto }} from any to any port {{ service.port }} rdr-to {{ h.ip.in }} {% endfor %} {% endif %} {% endcall %} {# {% if hypervisor is defined and vms is defined %} # hypervisor network passthrough {% for i in range(vms | length + 5) %} set skip on tap{{ i }} {% endfor %} {% endif %} #} # wireguard pass in on egress inet proto udp from any to any port 50000 pass out quick on egress inet from (tun0:network) nat-to (egress:0) # output network pass out quick inet pass in proto { icmp, icmp6 } all