进入正题:
1. 查看网卡信息,eth0为旧网卡IP地址,eth0:0为新IP地址
- [[email protected]:] ~ # ifconfig
- eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
- inet 149.57.166.xx netmask 255.255.255.0 broadcast 149.57.166.255
- ether 00:xx:3c:7e:79:23 txqueuelen 1000 (Ethernet)
- RX packets 24522 bytes 1529220 (1.4 MiB)
- RX errors 0 dropped 0 overruns 0 frame 0
- TX packets 657 bytes 85448 (83.4 KiB)
- TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
-
- eth0:0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
- inet 47.87.230.xx netmask 255.255.255.0 broadcast 47.87.230.255
- ether 00:xx:3c:7e:79:23 txqueuelen 1000 (Ethernet)
复制代码
2. 备份文件网卡配置:
- cp /etc/network/interfaces{,.back}
复制代码
3. 将旧IP地址的配置eth0改成eth0:0,将新IP地址的配置改成eth0,如下所示
- # Generated by SolusVM
-
- auto lo
- iface lo inet loopback
-
- auto eth0
- iface eth0 inet static
- address 47.87.230.xx
- gateway 47.87.230.1
- netmask 255.255.255.0
- dns-nameservers 8.8.8.8 8.8.4.4
-
- auto eth0:0
- iface eth0:0 inet static
- address 149.57.166.xx
- gateway 149.57.166.1
- netmask 255.255.255.0
- dns-nameservers 8.8.8.8 8.8.4.4
复制代码
4. 重启服务器reboot,再次登录系统,通过ifconfig验证。 |