GCP 网络故障将网络从旧版更改为共享 VPC(仅发生在 Ubuntu Bionic 和 Focal 中)

GCP 网络故障将网络从旧版更改为共享 VPC(仅发生在 Ubuntu Bionic 和 Focal 中)

我需要一些帮助来解决这个网络问题。

我在 GCP Compute Engine 上设置了一个服务器/实例。

请注意,这仅发生在 Ubuntu Bionic 和 Focal 中。如果我使用 Debian 的图像,则不会出现网络问题。

将旧网络更改为共享 VPC 后,没有网络/没有 IP。

root@instance-1-eng-2819:~# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> 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: ens4: <BROADCAST,MULTICAST> mtu 1500 qdisc mq state DOWN group default qlen 1000
    link/ether 42:01:0a:80:00:2c brd ff:ff:ff:ff:ff:ff
    altname enp0s4 root@instance-1-eng-2819:~# ip link 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: ens4: <BROADCAST,MULTICAST> mtu 1500 qdisc mq state DOWN mode DEFAULT group default qlen 1000
    link/ether 42:01:0a:80:00:2c brd ff:ff:ff:ff:ff:ff
    altname enp0s4

我从串行端口 1(控制台)获取了这些

root@instance-1-eng-2819:~# Dec 25 01:02:53 instance-1-eng-2819 OSConfigAgent[4112]: 2022-12-25T01:02:53.4655Z OSConfigAgent Critical main.go:100: Error parsing metadata, agent cannot start: network error when requesting metadata, make sure your instance has an active network and can reach the metadata server: Get http://169.254.169.254/computeMetadata/v1/?recursive=true&alt=json&wait_for_change=true&last_etag=0&timeout_sec=60: dial tcp 169.254.169.254:80: connect: network is unreachable Dec 25 01:02:53 instance-1-eng-2819 systemd[1]: google-osconfig-agent.service: Main process exited, code=exited, status=1/FAILURE Dec 25 01:02:53 instance-1-eng-2819 systemd[1]: google-osconfig-agent.service: Failed with result 'exit-code'. Dec 25 01:02:54 instance-1-eng-2819 systemd[1]: google-osconfig-agent.service: Scheduled restart job, restart counter is at 76. Dec 25 01:02:54 instance-1-eng-2819 systemd[1]: Stopped Google OSConfig Agent. Dec 25 01:02:54 instance-1-eng-2819 systemd[1]: Started Google OSConfig Agent. Dec 25 01:03:39 instance-1-eng-2819 systemd[1]: google-guest-agent.service: State 'stop-sigterm' timed out. Killing.

我还从日志中看到了“权限被拒绝”:

Dec 24 23:45:19 instance-1-eng-2819 dhclient[419]: execve (/bin/true, ...): Permission denied Dec 24 23:45:19 instance-1-eng-2819 dhclient[415]: Listening on LPF/ens4/42:01:0a:80:00:2c Dec 24 23:45:19 instance-1-eng-2819 dhclient[415]: Sending on   LPF/ens4/42:01:0a:80:00:2c Dec 24 23:45:19 instance-1-eng-2819 dhclient[415]: Sending on   Socket/fallback Dec 24 23:45:19 instance-1-eng-2819 dhclient[415]: DHCPDISCOVER on ens4 to
255.255.255.255 port 67 interval 3 (xid=0xbe742848) Dec 24 23:45:19 instance-1-eng-2819 dhclient[415]: DHCPOFFER of 10.128.0.44 from
169.254.169.254 Dec 24 23:45:19 instance-1-eng-2819 dhclient[415]: DHCPREQUEST for 10.128.0.44 on ens4 to 255.255.255.255 port 67 (xid=0x482874be) Dec 24 23:45:19 instance-1-eng-2819 dhclient[415]: DHCPACK of 10.128.0.44 from 169.254.169.254 (xid=0xbe742848) Dec 24 23:45:19 instance-1-eng-2819 dhclient[420]: execve (/bin/true, ...): Permission denied   So I think the network failure occurred because it can't communicate to gcp metadata 169.254.169.254.

这是 Ubuntu 特有的问题吗,因为它使用 Debian 的图像运行良好?

更新:(这不是我正在寻找的解决方案)

事实证明,在 GCP 中更改网络后,它没有获取/更新新的 MAC 地址。

如果是 ens4,则当前 MAC 地址

ip a | grep link/ether
link/ether 42:01:0a:80:00:2c brd ff:ff:ff:ff:ff:ff

Netplan mac 地址:

cat /etc/netplan/50-cloud-init.yaml | grep mac
2 macaddress: 42:01:0a:f0:02:42

匹配(更改了 netplan mac addr)mac 地址后,我获得了 IP 和网络。

ip a | grep ens4
2: ens4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1460 qdisc mq state UP group default qlen 1000
    inet 10.128.0.44/32 scope global dynamic ens4
root@instance-1-eng-2819:~# ping google.com
PING google.com (142.251.161.100) 56(84) bytes of data.
64 bytes from ig-in-f100.1e100.net (142.251.161.100): icmp_seq=1 ttl=109 time=1.83 ms
64 bytes from ig-in-f100.1e100.net (142.251.161.100): icmp_seq=2 ttl=109 time=1.24 ms

所以现在的问题是:

更改网络 VPC 后,cloud-init 获取了错误的 MAC 地址。

答案1

我找到了一个修复程序。cloud-init clean在更新网络 VPC 之前运行即可修复该问题。

相关内容