Advertisement
psychozoic

Untitled

Jul 24th, 2013
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 5.99 KB | None | 0 0
  1. ### Interfaces ###
  2.  ext ="vr0"
  3.  int ="ale0"
  4. localnet = $int:network
  5.  
  6. ### Hosts ###
  7.  Windows ="192.168.1.33"
  8.  Xbox360 ="192.168.1.4"
  9.  phone   ="192.168.1.5"
  10.  WorkSsh ="107.21.121.234"
  11.  
  12.  webserver = "127.0.0.1"
  13.  
  14.  mail_smtp = "192.168.1.250"
  15.  devcenter = "192.168.2.222"
  16.  
  17. ### Ports ###
  18.  
  19. web_ports = "{ http, https }"
  20. ssh_ports = "{ ssh, 10022 }"
  21.  
  22.  
  23. ### Queues, States and Types ###
  24.  IcmpPing ="icmp-type 8 code 0"
  25.  SshQueue ="(ssh_bulk, ssh_login)"
  26.  SynState ="flags S/SA synproxy state"
  27.  TcpState ="flags S/SA modulate state"
  28.  UdpState ="keep state"
  29.  
  30. ### Stateful Tracking Options (STO) ###
  31.  OpenSTO ="(max 90000, source-track rule, max-src-conn 1000, max-src-nodes 256)"
  32.  SmtpSTO ="(max   200, source-track rule, max-src-conn   10, max-src-nodes 256, max-src-conn-rate 200/30)"
  33.  SshSTO  ="(max   100, source-track rule, max-src-conn   10, max-src-nodes 100, max-src-conn-rate 100/30,  overload <BLOCKTEMP> flush global)"
  34.  WebSTO  ="(max  4096, source-track rule, max-src-conn   64, max-src-nodes 512, max-src-conn-rate 500/100, overload <BLOCKTEMP> flush global)"
  35.  
  36. ### Tables ###
  37.  table <BLOCKTEMP> counters
  38.  table <BLOCKPERM> counters #file "/somedir/block_permanent"
  39.  table <spamd-white>
  40.  
  41. ################ Options ######################################################
  42. ### Misc Options
  43.  set skip on lo0
  44.  set debug urgent
  45.  set block-policy drop
  46.  set loginterface $ext
  47.  set state-policy if-bound
  48.  set fingerprints "/etc/pf.os"
  49.  set ruleset-optimization none
  50.  
  51. ### Timeout Options
  52.  set optimization normal
  53.  set timeout { tcp.closing 60, tcp.established 7200}
  54.  
  55. ################ Queueing ####################################################
  56. # no quality of service (QOS) since it is not supported by the myricom 10gig
  57. # vr0 interface drivers and we would lose as much as 10% bandwidth anyways.
  58. # for more information: https://calomel.org/pf_hfsc.html
  59.  
  60. ################ Normalization ###############################################
  61. scrub out log on $ext all random-id set-tos 0x04 fragment reassemble
  62. scrub     log on $ext all reassemble tcp fragment reassemble
  63.  
  64. ################ Translation #################################################
  65. ### NAT and Redirection rules are first match
  66.  
  67. # NAT with static NAT for the XBOX360
  68.  nat on $ext from $localnet to any -> ($ext)
  69.  
  70. # Apache or Nginx (external users to an internal server?)
  71.  rdr on $ext inet proto tcp from  !($ext) to ($ext) port $web_ports -> $webserver
  72.  
  73. # OpenSMTPD or Postfix with Spamd
  74.  rdr on $ext inet proto tcp from  any to ($ext) port smtp -> $mail_smtp
  75.  
  76. # Openssh
  77.  rdr on {$ext, $int} inet proto tcp from any to any port 10022 -> lo0
  78.  rdr on {$ext, $int} inet proto tcp from any to any port 22 -> $devcenter
  79.  
  80. # Apache or Nginx (internal webserver for the LAN to localhost?)
  81.  rdr on $int inet proto tcp from  !($int) to ($int) port $web_ports  -> lo0
  82.  
  83. # Bind or Unbound DNS for LAN machines
  84.  rdr on $int inet proto udp from $localnet to $int port domain -> lo0
  85.  
  86. # Ntpd time server for the LAN
  87.  rdr on $int inet proto udp from $localnet to $int port ntp -> lo0
  88.  
  89. # Anchors
  90. # rdr-anchor "games"
  91.  
  92. # Ftp ( secure ftp-proxy for the internal LAN )
  93.  nat-anchor "ftp-proxy/*"
  94.  rdr-anchor "ftp-proxy/*"
  95.  rdr pass on $int proto tcp from $localnet to any port 21 -> 127.0.0.1 port 8021
  96.  
  97. # DENY rouge redirection
  98.  no rdr
  99.  
  100. ################ Filtering ###################################################
  101. # Rules are best (closest) match. Notice we optimized the rules so external
  102. # interface parsing is first followed by the internal interface.
  103.  
  104. ### $ext block abusive hosts in temp and perm tables
  105. # block drop in  log quick on $ext           from <BLOCKPERM> to any
  106. # block drop in  log quick on $ext proto udp from <BLOCKTEMP> to any
  107. # block drop in  log quick on $ext proto tcp from <BLOCKTEMP> to any port != ssh
  108. # block drop in  log quick on $ext proto tcp from <BLOCKTEMP> to any port != 10022
  109.  
  110. ### $ext default block with drop
  111.  block all
  112. # block drop in log on $ext
  113.  
  114. ### $ext inbound
  115.  pass in log on $ext inet proto tcp  from !($ext)      to $webserver port $web_ports $TcpState $WebSTO
  116. # pass in log on $ext inet proto tcp  from !($ext)      to $webserver port www   $TcpState $WebSTO
  117.  pass in log on $ext inet proto tcp  from  !($ext) to $mail_smtp port smtp  $TcpState $SmtpSTO
  118.  #pass in log on $ext inet proto tcp  from !<spamd-white> to 10.10.10.200 port spamd $TcpState $SmtpSTO
  119.  
  120.  pass in log on $ext inet proto tcp  from  any      to lo0 port 10022   $TcpState $SshSTO
  121.  pass in log on $ext inet proto tcp  from  any      to $devcenter port ssh   $TcpState $SshSTO
  122.  
  123. ### $ext outbound
  124.  pass out log on $ext inet proto tcp  from ($ext) to !($ext) $TcpState $OpenSTO
  125.  pass out log on $ext inet proto udp  from ($ext) to !($ext) $UdpState $OpenSTO
  126.  pass out log on $ext inet proto icmp from ($ext) to !($ext) $UdpState $OpenSTO
  127.  
  128. ### $int default block with return (TCP reset)
  129.  block return in log on $int inet
  130.  
  131. ### $int inbound (restrict LAN clients to external machines here)
  132. # pass in log on $int inet proto tcp  from  $localnet to  any     port https  $TcpState $OpenSTO
  133.  pass in log on $int inet proto tcp  from  $localnet to  any     port $web_ports    $TcpState $OpenSTO
  134.  
  135.  pass in log on $int inet proto tcp  from  any       to  lo0     port 10022   $TcpState $OpenSTO
  136.  pass in log on $int inet proto tcp  from  any       to  $devcenter     port ssh    $TcpState $OpenSTO
  137.  pass in log on $int inet proto udp  from  $localnet to  lo0     port domain $UdpState $OpenSTO
  138.  pass in log on $int inet proto udp  from  $localnet to  lo0     port ntp    $UdpState $OpenSTO
  139.  pass in log on $int inet proto icmp from  $localnet to $int  $IcmpPing   $UdpState $OpenSTO
  140.  
  141. ### $int ftp secure secure proxy for LAN
  142.  anchor "ftp-proxy/*" in on $int inet proto tcp
  143.  
  144. ### $int outbound
  145.  pass out log on $int inet proto tcp  from $int to $localnet $TcpState
  146.  pass out log on $int inet proto udp  from $int to $localnet $UdpState
  147.  pass out log on $int inet proto icmp from $int to $localnet $UdpState
  148.  
  149. #allow devcenter
  150. pass out proto tcp to port ssh
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement