default网卡状态为inactive。启动失败。
root@xydpc:/usr/share/libvirt# virsh net-list --all
Name State Autostart Persistent
----------------------------------------------------------
default inactive yes yes
root@xydpc:/usr/share/libvirt# virsh net-start
error: command 'net-start' requires option
root@xydpc:/usr/share/libvirt# virsh net-start default
error: Failed to start network default
error: internal error: Failed to initialize a valid firewall backend
检查软件安装情况:
root@xydpc:~# apt list dnsmasq
正在列表... 完成
dnsmasq/bionic,bionic,now 2.79-1 all [已安装]
root@xydpc:~# apt list ip6tables
正在列表... 完成
root@xydpc:~# apt list ipv6tables
正在列表... 完成
root@xydpc:~# apt list ebtables
正在列表... 完成
ebtables/bionic-updates 2.0.10.4-3.5ubuntu2.18.04.3 amd64
N: 还有 1 个版本。请使用 -a 选项来查看它(他们)。
root@xydpc:~# apt list modprobe
正在列表... 完成
root@xydpc:~# apt list modprobe
正在列表... 完成
root@xydpc:~# apt list firewalld
正在列表... 完成
firewalld/bionic,bionic 0.4.4.6-1 all
root@xydpc:~# systemctl status libvirtd
● libvirtd.service - Virtualization daemon
Loaded: loaded (/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2019-05-16 10:40:55 CST; 3h 53min ago
Docs: man:libvirtd(8)
https://libvirt.org
Main PID: 860 (libvirtd)
Tasks: 23 (limit: 32768)
CGroup: /system.slice/libvirtd.service
├─ 860 /usr/sbin/libvirtd
└─8046 qemu-system-x86_64 -enable-kvm -name guest=suse11,debug-threads=on -S -object secret,id=masterKey0,format
5月 16 14:10:03 xydpc libvirtd[860]: 2019-05-16 06:10:03.993+0000: 1059: error : virNetDevSendEthtoolIoctl:3050 : ethtool i
5月 16 14:10:03 xydpc libvirtd[860]: 2019-05-16 06:10:03.995+0000: 1059: error : virNetDevSendEthtoolIoctl:3050 : ethtool i
5月 16 14:10:03 xydpc libvirtd[860]: 2019-05-16 06:10:03.998+0000: 1059: error : virNetDevSendEthtoolIoctl:3050 : ethtool i
5月 16 14:10:04 xydpc libvirtd[860]: 2019-05-16 06:10:04.000+0000: 1059: error : virNetDevSendEthtoolIoctl:3050 : ethtool i
5月 16 14:10:04 xydpc libvirtd[860]: 2019-05-16 06:10:04.003+0000: 1059: error : virNetDevSendEthtoolIoctl:3050 : ethtool i
5月 16 14:12:35 xydpc libvirtd[860]: 2019-05-16 06:12:35.551+0000: 860: error : qemuMonitorIO:719 : internal error: End of
5月 16 14:25:40 xydpc libvirtd[860]: 2019-05-16 06:25:40.400+0000: 940: error : virSocketAddrGetRange:766 : internal error:
5月 16 14:26:17 xydpc libvirtd[860]: 2019-05-16 06:26:17.504+0000: 942: error : virFirewallApply:916 : internal error: Fail
5月 16 14:26:17 xydpc libvirtd[860]: 2019-05-16 06:26:17.526+0000: 1059: error : virFileReadAll:1420 : Failed to open file
5月 16 14:26:17 xydpc libvirtd[860]: 2019-05-16 06:26:17.526+0000: 1059: error : virNetDevGetLinkInfo:2530 : unable to read
root@xydpc:~#
root@xydpc:~#
进一步查看日志
root@xydpc:~# journalctl -u libvirtd > aa
root@xydpc:~# tail -30 aa
5月 16 14:35:29 xydpc systemd[1]: Stopping Virtualization daemon...
5月 16 14:35:29 xydpc systemd[1]: Stopped Virtualization daemon.
5月 16 14:35:46 xydpc systemd[1]: Starting Virtualization daemon...
5月 16 14:35:46 xydpc systemd[1]: Started Virtualization daemon.
5月 16 14:35:46 xydpc libvirtd[8975]: 2019-05-16 06:35:46.756+0000: 8991: info : libvirt version: 4.0.0, package: 1ubuntu8.8 (Marc Deslauriers Wed, 13 Mar 2019 08:09:33 -0400)
5月 16 14:35:46 xydpc libvirtd[8975]: 2019-05-16 06:35:46.756+0000: 8991: info : hostname: xydpc
5月 16 14:35:46 xydpc libvirtd[8975]: 2019-05-16 06:35:46.756+0000: 8991: error : virFirewallValidateBackend:193 : direct firewall backend requested, but /sbin/ebtables is not available: 没有那个文件或目录
5月 16 14:35:46 xydpc libvirtd[8975]: 2019-05-16 06:35:46.756+0000: 8991: error : virFirewallApply:916 : internal error: Failed to initialize a valid firewall backend
5月 16 14:35:46 xydpc libvirtd[8975]: 2019-05-16 06:35:46.959+0000: 8991: error : virFirewallApply:916 : internal error: Failed to initialize a valid firewall backend
5月 16 14:35:46 xydpc libvirtd[8975]: 2019-05-16 06:35:46.983+0000: 8994: error : virNetDevSendEthtoolIoctl:3050 : ethtool ioctl error: 没有那个设备
安装问题缺少文件,重新安装解决。
root@xydpc:~# ll /sbin/ebtables
ls: 无法访问'/sbin/ebtables': 没有那个文件或目录
root@xydpc:~# apt-get install ebtables
root@xydpc:~# ll /sbin/ebtables
-rwxr-xr-x 1 root root 6136 6月 29 2018 /sbin/ebtables*
重启服务
root@xydpc:~# systemctl start libvirtd
root@xydpc:~# systemctl status libvirtd
● libvirtd.service - Virtualization daemon
Loaded: loaded (/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2019-05-16 14:38:01 CST; 1s ago
Docs: man:libvirtd(8)
https://libvirt.org
Main PID: 9499 (libvirtd)
Tasks: 19 (limit: 32768)
CGroup: /system.slice/libvirtd.service
├─9499 /usr/sbin/libvirtd
├─9643 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib
└─9644 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib
5月 16 14:38:01 xydpc systemd[1]: Started Virtualization daemon.
5月 16 14:38:03 xydpc dnsmasq[9643]: started, version 2.79 cachesize 150
5月 16 14:38:03 xydpc dnsmasq[9643]: compile time options: IPv6 GNU-getopt DBus i18n IDN DHCP DHCPv6 no-Lua TFTP conntrack
5月 16 14:38:03 xydpc dnsmasq-dhcp[9643]: DHCP, IP range 192.168.56.2 -- 192.168.56.99, lease time 1h
5月 16 14:38:03 xydpc dnsmasq-dhcp[9643]: DHCP, sockets bound exclusively to interface virbr0
5月 16 14:38:03 xydpc dnsmasq[9643]: reading /etc/resolv.conf
5月 16 14:38:03 xydpc dnsmasq[9643]: using nameserver 127.0.0.53#53
5月 16 14:38:03 xydpc dnsmasq[9643]: read /etc/hosts - 7 addresses
5月 16 14:38:03 xydpc dnsmasq[9643]: read /var/lib/libvirt/dnsmasq/default.addnhosts - 0 addresses
5月 16 14:38:03 xydpc dnsmasq-dhcp[9643]: read /var/lib/libvirt/dnsmasq/default.hostsfile
root@xydpc:~# virsh net-list
Name State Autostart Persistent
----------------------------------------------------------
default active yes yes
virt-manager启动虚拟机
在虚拟机下执行
ip ad
dhcpcd eth1
ping baidu.com
ping结果正常。
宿主机的配置感觉有点奇葩,哈哈,桥接了,还是nat模式,不过可以工作,或者去掉nat就是桥接了吧?
root@xydpc:/etc/netplan# virsh net-edit default
default
b19c99d1-4688-447a-84a9-1e54eb84a894
Network default XML configuration not changed.
root@xydpc:/etc/netplan# ll
总用量 20
drwxr-xr-x 2 root root 4096 12月 17 22:43 ./
drwxr-xr-x 163 root root 12288 5月 16 14:37 ../
-rw-r--r-- 1 root root 104 2月 9 2018 1-network-manager-all.yaml
root@xydpc:/etc/netplan# cat 1-network-manager-all.yaml
# Let NetworkManager manage all devices on this system
network:
version: 2
renderer: NetworkManager
root@xydpc:/etc/netplan# lsb
lsblk lsb_release
root@xydpc:/etc/netplan# lsb_release -a
No LSB modules are available.
Distributor ID: LinuxMint
Description: Linux Mint 19.1 Tessa
Release: 19.1
Codename: tessa
root@xydpc:/etc/netplan# ip ad
1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp6s0: mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
link/ether 20:47:47:6b:9a:71 brd ff:ff:ff:ff:ff:ff
3: wlp7s0: mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 4c:34:88:20:f9:b8 brd ff:ff:ff:ff:ff:ff
inet 123.146.66.216/24 brd 123.146.66.255 scope global dynamic noprefixroute wlp7s0
valid_lft 239274sec preferred_lft 239274sec
inet6 fe80::b635:fc5d:5f52:10c1/64 scope link noprefixroute
valid_lft forever preferred_lft forever
20: virbr0: mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 52:54:00:6a:9d:ff brd ff:ff:ff:ff:ff:ff
inet 192.168.56.1/24 brd 192.168.56.255 scope global virbr0
valid_lft forever preferred_lft forever
21: virbr0-nic: mtu 1500 qdisc fq_codel master virbr0 state DOWN group default qlen 1000
link/ether 52:54:00:6a:9d:ff brd ff:ff:ff:ff:ff:ff
22: vnet0: mtu 1500 qdisc fq_codel master virbr0 state UNKNOWN group default qlen 1000
link/ether fe:54:00:8c:f1:91 brd ff:ff:ff:ff:ff:ff
root@xydpc:/etc/netplan#
网卡采用的NetworkManager模式,并没有直接使用netplan,这2者区别还不清楚,待学习。但图像界面看起来网卡信息也没有报错什么的。