Date: Mon, 28 Sep 2009 23:32:19 -0700 From: Bakul Shah <bakul@bitblocks.com> To: Adam Vande More <amvandemore@gmail.com> Cc: freebsd-net@freebsd.org Subject: Re: tap dhcp Message-ID: <20090929063219.C87045B30@mail.bitblocks.com> In-Reply-To: Your message of "Mon, 28 Sep 2009 15:21:17 CDT." <6201873e0909281321s51e3d485i1074954d43b657d6@mail.gmail.com> References: <6201873e0909281321s51e3d485i1074954d43b657d6@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 28 Sep 2009 15:21:17 CDT Adam Vande More <amvandemore@gmail.com> 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!
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090929063219.C87045B30>