churchers / vm-bhyve

Shell based, minimal dependency bhyve manager
BSD 2-Clause "Simplified" License
840 stars 181 forks source link

No guest networking - DHCP #467

Closed hamzakc closed 2 years ago

hamzakc commented 2 years ago

I have been using bhyve-vm for a few months now and have had no problems. However I restarted my host server and now all my vm's do not seem to be able to get a IP address from my router using DHCP. The host is freebsd-13 and i am trying to connect to a freebsd-13 vm.

Server (HOST)

root@freebsd:/zroot/vm/florio # vm switch list
NAME    TYPE      IFACE      ADDRESS  PRIVATE  MTU  VLAN  PORTS
public  standard  vm-public  -        no       -    -     em0
root@freebsd:/zroot/vm/florio # vm info florio
------------------------
Virtual Machine: florio
------------------------
  state: running (19069)
  datastore: default
  loader: bhyveload
  uuid: a1386401-b263-11eb-84e9-e86a64c70198
  uefi: default
  cpu: 6
  memory: 16G
  memory-resident: 927780864 (884.800M)

  console-ports
    com1: /dev/nmdm-florio.1B

  network-interface
    number: 0
    emulation: virtio-net
    virtual-switch: public
    fixed-mac-address: 58:9c:fc:02:68:53
    fixed-device: -
    active-device: tap0
    desc: vmnet-florio-0-public
    mtu: 1500
    bridge: vm-public
    bytes-in: 0 (0.000B)
    bytes-out: 1368 (1.335K)

  virtual-disk
    number: 0
    device-type: file
    emulation: virtio-blk
    options: -
    system-path: /zroot/vm/florio/disk0.img
    bytes-size: 107374182400 (100.000G)
    bytes-used: 41357620224 (38.517G)

  clone-origin
    zroot/vm/freebsd-13-vm@emacs-base

VM log

Jul 14 11:04:19: initialising
Jul 14 11:04:19:  [loader: bhyveload]
Jul 14 11:04:19:  [cpu: 6]
Jul 14 11:04:19:  [memory: 16G]
Jul 14 11:04:19:  [hostbridge: standard]
Jul 14 11:04:19:  [com ports: com1]
Jul 14 11:04:19:  [uuid: a1386401-b263-11eb-84e9-e86a64c70198]
Jul 14 11:04:19:  [utctime: yes]
Jul 14 11:04:19:  [debug mode: no]
Jul 14 11:04:19:  [primary disk: disk0.img]
Jul 14 11:04:19:  [primary disk dev: file]
Jul 14 11:04:19: initialising network device tap0
Jul 14 11:04:19: adding tap0 -> vm-public (public addm)
Jul 14 11:04:20: bring up tap0 -> vm-public (public addm)
Jul 14 11:04:20: booting
Jul 14 11:04:20: bhyveload -c /dev/nmdm-florio.1A -m 16G -e autoboot_delay=3 -d /zroot/vm/florio/disk0.img florio
Jul 14 11:04:23:  [bhyve options: -c 6 -m 16G -AHP -U a1386401-b263-11eb-84e9-e86a64c70198 -u]
Jul 14 11:04:23:  [bhyve devices: -s 0,hostbridge -s 31,lpc -s 4:0,virtio-blk,/zroot/vm/florio/disk0.img -s 5:0,virtio-net,tap0,mac=58:9c:fc:02:68:53]
Jul 14 11:04:23:  [bhyve console: -l com1,/dev/nmdm-florio.1A]
Jul 14 11:04:23: starting bhyve (run 1)

ifconfig

root@freebsd:/zroot/vm/florio # ifconfig
em0: flags=8963<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=4810099<RXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,VLAN_HWFILTER,NOMAP>
        ether e8:6a:64:c7:01:98
        inet 10.0.0.90 netmask 0xffffff00 broadcast 10.0.0.255
        media: Ethernet autoselect (1000baseT <full-duplex>)
        status: active
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
        inet6 ::1 prefixlen 128
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2
        inet 127.0.0.1 netmask 0xff000000
        groups: lo
        nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
vm-public: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether d6:74:6e:44:98:bb
        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: tap0 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
                ifmaxaddr 0 port 3 priority 128 path cost 2000000
        member: em0 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
                ifmaxaddr 0 port 1 priority 128 path cost 2000000
        groups: bridge vm-switch viid-4c918@
        nd6 options=9<PERFORMNUD,IFDISABLED>
tap0: flags=8942<BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
        description: vmnet-florio-0-public
        options=80000<LINKSTATE>
        ether 58:9c:fc:10:61:74
        groups: tap vm-port
        media: Ethernet autoselect
        status: active
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
        Opened by PID 19069

Client

vtnet0: flags=8863<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=80028<VLAN_MTU,JUMBO_MTU,LINKSTATE>
        ether 58:9c:fc:02:68:53
        inet 0.0.0.0 netmask 0xff000000 broadcast 255.255.255.255
        media: Ethernet autoselect (10Gbase-T <full-duplex>)
        status: active
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
        inet6 ::1 prefixlen 128
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2
        inet 127.0.0.1 netmask 0xff000000
        groups: lo
        nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>

Issue - No IP address

[root@florio /usr/home/hamza]# dhclient vtnet0
DHCPDISCOVER on vtnet0 to 255.255.255.255 port 67 interval 4
DHCPDISCOVER on vtnet0 to 255.255.255.255 port 67 interval 6
DHCPDISCOVER on vtnet0 to 255.255.255.255 port 67 interval 6
DHCPDISCOVER on vtnet0 to 255.255.255.255 port 67 interval 7
Jul 14 12:06:44 florio syslogd: last message repeated 1 times
DHCPDISCOVER on vtnet0 to 255.255.255.255 port 67 interval 8
DHCPDISCOVER on vtnet0 to 255.255.255.255 port 67 interval 12
DHCPDISCOVER on vtnet0 to 255.255.255.255 port 67 interval 14
DHCPDISCOVER on vtnet0 to 255.255.255.255 port 67 interval 3
No DHCPOFFERS received.

I have ruled out firewall issues as it is effecting my other vm's that do not have a firewall configured.

Any help would be appreciated. I have come to a dead end.

hamzakc commented 2 years ago

I managed to fix the issue, I just deleted the switch and added it again:

vm switch destroy public
vm switch create public
vm switch add public em0

:man_shrugging: