Good evening everyone,
I have a question regarding my pf.conf, how do I setup my firewall to get reverse nat working? I was reading and there is an natd available but it works with firewalld. My current conf for pf is as below:
Basically I would like to visit my website inside local network using my external (public) IP address
I have a question regarding my pf.conf, how do I setup my firewall to get reverse nat working? I was reading and there is an natd available but it works with firewalld. My current conf for pf is as below:
Code:
##################################################
# Firewall (PF) by Airost made on 27/04/2022 #
##################################################
##############################
# Makra i tabele #
##############################
lo_if="lo0" #loopback
wan_if="tun0" #PlusNet
lan_if="bge1" #LAN
lan_net="172.16.0.1/16" #Siec LAN
my_ip="212.159.22.253" #IP WAN
rockyvm="tap1" #Rocky VM
win2012servervm="tap0" #Windows 2012 Server VM
ubuntuvm="tap2" #Ubuntu VM
win2022servervm="tap3" #Windows 2022 Server VM
uzytkownicy="{ 172.16.0.1,
172.16.0.2,
172.16.0.3,
172.16.0.4,
172.16.0.5,
172.16.0.6,
172.16.0.7,
172.16.0.8,
172.16.0.9,
172.16.0.10,
172.16.0.11,
172.16.0.12,
172.16.0.13,
172.16.0.14,
172.16.0.15,
172.16.0.16,
172.16.0.17,
172.16.0.18,
172.16.0.19,
172.16.0.20,
172.16.0.21,
172.16.0.22,
172.16.0.23,
172.16.0.24,
172.16.0.25,
172.16.1.2,
172.16.0.109,
172.16.0.100,
172.16.0.110,
172.16.0.111,
172.16.0.120,
172.16.0.121,
172.16.10.2,
172.16.10.3 }"
virtual="{ 10.0.0.1,
10.0.0.2,
10.0.0.3,
10.0.0.4,
10.0.0.10,
10.0.0.20,
10.0.0.100 }"
set loginterface $wan_if
set loginterface $lan_if
set optimization normal
##############################
# Normalizacja pakietow #
##############################
scrub in all
scrub on $wan_if no-df
##############################
# AltQ - upload #
##############################
altq on $wan_if cbq bandwidth 1Gb queue { std_out \
accesspointac_out \
airost_out \
airostmobile_out \
aszka_out \
aszkamobile_out \
aszkaipad_out \
PS4_out \
amazontv_out \
bluray_out \
nx6330_out \
aszkamobile7plus_out \
airostiphonese_out \
vch_out \
wch_out \
annatanska_out \
romantanski_out \
morfinalaptop_out \
accesspointn_out \
airosteth_out \
amazontveth_out \
canonprinter_out \
hpprinter_out \
wwwserver_out \
mailserver_out \
gameserver_out }
queue std_out bandwidth 30Mb cbq(default borrow red)
queue accesspointac_out bandwidth 300Mb cbq(borrow red)
queue airost_out bandwidth 10Mb cbq(red)
queue airostmobile_out bandwidth 1Mb cbq(red)
queue aszka_out bandwidth 5Mb cbq(red)
queue aszkamobile_out bandwidth 1Mb cbq(red)
queue aszkaipad_out bandwidth 1Mb cbq(red)
queue PS4_out bandwidth 1Mb cbq(red)
queue amazontv_out bandwidth 1Mb cbq(red)
queue bluray_out bandwidth 1Mb cbq(red)
queue nx6330_out bandwidth 1Mb cbq(red)
queue aszkamobile7plus_out bandwidth 1Mb cbq(red)
queue airostiphonese_out bandwidth 1Mb cbq(red)
queue vch_out bandwidth 1Mb cbq(red)
queue wch_out bandwidth 1Mb cbq(red)
queue annatanska_out bandwidth 1Mb cbq(red)
queue romantanski_out bandwidth 1Mb cbq(red)
queue morfinalaptop_out bandwidth 1Mb cbq(red)
queue accesspointn_out bandwidth 300Mb cbq(borrow red)
queue airosteth_out bandwidth 10Mb cbq(red)
queue amazontveth_out bandwidth 1Mb cbq(red)
queue canonprinter_out bandwidth 1Mb cbq(red)
queue hpprinter_out bandwidth 1Mb cbq(red)
queue wwwserver_out bandwidth 10Mb cbq(borrow red)
queue mailserver_out bandwidth 10Mb cbq(borrow red)
queue gameserver_out bandwidth 10Mb cbq(borrow red)
##############################
# AltQ - download #
##############################
altq on $lan_if cbq bandwidth 1Gb queue { std_in \
accesspointac_in \
airost_in \
airostmobile_in \
aszka_in \
aszkamobile_in \
aszkaipad_in \
PS4_in \
amazontv_in \
bluray_in \
nx6330_in \
aszkamobile7plus_in \
airostiphonese_in \
vch_in \
wch_in \
annatanska_in \
romantanski_in \
morfinalaptop_in \
accesspointn_in \
airosteth_in \
amazontveth_in \
canonprinter_in \
hpprinter_in \
wwwserver_in \
mailserver_in \
gameserver_in }
queue std_in bandwidth 78Mb cbq(default borrow red)
queue accesspointac_in bandwidth 378Mb cbq(borrow red)
queue airost_in bandwidth 30Mb cbq(borrow red)
queue airostmobile_in bandwidth 5Mb cbq(red)
queue aszka_in bandwidth 20Mb cbq(borrow red)
queue aszkamobile_in bandwidth 5Mb cbq(red)
queue aszkaipad_in bandwidth 5Mb cbq(red)
queue PS4_in bandwidth 10Mb cbq(borrow red)
queue amazontv_in bandwidth 10Mb cbq(borrow red)
queue bluray_in bandwidth 10Mb cbq(borrow red)
queue nx6330_in bandwidth 10Mb cbq(borrow red)
queue aszkamobile7plus_in bandwidth 5Mb cbq(red)
queue airostiphonese_in bandwidth 5Mb cbq(red)
queue vch_in bandwidth 5Mb cbq(red)
queue wch_in bandwidth 5Mb cbq(borrow red)
queue annatanska_in bandwidth 5Mb cbq(red)
queue romantanski_in bandwidth 5Mb cbq(red)
queue morfinalaptop_in bandwidth 5Mb cbq(red)
queue accesspointn_in bandwidth 78Mb cbq(borrow red)
queue airosteth_in bandwidth 30Mb cbq(borrow red)
queue amazontveth_in bandwidth 10Mb cbq(red)
queue canonprinter_in bandwidth 1Mb cbq(red)
queue hpprinter_in bandwidth 1Mb cbq(red)
queue wwwserver_in bandwidth 10Mb cbq(borrow red)
queue mailserver_in bandwidth 10Mb cbq(borrow red)
queue gameserver_in bandwidth 10Mb cbq(borrow red)
##############################
# NAT -> LAN #
##############################
nat on $wan_if from $uzytkownicy to any -> ($wan_if)
nat on $wan_if from $lan_if to any -> ($wan_if)
nat on $wan_if from $rockyvm to any -> ($wan_if)
nat on $wan_if from $win2012servervm to any -> ($wan_if)
nat on $wan_if from $ubuntuvm to any -> ($wan_if)
nat on $wan_if from $win2022servervm to any -> ($wan_if)
nat on $wan_if from $virtual to any -> ($wan_if)
#nat on $lan_if inet from ! ($lan_if) to any -> ($lan_if)
##############################
# Redirect LAN -> WAN #
##############################
rdr-anchor miniupnpd
#Serwer Steam [Rocky VM]
#rdr pass on $wan_if inet proto {tcp, udp} from any to any port { 80, 443} -> 10.0.0.2
rdr pass on $wan_if inet proto {tcp, udp} from any to any port { 27015, 27016, 7777 } -> 10.0.0.2
rdr pass on $wan_if inet proto {tcp, udp} from any to any port { 27005, 27020, 51840 } -> 10.0.0.2
#Serwer Steam [Rocky VM] Don't Starve Together
rdr pass on $wan_if inet proto {tcp, udp} from any to any port { 8768, 11000, 27018 } -> 10.0.0.2
#Serwer TeamSpeak [Rocky VM]
rdr pass on $wan_if proto {tcp, udp} from any to any port 9987 -> 10.0.0.2 port 9987
rdr pass on $wan_if proto {tcp, udp} from any to any port 10011 -> 10.0.0.2 port 10011
rdr pass on $wan_if proto {tcp, udp} from any to any port 30033 -> 10.0.0.2 port 30033
#Shell Access [Rocky VM]
rdr pass on $wan_if proto {tcp, udp} from any to any port 2281 -> 10.0.0.2 port 2281
rdr pass on $wan_if proto {tcp, udp} from any to any port 9090 -> 10.0.0.2 port 9090
#Serwer HTTP
rdr pass on $wan_if inet proto {tcp, udp} from any to any port { 80, 443} -> 10.0.0.3
#Battle.net
rdr pass on $wan_if inet proto {tcp, udp} from any to any port 6112 -> 172.16.0.3 port 6112
#Far Cry 3
rdr pass on $wan_if inet proto {tcp, udp} from any to any port { 9000:9010 } -> 172.16.0.3
rdr pass on $wan_if inet proto {tcp, udp} from any to any port { 10009:10010 } -> 172.16.0.3
rdr pass on $wan_if inet proto {tcp, udp} from any to any port { 13000:13200 } -> 172.16.0.3
rdr pass on $wan_if inet proto {tcp, udp} from any to any port { 14000:14010 } -> 172.16.0.3
rdr pass on $wan_if inet proto {tcp, udp} from any to any port { 21000:22000 } -> 172.16.0.3
rdr pass on $wan_if inet proto {tcp, udp} from any to any port 3074 -> 172.16.0.3
##### Dziala na hoscie
#rdr pass on $wan_if inet proto {tcp, udp} from any to any port { 9987, 10011, 30033 } -> 212.159.22.253
#Minecraft Server
rdr pass on $wan_if inet proto {tcp, udp} from any to any port 25565 -> 212.159.22.253 port 25565
##############################
# Firewall #
##############################
pass out all
pass in all
##############################
# AltQ - uzytkownicy #
##############################
pass in on $lan_if inet proto tcp from any to $wan_if port 1723 flags S/SAFR queue (q_normal, q_ack)
pass in on $lan_if inet proto gre from any to $wan_if queue (q_normal, q_ack)
#pass in on $lan_if route-to ($wan_if $my_ip) from any to $my_ip
##############################
# Tagowanie pakietow LAN #
##############################
pass in on $lan_if from 172.16.0.1 to any tag server keep state
pass in on $lan_if from 172.16.0.2 to any tag accesspointac keep state
pass in on $lan_if from 172.16.0.3 to any tag airost keep state
pass in on $lan_if from 172.16.0.4 to any tag airostmobile keep state
pass in on $lan_if from 172.16.0.5 to any tag aszka keep state
pass in on $lan_if from 172.16.0.6 to any tag aszkamobile keep state
pass in on $lan_if from 172.16.0.7 to any tag aszkaipad keep state
pass in on $lan_if from 172.16.0.8 to any tag PS4 keep state
pass in on $lan_if from 172.16.0.9 to any tag amazontv keep state
pass in on $lan_if from 172.16.0.10 to any tag bluray keep state
pass in on $lan_if from 172.16.0.11 to any tag nx6330 keep state
pass in on $lan_if from 172.16.0.12 to any tag aszkamobile7plus keep state
pass in on $lan_if from 172.16.0.13 to any tag airostiphonese keep state
pass in on $lan_if from 172.16.0.21 to any tag vch keep state
pass in on $lan_if from 172.16.0.22 to any tag wch keep state
pass in on $lan_if from 172.16.0.23 to any tag annatanska keep state
pass in on $lan_if from 172.16.0.24 to any tag romantanski keep state
pass in on $lan_if from 172.16.0.25 to any tag morinalaptop keep state
pass in on $lan_if from 172.16.1.2 to any tag accesspointn keep state
pass in on $lan_if from 172.16.0.100 to any tag airosteth keep state
pass in on $lan_if from 172.16.0.109 to any tag amazontveth keep state
pass in on $lan_if from 172.16.0.110 to any tag canonprinter keep state
pass in on $lan_if from 172.16.0.111 to any tag hpprinter keep state
pass in on $lan_if from 10.0.0.1 to any tag wwwserver keep state
pass in on $lan_if from 10.0.0.2 to any tag mailserver keep state
pass in on $lan_if from 172.16.10.2 to any tag gameserver keep state
##############################
# AltQ - Upload #
##############################
pass out on $wan_if all tagged server keep state queue server_out
pass out on $wan_if all tagged accesspointac keep state queue accesspointac_out
pass out on $wan_if all tagged airost keep state queue airost_out
pass out on $wan_if all tagged airostmobile keep state queue airostmobile_out
pass out on $wan_if all tagged aszka keep state queue aszka_out
pass out on $wan_if all tagged aszkamobile keep state queue aszkamobile_out
pass out on $wan_if all tagged aszkaipad keep state queue aszkaipad_out
pass out on $wan_if all tagged PS4 keep state queue PS4_out
pass out on $wan_if all tagged amazontv keep state queue amazontv_out
pass out on $wan_if all tagged bluray keep state queue bluray_out
pass out on $wan_if all tagged nx6330 keep state queue nx6330_out
pass out on $wan_if all tagged aszkamobile7plus keep state queue aszkamobile7plus_out
pass out on $wan_if all tagged airostiphonese keep state queue airostiphonese_out
pass out on $wan_if all tagged vch keep state queue vch_out
pass out on $wan_if all tagged wch keep state queue wch_out
pass out on $wan_if all tagged annatanska keep state queue annatanska_out
pass out on $wan_if all tagged romantanski keep state queue romantanski_out
pass out on $wan_if all tagged morfinalaptop keep state queue morfinalaptop_out
pass out on $wan_if all tagged accesspointn keep state queue accesspointn_out
pass out on $wan_if all tagged airosteth keep state queue airosteth_out
pass out on $wan_if all tagged amazontveth keep state queue amazontveth_out
pass out on $wan_if all tagged canonprinter keep state queue canonprinter_out
pass out on $wan_if all tagged hpprinter keep state queue hpprinter_out
pass out on $wan_if all tagged wwwserver keep state queue wwwserver_out
pass out on $wan_if all tagged mailserver keep state queue mailserver_out
pass out on $wan_if all tagged gameserver keep state queue gameserver_out
##############################
# AltQ - Download #
##############################
pass in on $lan_if all tagged server keep state queue server_in
pass in on $lan_if all tagged accesspointac keep state queue accesspointac_in
pass in on $lan_if all tagged airost keep state queue airost_in
pass in on $lan_if all tagged airostmobile keep state queue airostmobile_in
pass in on $lan_if all tagged aszka keep state queue aszka_in
pass in on $lan_if all tagged aszkamobile keep state queue aszkamobile_in
pass in on $lan_if all tagged aszkaipad keep state queue aszkaipad_in
pass in on $lan_if all tagged PS4 keep state queue PS4_in
pass in on $lan_if all tagged amazontv keep state queue amazontv_in
pass in on $lan_if all tagged bluray keep state queue bluray_in
pass in on $lan_if all tagged nx6330 keep state queue nx6330_in
pass in on $lan_if all tagged aszkamobile7plus keep state queue aszkamobile7plus_in
pass in on $lan_if all tagged airostiphone keep state queue airostiphonese_in
pass in on $lan_if all tagged vch_out keep state queue vch_in
pass in on $lan_if all tagged wch_out keep state queue wch_in
pass in on $lan_if all tagged annatanska keep state queue annatanka_in
pass in on $lan_if all tagged romantanski keep state queue romantanski_in
pass in on $lan_if all tagged morfinalaptop keep state queue morfinalaptop_in
pass in on $lan_if all tagged accesspointn keep state queue accesspointn_in
pass in on $lan_if all tagged airosteth keep state queue airosteth_in
pass in on $lan_if all tagged amazontveth keep state queue amazontveth_in
pass in on $lan_if all tagged canonprinter keep state queue canonprinter_in
pass in on $lan_if all tagged hpprinter keep state queue hpprinter_in
pass in on $lan_if all tagged wwwserver keep state queue wwwserver_in
pass in on $lan_if all tagged mailserver keep state queue mailserver_in
pass in on $lan_if all tagged gameserver keep state queue gameserver_in
##############################
# Blokada portow #
##############################
block in log quick on $wan_if proto tcp from any to any port = 135
block in log quick on $wan_if proto tcp from any to any port = 136
block in log quick on $wan_if proto tcp from any to any port = 137
block in log quick on $wan_if proto tcp from any to any port = 138
block in log quick on $wan_if proto tcp from any to any port = 139
block in log quick on $wan_if proto tcp from any to any port = 445
block in log quick on $wan_if proto tcp from any to any port = 593
block in log quick on $wan_if proto tcp from any to any port = 1024
block in log quick on $wan_if proto tcp from any to any port = 1025
block in log quick on $wan_if proto tcp from any to any port = 1026
block in log quick on $wan_if proto tcp from any to any port = 1027
block in log quick on $wan_if proto tcp from any to any port = 1028
block in log quick on $wan_if proto tcp from any to any port = 1029
block in log quick on $wan_if proto tcp from any to any port = 1030
block in log quick on $lan_if proto tcp from any to any port = 135
block in log quick on $lan_if proto tcp from any to any port = 136
block in log quick on $lan_if proto tcp from any to any port = 137
block in log quick on $lan_if proto tcp from any to any port = 138
block in log quick on $lan_if proto tcp from any to any port = 139
block in log quick on $lan_if proto tcp from any to any port = 445
block in log quick on $lan_if proto tcp from any to any port = 593
block in log quick on $lan_if proto tcp from any to any port = 1024
block in log quick on $lan_if proto tcp from any to any port = 1025
block in log quick on $lan_if proto tcp from any to any port = 1026
block in log quick on $lan_if proto tcp from any to any port = 1027
block in log quick on $lan_if proto tcp from any to any port = 1028
block in log quick on $lan_if proto tcp from any to any port = 1029
block in log quick on $lan_if proto tcp from any to any port = 1030