我在 kvm 中设置了一个 Ubuntu 16.04 服务器作为客户机。服务器使用 2 个接口:主机和桥接器
ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
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: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 52:54:00:46:46:ba brd ff:ff:ff:ff:ff:ff
inet 192.168.122.166/24 brd 192.168.122.255 scope global ens3
valid_lft forever preferred_lft forever
inet6 fe80::5054:ff:fe46:46ba/64 scope link
valid_lft forever preferred_lft forever
3: ens8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 52:54:00:b9:36:a0 brd ff:ff:ff:ff:ff:ff
inet 192.168.2.161/24 brd 192.168.2.255 scope global ens8
valid_lft forever preferred_lft forever
inet6 fe80::5054:ff:feb9:36a0/64 scope link
valid_lft forever preferred_lft forever
需要连接静态 ens8
sudo nano /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# Source interfaces
# Please check /etc/network/interfaces.d before changing this file
# as interfaces may have been defined in /etc/network/interfaces.d
# See LP: #1262951
#source /etc/network/interfaces.d/*.cfg
auto ens8
iface ens8 inet static
addtress 192.168.2.161
netmask 255.255.255.0
gateway 192.168.2.1
dns-nameservers 127.0.0.53
/etc/init.d/networking 重启
Restarting networking (via systemctl): networking.service==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to restart 'networking.service'.
Authenticating as: Ubuntu (ubuntu)
Password:
==== AUTHENTICATION COMPLETE ===
Job for networking.service failed because the control process exited with error code. See "systemctl status networking.service" and "journalctl -xe" for details.
failed!