Is there a way to use a virtual network interface on a physical FreeBSD host?
TL;DR - yes - use epair(4) interfaces.
Background: I have this new and quite cheap laptop (Lenovo ideapad 530S-14ARR). It was on outlet sale, therefore cheap. It doesn't have a wired ethernet interface, and the wireless interface is Qualcomm Atheros QCA9377 which is not supported by FreeBSD yet.
But that is also the point: I wanted to try an experiment - to see if I could use a virtual machine running Linux as a gateway.
Long story short: I used a usb dongle (usb hub-with-ethernet-port) as a wired network while installing FreeBSD, vm-bhyve and other packages on the machine. Now it runs:
The virtual machine is installed and working, it runs Debian. The setup is per BridgeNetworkConnectionsProxyArp page on the Debian wiki.
and as you can see, I can ssh into it, so wireless is working. On the host side, I have the following network set up in /etc/rc.conf:
One problem I see right away, is that tap0 shows "no carrier":
compare to tap1 (the interface for the virtual machine)
FWIW, both interfaces are members of the same bridge
So, what else have I tried?
- using tun0 instead of tap0; doesn't work - I get an error message when I try to add it to a bridge (understandably)
- using lo1 instead of tap0; doesn't work - I get an error message when I try to add it to a bridge (not sure why)
- using epair(4) interfaces, with epair0a on the host, and epair0b connected to the bridge; here I get no error messages, but the host machine also doesn't get an ip adress from the DHCP server
TL;DR - yes - use epair(4) interfaces.
Background: I have this new and quite cheap laptop (Lenovo ideapad 530S-14ARR). It was on outlet sale, therefore cheap. It doesn't have a wired ethernet interface, and the wireless interface is Qualcomm Atheros QCA9377 which is not supported by FreeBSD yet.
But that is also the point: I wanted to try an experiment - to see if I could use a virtual machine running Linux as a gateway.
Long story short: I used a usb dongle (usb hub-with-ethernet-port) as a wired network while installing FreeBSD, vm-bhyve and other packages on the machine. Now it runs:
Code:
root@kg-pod530:~ # freebsd-version -ku
12.1-RELEASE-p7
12.1-RELEASE-p7
Code:
tingo@kg-core2$ ssh 10.1.161.14
Linux pod530-gw 4.19.0-9-amd64 #1 SMP Debian 4.19.118-2+deb10u1 (2020-06-07) x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Fri Jul 31 21:21:28 2020 from 10.1.150.52
Code:
cloned_interfaces="bridge0 tap0"
ifconfig_bridge0="addm tap0"
ifconfig_tap0="DHCP"
Code:
root@kg-pod530:~ # ifconfig tap0
tap0: flags=8903<UP,BROADCAST,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=80000<LINKSTATE>
ether 00:bd:98:db:f6:00
groups: tap
media: Ethernet autoselect
status: no carrier
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
Code:
root@kg-pod530:~ # ifconfig tap1
tap1: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
description: vmnet-gateway-0-glue
options=80000<LINKSTATE>
ether 00:bd:a6:f8:f6:01
inet6 fe80::2bd:a6ff:fef8:f601%tap1 prefixlen 64 tentative scopeid 0x6
groups: tap vm-port
media: Ethernet autoselect
status: active
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
Opened by PID 1543
Code:
root@kg-pod530:~ # ifconfig bridge0
bridge0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
description: vm-glue
ether 02:73:ff:81:33:00
id 00:00:00:00:00:00 priority 32768 hellotime 2 fwddelay 15
maxage 20 holdcnt 6 proto rstp maxaddr 2000 timeout 1200
root id 00:00:00:00:00:00 priority 32768 ifcost 0 port 0
member: tap1 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
ifmaxaddr 0 port 6 priority 128 path cost 2000000
member: tap0 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
ifmaxaddr 0 port 3 priority 128 path cost 2000000
groups: bridge vm-switch viid-1ed4d@
nd6 options=9<PERFORMNUD,IFDISABLED>
- using tun0 instead of tap0; doesn't work - I get an error message when I try to add it to a bridge (understandably)
- using lo1 instead of tap0; doesn't work - I get an error message when I try to add it to a bridge (not sure why)
- using epair(4) interfaces, with epair0a on the host, and epair0b connected to the bridge; here I get no error messages, but the host machine also doesn't get an ip adress from the DHCP server
Last edited: