All pastes #478785 Raw Edit

Untitled

public text v1 · immutable
·published 2007-05-09 11:22 UTC
rendered paste body
#!/bin/sh

# commonly used things
fw="ipfw -q add"
if_ext="bge0"
if_int="bge1"
skip="skipto 30000"

# flush all existing rules
ipfw -q -f flush

# allow things that are always "safe": local network (if_int) and loopback
$fw 100 allow all from any to any via $if_int
$fw 200 allow all from any to any via lo0

# nat if the packet is coming in
$fw 1000 divert natd ip from any to any in via $if_ext

# allow packets from previous dynamic rules
$fw 1500 check-state

# allow all outbound connections
$fw 2000 $skip tcp from any to any out via $if_ext setup keep-state

# allow incoming connections for port 2345
$fw 3010 $skip tcp from any to any 2345 in via $if_ext

# reject all unauthorized incoming
$fw 15000 deny log all from any to any in via $if_ext

# skipto for outbound stateful
$fw 30000 divert natd ip from any to any out via $if_ext
$fw 30001 allow ip from any to any

# deny everything else
$fw 44444 deny log all from any to any