How to build a simple FreeBSD WAN simulator

  1. Edit /etc/ipfw.rules and add the following lines:
    pipe 1 config bw 1000KBit/s delay 100 plr 0.05
    add pipe 1 all from not me to not me in
    add allow all from any to any
    
    This limits any traffic traversing your machine to 1 MBit per second, adds a 100 ms delay (ping will show a 200 ms round trip time if you use your FreeBSD box as a router), and drops 5% of all packets.
  2. Enable dummynet(4) at boot time:
    echo 'dummynet_enable="YES"' >> /etc/rc.conf
    
  3. Enable firewalling at boot time:
    echo 'firewall_enable="YES"' >> /etc/rc.conf
    echo 'firewall_type="/etc/ipfw.rules"' >> /etc/rc.conf
    
  4. Enable ip forwarding at boot time:
    echo 'gateway_enable="YES"' >> /etc/rc.conf
    
  5. Either reboot your FreeBSD box, or reload your firewall rules manually:
    /etc/rc.d/ipfw restart