From owner-freebsd-net@FreeBSD.ORG Tue Sep 29 06:50:09 2009 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5E240106568F for ; Tue, 29 Sep 2009 06:50:09 +0000 (UTC) (envelope-from bakul@bitblocks.com) Received: from mail.bitblocks.com (mail.bitblocks.com [64.142.15.60]) by mx1.freebsd.org (Postfix) with ESMTP id 3D1D08FC14 for ; Tue, 29 Sep 2009 06:50:09 +0000 (UTC) Received: from bitblocks.com (localhost.bitblocks.com [127.0.0.1]) by mail.bitblocks.com (Postfix) with ESMTP id C87045B30; Mon, 28 Sep 2009 23:32:19 -0700 (PDT) To: Adam Vande More In-reply-to: Your message of "Mon, 28 Sep 2009 15:21:17 CDT." <6201873e0909281321s51e3d485i1074954d43b657d6@mail.gmail.com> References: <6201873e0909281321s51e3d485i1074954d43b657d6@mail.gmail.com> Comments: In-reply-to Adam Vande More message dated "Mon, 28 Sep 2009 15:21:17 -0500." Date: Mon, 28 Sep 2009 23:32:19 -0700 From: Bakul Shah Message-Id: <20090929063219.C87045B30@mail.bitblocks.com> Cc: freebsd-net@freebsd.org Subject: Re: tap dhcp X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Sep 2009 06:50:09 -0000 On Mon, 28 Sep 2009 15:21:17 CDT Adam Vande More wrote: > Am I doing something wrong here? > > kldload if_tap if_bridge > sysctl net.link.tap.user_open=1 > ifconfig tap0 create > ifconfig bridge create > ifconfig bridge0 addm tap0 addm em0 > > it# dhclient tap0 > DHCPDISCOVER on tap0 to 255.255.255.255 port 67 interval 6 > DHCPDISCOVER on tap0 to 255.255.255.255 port 67 interval 6 > DHCPDISCOVER on tap0 to 255.255.255.255 port 67 interval 13 > DHCPDISCOVER on tap0 to 255.255.255.255 port 67 interval 18 > DHCPDISCOVER on tap0 to 255.255.255.255 port 67 interval 18 > No DHCPOFFERS received. > No working leases in persistent database - sleeping. > > Although dhclient em0 works as expected. This is behaving as it should. Here is why. Normal behavior of the tap device: * What you send on if tap0 can be read on /dev/tap0. [if == interface] * What you write on /dev/tap0 can be received on if tap0. Your bridge setup: bridge0 |---- em0 -- physical network |---- tap0--/dev/tap0-virtual machine For this setup the behavior is modified as follows: * What you write to /dev/tap0 can be received on if tap0 + it will be sent out to the phys. net over em0 (but you can't receive this packets on if em0). * What you send on if tap0 can be read on /dev/tap0 + it will be sent out to the phys. net over em0 (but you can't receive this packets on if em0). * What you receive from a phys. device can be read on em0 + it will be sent out on tap0 (so you can read it from /dev/tap0) but you can't receive this packet on if tap0. So you can see that DHCPDISCOVER pkt sent on tap0 will be seen by the dhcp server on a physical net but you can't receive the response on if tap0. Now typically an emulator like qemu will connect its emulated VM's interface (say re0) to /dev/tap0. If the VM does dhclient re0, it will get its ip address from the dhcp server on the phys net. If you want dhclient tap0 to work, run a dhcp server on the VM!