FreeBSD 9.1 – virtual wan simulator „WANsim“

FreeBSD_logo   For a experiment I needed a wan simulator so I decided to build one – using FreeBSD makes this very easy. Specifically what I wanted was a vmware virtual machine capable of Layer 2 wan Simulation it is easier because theres no routing or subnet changes to mess around with just simply a single subnet with some hosts further away than others. It had to be a VM as my whole lab environment is virtual so it makes sense to just put a vm between 2 vswitches and get the restricted bandwidth increased latency and packet loss

FreeBSD_WANsim_01

/etc/rc.conf

hostname=“WANsim“
keymap=“german.iso.kbd“
sshd_enable=“YES“
dumpdev=“AUTO“

#Bridge
cloned_interfaces=“bridge0″
ifconfig_bridge0=“addm em0 addm em1 up“
ifconfig_em0=“up“
ifconfig_em1=“up“
ifconfig_bridge0_alias0=“inet 192.168.1.253 netmask 255.255.255.0 up“

#Firewall
firewall_enable=“YES“
firewall_type=“open“
firewall_logging=“YES“
firewall_script=“/usr/local/etc/ipfw.rules“

 

/usr/local/etc/ipfw.rules

# delete all rules
# —————————————

ipfw -q -flush

# em0 3MBit/s and 20ms latency
# em1 0.5MBit/s and 20ms latency
# —————————————

ipfw -q add 10001 pipe 1 ip from any to any out via em0 bridged
ipfw -q add 10002 pipe 2 ip from any to any out via em1 bridged
ipfw -q pipe 1 config bw 3072Kbit/s delay 20
ipfw -q pipe 2 config bw 512Kbit/s delay 20

 

/etc/sysctl.conf

net.link.bridge.ipfw=1

 

/boot/loader.conf
if_bridge_load=“YES“
dummynet_load=“YES“

Placing the guest’s network adapter in promiscuous mode causes it to receive all frames passed on the virtual switch that are allowed under the VLAN policy for the associated portgroup

Leave a Reply

You must be logged in to post a comment.