昨天 收到阿里的迁移通知 我预约了今天早上8点 结果 迁移完毕之后 服务器外网一直无法访问
- 通过 阿里的管理终端进入服务器 执行
ip a
发现服务器网卡没有分配IP1
2
3
4
5
6
7
8
9root@iZ28cqmea34Z:~# 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
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:16:3e:04:d2:cc brd ff:ff:ff:ff:ff:ff
3: ens4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:16:3e:04:36:65 brd ff:ff:ff:ff:ff:ff - 提交工单 他们让我重启网络服务 结果报错了 通过
journalctl -xe
查看错误信息 关键信息如下1
2
3
4
5
6
7
8Jul 29 11:30:58 iZ28cqmea34Z ifup[570]: Cannot find device "eth0"
Jul 29 11:30:58 iZ28cqmea34Z ifup[570]: Failed to bring up eth0.
Jul 29 11:30:58 iZ28cqmea34Z ifup[570]: Cannot find device "eth1"
Jul 29 11:30:58 iZ28cqmea34Z ifup[570]: Failed to bring up eth1.
Jul 29 11:30:58 iZ28cqmea34Z irqbalance[511]: * Starting SMP IRQ Balancer: irqbalance
Jul 29 11:30:58 iZ28cqmea34Z cron[559]: (CRON) INFO (Running @reboot jobs)
Jul 29 11:30:58 iZ28cqmea34Z nscd[497]: ...done.
Jul 29 11:30:58 iZ28cqmea34Z systemd[1]: Started LSB: Starts the Name Service Cache Daemon. - 通过对比发现 应该是 阿里云 迁移之后 虚拟机网卡的MAC变了 导致网卡名称变了 所以要修改网卡
- 我的操作系统是
Ubuntu
的 配置文件在/etc/network/interfaces
- 用 VI 修改网卡接口配置
vi /etc/network/interfaces
- 替换
eth0
为ens3
- 替换
eth1
为ens4
- 保存退出
- 替换
- 最后重启网络
service networking restart
查看网络 已经获得IP了1
2
3
4
5
6
7
8
9
10
11
12
13root@iZ28cqmea34Z:~# 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
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:16:3e:04:d2:cc brd ff:ff:ff:ff:ff:ff
inet 10.30.166.130/22 brd 10.30.167.255 scope global ens3
valid_lft forever preferred_lft forever
3: ens4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:16:3e:04:36:65 brd ff:ff:ff:ff:ff:ff
inet xxx.xxx.xxx.xxx/22 brd 121.42.207.255 scope global ens4
valid_lft forever preferred_lft forever - 外网访问正常 问题解决