[root@rac19c01 ~]# 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: ens33:
link/ether 00:0c:29:73:28:16 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.61/24 brd 192.168.1.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
inet6 fe80::99e4:3fd5:dee8:ea21/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: ens34:
link/ether 00:50:56:37:17:0d brd ff:ff:ff:ff:ff:ff
4: virbr0:
link/ether 52:54:00:59:a5:44 brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
5: virbr0-nic:
link/ether 52:54:00:59:a5:44 brd ff:ff:ff:ff:ff:ff
修改配置文件后重启网络服务:
[root@rac19c01 ~]# ifconfig ens34 up
--重启未报错
--再次检查,依旧不生效
总结:ens34网段未生效,检查虚拟机网络配置和相关windows的网络配置,均显示正常
后找人询问后发现是因为配置文件书写错误
正确如下:
[root@rac19c01 ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens34
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens34
UUID=30760386-ffe4-4245-b3b4-47710c316c54
DEVICE=ens34
ONBOOT=yes #此处onboot需设置成yes,设置成开机自启动
IPADDR=192.168.2.61
PREFIX=24
#GATEWAY=192.168.2.1 #此处网关设置需要注释掉,否则ip不生效
IPV6_PRIVACY=no
随机重启网络服务:
[root@rac19c01 ~]# service network restart
Restarting network (via systemctl): [ OK ]
--网络服务重启正常
--再次检查,发现ip生效,ens34启动成功
- [root@rac19c01 ~]# ip a
- 1: lo:
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: ens33:
mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 - link/ether 00:0c:29:73:28:16 brd ff:ff:ff:ff:ff:ff
- inet 192.168.1.61/24 brd 192.168.1.255 scope global noprefixroute ens33
- valid_lft forever preferred_lft forever
- inet6 fe80::99e4:3fd5:dee8:ea21/64 scope link noprefixroute
- valid_lft forever preferred_lft forever
- 3: ens34:
mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 - link/ether 00:50:56:37:17:0d brd ff:ff:ff:ff:ff:ff
- inet 192.168.2.61/24 brd 192.168.2.255 scope global noprefixroute ens34
- valid_lft forever preferred_lft forever
- inet6 fe80::63d2:b0ff:a37c:c981/64 scope link noprefixroute
- valid_lft forever preferred_lft forever
- 4: virbr0:
mtu 1500 qdisc noqueue state DOWN group default qlen 1000 - link/ether 52:54:00:59:a5:44 brd ff:ff:ff:ff:ff:ff
- inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
- valid_lft forever preferred_lft forever
- 5: virbr0-nic:
mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000 - link/ether 52:54:00:59:a5:44 brd ff:ff:ff:ff:ff:ff
- [root@rac19c01 ~]#