为什么日志显示 172.16.xx 网络?

为什么日志显示 172.16.xx 网络?

我有一个全新的 ubuntu 16.04 镜像,是我用它创建的包装工基于便当配置。我的配置几乎与16.04配置在这里

我的 ubuntu 虚拟机即使在重新启动后也无法获得 dhcp 租约。同一 VLAN 上的其他 Windows 和 CentOS 虚拟机获得 DHCP 租约没有问题。

我获得租约的唯一方法是手动运行dhclient

/etc/网络/接口

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto ens32
iface ens32 inet dhcp
pre-up sleep 2

当我检查时cat /var/log/syslog | grep -Ei 'dhcp',我看到 dhcp 客户端正在启动。奇怪的是,它请求 172.16.xx 网络中的 IP(我希望是 10.xxx IP)。

Dec  2 21:17:02 vagrant dhclient[688]: Internet Systems Consortium DHCP Client 4.3.3
Dec  2 21:17:02 vagrant sh[676]: Internet Systems Consortium DHCP Client 4.3.3
Dec  2 21:17:02 vagrant dhclient[688]: For info, please visit https://www.isc.org/software/dhcp/
Dec  2 21:17:02 vagrant sh[676]: For info, please visit https://www.isc.org/software/dhcp/
Dec  2 21:17:02 vagrant dhclient[688]: DHCPDISCOVER on ens32 to 255.255.255.255 port 67 interval 3 (xid=0x76d9e602)
Dec  2 21:17:02 vagrant sh[676]: DHCPDISCOVER on ens32 to 255.255.255.255 port 67 interval 3 (xid=0x76d9e602)
Dec  2 21:17:03 vagrant dhclient[688]: DHCPREQUEST of 172.16.148.140 on ens32 to 255.255.255.255 port 67 (xid=0x2e6d976)
Dec  2 21:17:03 vagrant sh[676]: DHCPREQUEST of 172.16.148.140 on ens32 to 255.255.255.255 port 67 (xid=0x2e6d976)
Dec  2 21:17:03 vagrant sh[676]: DHCPOFFER of 172.16.148.140 from 172.16.148.254
Dec  2 21:17:03 vagrant dhclient[688]: DHCPOFFER of 172.16.148.140 from 172.16.148.254
Dec  2 21:17:03 vagrant dhclient[688]: DHCPACK of 172.16.148.140 from 172.16.148.254
Dec  2 21:17:03 vagrant sh[676]: DHCPACK of 172.16.148.140 from 172.16.148.254
Jan  5 16:53:56 vagrant kernel: [    6.068252] audit: type=1400 audit(1483635236.420:4): apparmor="STATUS" operation="profile_load" profile="unconfined" name="/usr/lib/NetworkManager/nm-dhcp-client.action" pid=951 comm="apparmor_parser"
Jan  5 16:53:56 vagrant kernel: [    6.068256] audit: type=1400 audit(1483635236.420:5): apparmor="STATUS" operation="profile_load" profile="unconfined" name="/usr/lib/NetworkManager/nm-dhcp-helper" pid=951 comm="apparmor_parser"
Jan  5 16:53:58 vagrant dhclient[1115]: Internet Systems Consortium DHCP Client 4.3.3
Jan  5 16:53:58 vagrant ifup[965]: Internet Systems Consortium DHCP Client 4.3.3
Jan  5 16:53:58 vagrant ifup[965]: For info, please visit https://www.isc.org/software/dhcp/
Jan  5 16:53:58 vagrant dhclient[1115]: For info, please visit https://www.isc.org/software/dhcp/

查看cat /var/log/syslog | grep network我发现无法启动网络接口。

vagrant@vagrant:~$ cat /var/log/syslog | grep network
Dec  2 21:14:06 vagrant systemd[1]: Strating Raise network interfaces...
Dec  2 21:14:06 vagrant systemd[1]: Started Trigger resolvconf update for networkd DNS.
Dec  2 21:14:06 vagrant ifup[2794]: /sbin/ifup: waiting for lock on /run/network/ifstate.ens32
Dec  2 21:14:07 vagrant systemd[1]: Started Raise network interfaces.
Dec  2 21:15:54 vagrant systemd[1]: Started Trigger resolvconf update for networkd DNS.
Dec  2 21:17:02 vagrant systemd[1]: Starting Raise network interfaces...
Dec  2 21:17:02 vagrant systemd[1]: Started Trigger resolvconf update for networkd DNS.
Dec  2 21:17:02 vagrant ifup[724]: /sbin/ifup: waiting for lock on /run/network/ifstate.ens32
Dec  2 21:17:03 vagrant systemd[1]: Started Raise network interfaces.
Jan  5 16:53:56 vagrant systemd[1]: Started Trigger resolvconf update for networkd DNS.
Jan  5 16:53:58 vagrant systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE
Jan  5 16:53:58 vagrant systemd[1]: networking.service: Unit entered failed state.
Jan  5 16:53:58 vagrant systemd[1]: networking.service: Failed with result 'exit-code'.

根据我的研究,当 ubuntu 从 14.04 和 16.04 升级时,可能会发生这种情况,并且网络接口无法从旧版正确重命名eth0为现代版ens32。由于这是一个全新的 ubuntu 安装,这似乎不太可能。由于我可以简单地运行dhclient来解决问题,所以看起来我的界面已初始化。

https://askubuntu.com/questions/758594/no-networking-failed-to-bring-up-eth0

我还可以在哪里查找网络接口无法初始化的原因。
为什么 dhcpclient 不会自动运行?

更新

运行以下命令可以启动网络设备,但仍然没有自动 dhcp 租用

root@vagrant:~# ip link set ens3 up
root@vagrant:~# 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:0f:a4:c0 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::5054:ff:fe0f:a4c0/64 scope link
       valid_lft forever preferred_lft forever

更新

日志中显示的 172.xxx IP 地址是 12 月 2 日的。这是在 vmware 上构建镜像时的情况。

答案1

为什么日志显示 172.16.xx 网络?

vm是在vmware上创建的(使用packer),然后迁移到kvm。日志来自虚拟机迁移之前。

为什么虚拟机无法获取IP地址?

当虚拟机在vmware上时,其网络适配器是ens32 迁移后的,虚拟机网络适配器现在称为ens3
/etc/network/interfaces仍然引用旧的ens32

这是新的“副作用”可预测的网络接口名称' 从 Ubuntu 15.10 开始

短期修复是编辑 /etc/network/interfaces。这里介绍了长期自动修复:

可预测的网络接口名称会破坏虚拟机迁移

相关内容