From owner-freebsd-ipfw@FreeBSD.ORG Fri Apr 7 17:58:17 2006 Return-Path: X-Original-To: ipfw@freebsd.org Delivered-To: freebsd-ipfw@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 32B2A16A400 for ; Fri, 7 Apr 2006 17:58:17 +0000 (UTC) (envelope-from lists@jnielsen.net) Received: from ns1.jnielsen.net (ns1.jnielsen.net [69.55.238.237]) by mx1.FreeBSD.org (Postfix) with ESMTP id E4A9343D46 for ; Fri, 7 Apr 2006 17:58:16 +0000 (GMT) (envelope-from lists@jnielsen.net) Received: from localhost (jn@ns1 [69.55.238.237]) (authenticated bits=0) by ns1.jnielsen.net (8.12.9p2/8.12.9) with ESMTP id k37HwEVP055585 for ; Fri, 7 Apr 2006 10:58:16 -0700 (PDT) (envelope-from lists@jnielsen.net) From: John Nielsen To: ipfw@freebsd.org Date: Fri, 7 Apr 2006 13:57:27 -0400 User-Agent: KMail/1.9.1 X-Face: #X5#Y*q>F:]zT!DegL3z5Xo'^MN[$8k\[4^3rN~wm=s=Uw(sW}R?3b^*f1Wu*. X-Virus-Scanned: ClamAV version 0.88, clamav-milter version 0.87 on ns1.jnielsen.net X-Virus-Status: Clean Cc: Subject: Notes on using dummynet with if_bridge X-BeenThere: freebsd-ipfw@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: IPFW Technical Discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Apr 2006 17:58:17 -0000 I spent some time yesterday figuring out how to use dummynet and if_bridge (on a FreeBSD 6.x system) together to create a standalone rate-limiting device for simulating various types of links. I had some trouble and started to write a message asking for guidance, but was able to solve my problem as a result of describing it clearly. So I'm posting my setup as a reference for anyone else in the same situation. (I admit to being self-serving by doing so, since I'll inevitably want this information again in the future when I don't have access to the system I'm working on currently.) Comments are welcome but not needed (i.e. "it works"). ### From the kernel config: options IPFIREWALL options DUMMYNET ### From /boot/loader.conf: if_bridge_load="YES" ### From /etc/sysctl.conf net.inet.ip.fw.one_pass=0 net.link.bridge.ipfw=1 # values below are defaults, included for reference #net.inet.ip.fw.enable=1 #net.link.ether.ipfw=0 #net.link.bridge.pfil_member=0 #net.link.bridge.pfil_bridge=0 #net.link.bridge.pfil_onlyip=0 ### From /etc/rc.conf: ifconfig_rl0="DHCP" # Admin interface ifconfig_fxp0="up" # "Client" side ifconfig_xl0="up" # "Server" side cloned_interfaces="bridge0" ifconfig_bridge0="addm fxp0 addm xl0 up" firewall_enable="YES" firewall_script="/etc/rc.firewall.jcn" ### /etc/rc.firewall.jcn #!/bin/sh ipfw -q /etc/ipfw.conf ### /etc/ipfw.conf # flush old rules, queues and pipes. flush queue flush pipe flush # server->clients pipe 1 config bw 30Kbit/s delay 150 mask dst-ip 0xffffffff # clients->server pipe 2 config bw 30Kbit/s delay 150 mask src-ip 0xffffffff # Localhost add allow all from any to any via lo0 add deny all from any to 127.0.0.0/8 add deny all from 127.0.0.0/8 to any # Admin interface add skipto 60000 all from any to any via rl0 # server->clients add pipe 1 all from any to any out recv xl0 add skipto 60000 all from any to any out recv xl0 # clients->server add pipe 2 all from any to any out xmit xl0 add skipto 60000 all from any to any out xmit xl0 # Allow everything through add 60000 allow all from any to any ### Simple, no? :) JN