# *nix Networking Tools Cheat Sheet ## Packet and Firewall filtering ### pfctl + dnctl (MacOSX Yosemite+) ``` (cat /etc/pf.conf && echo "dummynet-anchor \"mop\"" && echo "anchor \"mop\"") | sudo pfctl -f - echo "dummynet in quick proto tcp from any to any port 5001 pipe 1" | sudo pfctl -a mop -f - sudo dnctl pipe 1 config bw 1Mbit/s ``` To undo... ``` sudo dnctl -q flush sudo pfctl -f /etc/pf.conf ``` Observe traffic is now shaped to 100Mbit/s: ``` iperf -s -D # Run as Daemon (-D) iperf -c localhost -t 5 ``` > ------------------------------------------------------------ > Client connecting to localhost, TCP port 5001 > TCP window size: 144 KByte (default) > ------------------------------------------------------------ > [ 5] local 127.0.0.1 port 59573 connected with 127.0.0.1 port 5001 > [ ID] Interval Transfer Bandwidth > [ 5] 0.0- 5.0 sec 60.5 MBytes 101 Mbits/sec ### ipfw (FreeBSD/OpenBSD) ### iptables (Linux) ## Network Performance ### iperf (all) I perf Setup the server: ``` iperf -s ``` Run the client against the server for 7 seconds: ``` iperf -c localhost -t 7 ``` You should get a throughput in (GMk)bits/sec ## Links * https://gist.github.com/tracphil/4353170 *