Guest User

Untitled

a guest
May 27th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.06 KB | None | 0 0
  1. # $OpenBSD: pf.conf,v 1.37 2008/05/09 06:04:08 reyk Exp $
  2. #
  3. # See pf.conf(5) for syntax and examples.
  4. # Remember to set net.inet.ip.forwarding=1 and/or net.inet6.ip6.forwarding=1
  5. # in /etc/sysctl.conf if packets are to be forwarded between interfaces.
  6.  
  7. # Macros: define common values, so they can be referenced and changed easily.
  8. ext_if="sk0" # replace with actual external interface name i.e., dc0
  9. vpn_if="nfe0"
  10. int_if="em0" # replace with actual internal interface name i.e., dc1
  11. vpn_gw="192.168.0.1"
  12. ext_gw="192.168.10.1"
  13.  
  14. tcp_services = "{ 22, 113 }"
  15. icmp_types = "echoreq"
  16.  
  17. priv_nets = "{ 127.0.0.0/8, 192.168.1.0/16, 172.16.0.0/12, 10.0.0.0/8 }"
  18. local_net = "192.168.6.0/24"
  19.  
  20. postfix = "192.168.0.2"
  21. wall = "192.168.6.6"
  22. server = "192.168.6.8"
  23.  
  24. wall_allowed_ports = "{ 22, 443 }"
  25. postfix_allowed_ports = "{ 25, 10025 }"
  26.  
  27. #
  28. # options
  29. #
  30. set block-policy drop
  31. set loginterface $ext_if
  32. #set state-policy if-bound
  33.  
  34. #
  35. # scrub
  36. #
  37. scrub in all
  38.  
  39. #
  40. # nat/rdr
  41. #
  42. nat on $ext_if from $local_net to any -> ($ext_if)
  43. nat on $vpn_if from $local_net to any -> ($vpn_if)
  44.  
  45. nat-anchor "ftp-proxy/*"
  46. rdr-anchor "ftp-proxy/*"
  47. rdr on $int_if proto tcp from any to any port 21 -> 127.0.0.1 port 8021
  48.  
  49. # moving services to the boxes receiving them
  50. rdr on $ext_if proto tcp from any to any port 22 -> $wall port 22
  51. rdr on $vpn_if proto tcp from any to any port 22 -> $wall port 22
  52. rdr on $vpn_if proto tcp from any to any port 443 -> $wall port 443
  53. rdr on $vpn_if proto tcp from any to any port 25 -> $postfix port 25
  54. rdr on $int_if proto tcp from $server to $postfix port 25 -> $postfix port 10025
  55.  
  56. #
  57. # filter rules
  58. #
  59. block log on $ext_if all
  60. block log on $vpn_if all
  61.  
  62. anchor "ftp-proxy/*"
  63.  
  64. pass quick on lo0 all
  65.  
  66. # block drop in log quick on $ext_if from $priv_nets to any
  67. # block drop out log quick on $ext_if from any to $priv_nets
  68.  
  69. # pass in inet proto icmp all icmp-type $icmp_types
  70.  
  71. pass in on $int_if from $int_if:network to any
  72. pass out on $int_if from any to $int_if:network
  73.  
  74. #send all traffic from the server out vpn_if
  75. pass in log on $int_if route-to ($vpn_if $vpn_gw) proto tcp from $server to !$local_net flags S/SA modulate state
  76. pass in log on $int_if route-to ($vpn_if $vpn_gw) proto { udp, icmp } from $server to !$local_net
  77.  
  78. pass out log on $ext_if proto tcp from !$vpn_if to any modulate state flags S/SA
  79. pass out log on $ext_if proto { udp, icmp } from !$vpn_if to any
  80.  
  81. pass out log on $vpn_if proto tcp from !$ext_if to any modulate state flags S/SA
  82. pass out log on $vpn_if proto { udp, icmp } from !$ext_if to any
  83.  
  84. #
  85. # site specific
  86. # here we allow for the services defined above
  87. #
  88. pass in log on $ext_if inet proto tcp from any to $wall port $wall_allowed_ports flags S/SA
  89. pass in log on $vpn_if reply-to ($vpn_if $vpn_gw) inet proto tcp from any to $wall port $wall_allowed_ports flags S/SA keep state
  90.  
  91. pass in log on $vpn_if reply-to ($vpn_if $vpn_gw) inet proto tcp from any to $postfix port $postfix_allowed_ports flags S/SA keep state
  92. pass in log on $int_if inet proto tcp from any to $postfix port $postfix_allowed_ports flags S/SA keep state
  93.  
  94. #
  95. # OPENVPN
  96. #
  97. pass in log on $vpn_if reply-to ($vpn_if $vpn_gw) proto { tcp, udp } from any to any port 1194
  98. pass out log on $vpn_if route-to ($vpn_if $vpn_gw) proto { tcp, udp } from any port 1194 to any
  99.  
  100. #
  101. # SSL Web Proxy
  102. #
  103. #pass out quick log on $ext_if route-to ($vpn_if $vpn_gw) inet proto tcp from $wall port 443 to any
  104. #pass out quick log on $ext_if route-to ($vpn_if $vpn_gw) inet proto tcp from $wall port 1194 to any
  105.  
  106. #smtp rule
  107. #pass out quick log on $ext_if route-to ($vpn_if $vpn_gw) proto tcp from $ext_if to any port 25 flags S/SA keep state
  108.  
  109. #
  110. # handle both interfaces
  111. #
  112. pass out quick log on $ext_if route-to ($vpn_if $vpn_gw) from $vpn_if to any
  113. pass out quick log on $vpn_if route-to ($ext_if $ext_gw) from $ext_if to any
  114. pass out quick log on $vpn_if route-to ($vpn_if $vpn_gw) proto { tcp, udp } from any port 1194 to any
Add Comment
Please, Sign In to add comment