12, IP别名的永久设置

一、        问题现象
某客户有一台安装RHEL6.5系统的服务器,该服务器需要配置内网和外网两个IP地址,系统配置好IP地址重启网卡服务后,通过内、外网IP地址都能正常连接。过一会儿后就连接不正常了,

该服务器无法通过外网IP地址远程连接,而通过内网IP地址却能远程,后来远程ifconfig查看网卡配置,发现外网IP丢失,两块网卡全变成了内网IP(如下图所示)

12, IP别名的永久设置

12, IP别名的永久设置

二、问题原因

该系统在安装的时候是安装了图形化界面服务,默认会安装 NetworkManager 管理服务,NetworkManager服务启动以后导致系统内部的网络配置出现紊乱。

三、解决方案

1、执行chkconfig --list命令查看NetworkManager服务是否开机启动:

12, IP别名的永久设置

2、如果该服务为启动状态,执行service NetworkManager stop或者/etc/init.d/NetworkManager stop 停止 NetworkManager 服务。

3、执行chkconfig NetworkManager off命令禁止NetworkManager 开机启动。

12, IP别名的永久设置

4、执行 /etc/init.d/network restart 重启服务器的网络检查,之后就恢复正常。

5.所以配置IP别名的时候,需要先关闭NetworkManager 服务。

6  IP别名(一个物理网卡添加多个IP地址)

[root@192 ~]# ifconfig

ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 192.168.132.188  netmask 255.255.255.0  broadcast 192.168.132.255

        inet6 fe80::f3cb:e9b0:cc85:56ab  prefixlen 64  scopeid 0x20<link>

        ether 00:0c:29:25:af:d7  txqueuelen 1000  (Ethernet)

        RX packets 3445892  bytes 4840270149 (4.5 GiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 256138  bytes 31798039 (30.3 MiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536

        inet 127.0.0.1  netmask 255.0.0.0

        inet6 ::1  prefixlen 128  scopeid 0x10<host>

        loop  txqueuelen 1  (Local Loopback)

        RX packets 33  bytes 2920 (2.8 KiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 33  bytes 2920 (2.8 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

virbr0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255

        ether 52:54:00:dc:f6:77  txqueuelen 1000  (Ethernet)

        RX packets 0  bytes 0 (0.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 0  bytes 0 (0.0 B)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

vnet0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet6 fe80::fc54:ff:fe2e:519c  prefixlen 64  scopeid 0x20<link>

        ether fe:54:00:2e:51:9c  txqueuelen 1000  (Ethernet)

        RX packets 0  bytes 0 (0.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 23037  bytes 1198156 (1.1 MiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

[root@192 ~]#

为ens33 网卡添加一个别名

[root@192 ~]# ip addr add 192.168.1.200/24 dev ens33 label ens33:0

[root@192 ~]# ifconfig

ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 192.168.132.188  netmask 255.255.255.0  broadcast 192.168.132.255

        inet6 fe80::f3cb:e9b0:cc85:56ab  prefixlen 64  scopeid 0x20<link>

        ether 00:0c:29:25:af:d7  txqueuelen 1000  (Ethernet)

        RX packets 3446156  bytes 4840293287 (4.5 GiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 256290  bytes 31817767 (30.3 MiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

ens33:0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 192.168.1.200  netmask 255.255.255.0  broadcast 0.0.0.0

        ether 00:0c:29:25:af:d7  txqueuelen 1000  (Ethernet)

 

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536

        inet 127.0.0.1  netmask 255.0.0.0

        inet6 ::1  prefixlen 128  scopeid 0x10<host>

        loop  txqueuelen 1  (Local Loopback)

        RX packets 33  bytes 2920 (2.8 KiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 33  bytes 2920 (2.8 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

virbr0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255

        ether 52:54:00:dc:f6:77  txqueuelen 1000  (Ethernet)

        RX packets 0  bytes 0 (0.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 0  bytes 0 (0.0 B)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

vnet0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet6 fe80::fc54:ff:fe2e:519c  prefixlen 64  scopeid 0x20<link>

        ether fe:54:00:2e:51:9c  txqueuelen 1000  (Ethernet)

        RX packets 0  bytes 0 (0.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 23126  bytes 1202784 (1.1 MiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

[root@192 ~]#

12, IP别名的永久设置

 

上一篇:django报错:(1054, "Unknown column 'blog_readnum.blog_id' in 'field list'"


下一篇:KVM 在 Ubuntu 18.04 Desktop 安装