Networking is a fundamental part of systems administration and maintaining a reliable, secure network is key.  On Monday morning, Jason Faulkner of Rackspace taught a new training session all about maintaining a secure network, primarily by focusing on firewall rules.  Of course, we started out with a review of basic networking concepts like the OSI model and some differences between IPv4 and IPv6.

Most admins have some degree of familiarity with the net-tools suite of programs, which includes old favorites like ifconfig, route, and netstat.  However, there's a newer package called iproute2 which combines much of the net-tools functionality into a single command: ip.  The ip command supports CIDR notation and permits shortening of command arguments.  Additionally, the iproute suite supports many more features that net-tools does not.

One early focus of the discussion was the current "good practices" of firewall design.  Many people tend to design their network like a truffle, focusing on creating a hard exterior but leaving the inside chewy.  This leaves hosts vulnerable to compromised hosts inside the perimeter.  A firewall is only as secure as its weakest entry point, and that's often the human.  Good practices consider both the security and performance of the system, but Jason instructed the audience to "never, ever sacrifice maintainability and auditability for the sake of optimization."

To optimize the performance of firewall rules, the idea is to use an inverted pyramid.  It doesn't matter how many firewall rules there are if most packets don't traverse them.  The idea is to catch as many "bad" packets in the first few passes.   The default rule should be to drop packets, then allow the most exact match possible. In addition to configuration, the "good practices" also include the documentation of all changes, regular audits to remove legacy rules, and checking to ensure allowed packets are being passed as expected.

iptables matches are done based on the current state of a packet, so if a packet is munged in the PREROUTING chain (e.g in NAT forwarding), rules it would match as it hits the NIC would not be matched when it reaches the firewall rules. 

Generic matches  don’t require specific modules, and so are best to use first. Implicit matches are protocol based (tcp, udp, icmp, etc) and provide more flexibility than generic matches. Explicit matches are most expensive, and generally require a specific module.  Explicit matches can be used to do MAC address blacklisting, can match on UID and GID of the user in OUTPUT chain, and can do many other complicated and powerful actions.

This tutorial also provided an example of the benefit that teaching a LISA training can provide.  Jason attended the Wireshark tutorial on Monday morning and learned about the tshark command.  He expressed regret that he didn't know about it before making his slides, because he would never have referenced tcpdump.

LISA attendees interested in learning more about firewalls can attend the Refereed Papers session at 2pm Wednesday.