Building A Home Firewall-Router Using Openbsd-Sparc
Building A Home Firewall-Router Using Openbsd-Sparc
Sun Hardware
SunOS / Solaris
(ugh)
OpenBSD (best OS for sparc HW very will ported) NetBSD (sparc32 port) Linux (SuSE, older Red-Hat, Debian)
Expansion
SCSI (almost every Sun box has it on-board) S-bus (network cards, extra SCSI busses, framebuffers)
Framebuffer is like video card for Sun but not necessary; you can use serial console and run headless!
(some machines)
M-bus CPU modules available on ebay and other places Only NetBSD-2 and Linux can utilize multiple CPUs
S-bus is 25 Mhz
Sun Sparcstation LX
RAM: up to 96MB (I'm using 48) 1 internal SCSI HD (I have a 1GB Seagate) On-board 10 base-T ethernet On-board Cgsix framebuffer
Typographic conventions
<italic in angle> - Parameter replace with your specific value {values|in|braces} - Choices for a value choose one [square brackets] Fixed type - Optional item - Command or line for a file literal
OpenBSD
www.openbsd.org
Heavily crypto-oriented
Installing OpenBSD-sparc
2 types of serial ports: DB-25 and mini DIN-8 DB25 is actually 2 serial ports in one
Configuring OpenBSD
/etc/hostname.<ifname>
Per-interface network configuration Format: inet <IP> <mask> [<bcast>] [<options>] For DHCP: 'dhcp NONE NONE NONE'
/etc/mygate
/etc/myname
System hostname
/etc/ppp.conf
External Interface
pppoe: set device "!/usr/sbin/pppoe -i le1" disable acfcomp protocomp deny acfcomp set mtu max 1492 set speed sync enable lqr set lqrperiod 5 set cd 5 set dial set login set timeout 0 set authname <username> set authkey <password> add! default HISADDR enable dns enable mssfixup
default: set log Phase Chat IPCP CCP tun command set redial 15 0 set reconnect 15 10000
NAT Basics
Network Address Translation Firewall translates the internal private IPs into an assigned public one Also called IP 'Masquerading' Hides the internal IP space and the internal hosts.
10.0.0.1
PF Basics
/etc/rc.conf
pf=YES
/etc/pf.rules
/etc/sysctl.conf
net.inet.ip.forwarding=1
PF Basics
Turn on/off
Load/flush rules
Load rules: 'pfctl -f <filename>' Flush filter rules: 'pfctl -F rules' Flush nat rules: 'pfctl -F nat' Flush state table: 'pfctl -F state'
(Same as IPF)
PF Configuration
{block|pass} [{in|out}] [quick] [on <if>] [inet] [proto {tcp| udp}] from <source> to <dest> [keep state]
'quick' apply this rule and stop checking the rule list inet: must be specified for some proto's (icmp) source/dest can be IP or network in CIDR notation source/dest can have 'port #' after them 'keep state' adds connection to the state table and expects a reply to the conversation
PF Configuration
Blocking options:
drop (the default): Do nothing, just ignore the packet return: Return a TCP RST or ICMP UNREACH depending on type return-rst: Return TCP RST only use for proto tcp return-icmp: Return ICMP UNREACH only use for proto udp
PF Configuration
NAT
ADDR is address to nat to; if you have dynamic IP, use '(<if>)'
Port Forwarding
rdr on <input interface> proto {tcp|udp} from any to <IP> port <portnum> -> <internal address>
rdr on le1 proto tcp from any to any port 80 -> 10.0.0.45
Advanced PF Syntax
Macros!
RFC1918 = "{ 192.168.0.0/16, 172.16.0.0/12, 10.0.0.0/8 } block in quick on $EXT from $RFC1918 to any
Packet scrubbing
De-fragment packets before passing them; protect machines from fragment attacks (DOS, etc.) scrub {in|out}
Antispoof
Drop packets that arrive on the wrong interface antispoof for <interface>
pass quick on lo0 all pass in quick on $INT from $lannet to any pass out quick on $INT from any to $lannet block in quick on $EXT from $RFC1918 to any # Accept pings pass in on $EXT inet proto icmp all icmp-type echoreq keep state pass out on $EXT proto tcp keep state flags S/SA pass out on $EXT proto { udp, icmp } keep state
Debugging Rulesets
No equivalent to 'ipmon' for pf Use 'tcpdump' to view pf logs:
n don't resolve Ips to hostnames, etc. e print link-level header info ttt print human-readable timestamp
Debugging Rulesets
Example: Telnet blocked
$> tcpdump -n -e -ttt -i pflog0 tcpdump: WARNING: pflog0: no IPv4 address assigned tcpdump: listening on pflog0 Jul 26 15:33:59.568436 rule 8/0(match): block in on le0: 10.0.8.100.32778 > 10.0.8.1.23: S 701220195:701220195(0) win 5840 <mss 1460,sackOK,timestamp[|tcp]> (DF) [tos 0x10] Jul 26 15:34:02.565304 rule 8/0(match): block in on le0: 10.0.8.100.32778 > 10.0.8.1.23: S 701220195:701220195(0) win 5840 <mss 1460,sackOK,timestamp[|tcp]> (DF) [tos 0x10] ^C 2 packets received by filter 0 packets dropped by kernel
Debugging Rulesets
Example: Telnet blocked
0 1 2 3 4 5 6 7 8 $> pfctl -s rules block drop in on ! le0 inet from 10.0.8.0/24 to any block drop in inet from 10.0.8.1 to any block drop in on le0 inet6 from fe80::a00:20ff:fe1d:d663 to any block drop log all block drop in log all block return-rst in log on le1 proto tcp all pass quick on lo0 all pass in on le1 inet proto icmp all icmp-type echoreq keep state block drop in log quick on le0 proto tcp from any to any port = telnet pass in quick on le0 inet from 10.0.8.0/24 to any pass out quick on le0 inet from any to 10.0.8.0/24 block drop in log quick on le1 inet from 172.16.0.0/12 to any block drop in log quick on le1 inet from 10.0.0.0/8 to any pass out on le1 proto tcp all flags S/SA keep state pass out on le1 proto udp all keep state pass out on le1 proto icmp all keep state
Adding DHCP
Allows computers to auto-configure network
/etc/dhcpd.interfaces
just list the name of the INTERNAL interface (le0, rl1, etc.)
/etc/dhcpd.conf /etc/rc.conf
dhcpd_flags='-q'
subnet 10.0.0.0 netmask 255.255.255.0 { option routers 10.0.0.1; range 10.0.0.30 10.0.0.250; } }
Good idea not to use a resolvable domain name for private network
pass in quick on le0 proto udp from any port 67 to any port 68 keep state
pass out quick on le1 proto udp from 0.0.0.0 to 255.255.255.255 port 67 keep state
/var/named
etc/named.conf ( etc/named-simple.conf )
Dynamic DNS
Allows you to have a forward DNS record even if you don't have a static IP! Providers:
Client on the firewall sends DDNS update to the provider to register your new IP every time it changes.
DDNS Clients
ddclient (linux.cudeso.be/linuxdoc/ddclient.php)
perl
ipcheck
(ipcheck.sourceforge.net)
python
www.openbsd.org/ports.html
Resources
Sun, Sun Microsystems and the Sun logo are trademarks of Sun Microsystems, Inc. The OpenBSD logo is a trademark of the OpenBSD project.