Skip to content

Commit 5d8c0ea

Browse files
committed
ipfw: Add option for firewall_type to be a directory
If specified, this will run rcorder over a directory. A small subset of examples is also provided Signed-off-by: Dan Mahoney <[email protected]>
1 parent 393356f commit 5d8c0ea

File tree

8 files changed

+105
-1
lines changed

8 files changed

+105
-1
lines changed

libexec/rc/rc.firewall

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,16 @@ case ${firewall_type} in
547547
;;
548548
*)
549549
if [ -r "${firewall_type}" ]; then
550-
${fwcmd} ${firewall_flags} ${firewall_type}
550+
if [ -f "${firewall_type}" ]; then
551+
${fwcmd} ${firewall_flags} ${firewall_type}
552+
else
553+
if [ -d "${firewall_type}" ]; then
554+
for fwfile in `rcorder $firewall_type/*`
555+
do
556+
ipfw -q $fwfile;
557+
done
558+
fi
559+
fi
551560
fi
552561
;;
553562
esac

share/examples/ipfw.d/final

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#
2+
# PROVIDE: final
3+
# REQUIRE: setup services outbound routing
4+
#
5+
6+
#
7+
add allow tcp from me to any out setup // default outbound
8+
9+
# silently ignore local multicast
10+
add deny ip from any to 224.0.0.0/4 // drop multicast
11+
12+
# drop and log everything else
13+
add reset log ip from any to any

share/examples/ipfw.d/ntp_client

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# REQUIRE: outbound
2+
# PROVIDE: ntp_client ntp_servers
3+
# BEFORE: final
4+
5+
table ntp_servers create
6+
7+
# Uncomment and your NTP servers (if they are on known ips in your network) to the following table:
8+
9+
# table ntp_servers add x.x.x.x
10+
11+
add allow ip from me to table(ntp_servers) 123 keep-state // NTP outbound

share/examples/ipfw.d/outbound

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#
2+
# REQUIRE: services
3+
# PROVIDE: outbound
4+
# BEFORE: final
5+
#
6+
# meta class - adds no rules

share/examples/ipfw.d/routing

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#
2+
# REQUIRE: setup
3+
# PROVIDE: routing
4+
# BEFORE: services
5+
#
6+
# meta class - adds no rules

share/examples/ipfw.d/services

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# REQUIRE: setup routing
2+
# PROVIDE: services
3+
# BEFORE: outbound
4+
#
5+
# meta class - adds no rules

share/examples/ipfw.d/setup

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#
2+
# PROVIDE: setup blocked bogons
3+
# BEFORE: services routing outbound final
4+
#
5+
6+
# remove all existing tables
7+
table all destroy
8+
table blocked create
9+
10+
# standard (non-service specific) tables
11+
table bogons create
12+
table bogons add 0.0.0.0/8
13+
table bogons add 10.0.0.0/8
14+
table bogons add 172.12.0.0/12
15+
table bogons add 192.168.0.0/16
16+
table bogons add 169.254.0.0/16
17+
table bogons add 240.0.0.0/4
18+
19+
# permit existing TCP sessions
20+
add allow tcp from any to any established
21+
22+
# permit internal loopback traffic
23+
add allow ip from any to any via lo0
24+
add allow ip from any to any via lo1
25+
26+
# deny directed loopback traffic
27+
add deny ip from any to 127.0.0.0/8 in
28+
add deny ip from any to ::/64 in
29+
30+
# deny unexpected sources
31+
add deny ip from table(bogons) to me in // unexpected sources
32+
33+
# deny explicitly disabled (non-persistent) sources
34+
add deny ip from table(blocked) to me in // emergency (non-persistent) blocklist
35+
36+
# allow bsd-standard-port traceroutes
37+
add allow udp from me to any 33434-33600 // traceroute in
38+
add allow udp from any to me 33434-33600 // traceroute out
39+
40+
# moderately permissive ICMPv4
41+
add allow icmp from any to any icmptypes 0,3,8,11,13,14 // safe ICMPv4
42+
43+
# link-local ICMPv6 (RS, RA, NS, NA) - per FreeBSD standard rules
44+
add allow ipv6-icmp from :: to fe80::/10 // ICMPv6 DAD
45+
add allow ipv6-icmp from fe80::/10 to fe80::/10 // ICMPv6 NDP
46+
add allow ipv6-icmp from fe80::/10 to ff02::/16 // ICMPv6 NDP
47+
add allow ipv6-icmp from any to any icmp6types 1,2,3,128,129,135,136 // safe ICMPv6

share/examples/ipfw.d/ssh_service

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# REQUIRE: services
2+
# PROVIDE: ssh_service ssh_clients
3+
# BEFORE: outbound
4+
5+
table ssh_clients create
6+
7+
add allow tcp from table(ssh_clients) to me 22 in setup // inbound SSH

0 commit comments

Comments
 (0)