centos7 oracle11g 配置详细_重启 CentOS 7 系统后的 IP 地址问题

在重启CentOS 7后,系统IP从192.168.186.128变为192.168.186.130,eno16777736网卡变成ens33。通过修改配置文件,将ens33的IP地址更改为旧IP,并删除无效网卡配置,重启网络服务,成功恢复原IP地址。此过程解决了远程连接超时的问题。
摘要由CSDN通过智能技术生成
dffc3e61d33219a015ba309f6f4aaac3.png

在配置 Zookeeper 的时候,我重启了 CentOS 7,发现使用 XShell 远程连接系统(主机:192.168.186.128)超时。

对于操作系统和写代码时候出现的各种 BUG 和意外,我早已经习惯;因为我知道,在有限的时间内,都可以被解决。

然后,我直接进入系统页面,打开命令行输入 ifconfig:

ens33: flags=4163  mtu 1500        inet 192.168.186.130  netmask 255.255.255.0  broadcast 192.168.186.255        inet6 fe80::20c:29ff:fe1a:6c13  prefixlen 64  scopeid 0x20        ether 00:0c:29:1a:6c:13  txqueuelen 1000  (Ethernet)        RX packets 636  bytes 48167 (47.0 KiB)        RX errors 0  dropped 0  overruns 0  frame 0        TX packets 237  bytes 26851 (26.2 KiB)        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0lo: flags=73  mtu 65536        inet 127.0.0.1  netmask 255.0.0.0        inet6 ::1  prefixlen 128  scopeid 0x10        loop  txqueuelen 0  (Local Loopback)        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

根据之前的系统快照备份,可以得到之前的信息为:

eno16777736: flags=4163  mtu 1500        inet 192.168.186.128  netmask 255.255.255.0  broadcast 192.168.186.255        inet6 fe80::20c:29ff:fed8:e9b9  prefixlen 64  scopeid 0x20        ether 00:0c:29:d8:e9:b9  txqueuelen 1000  (Ethernet)        RX packets 1370575  bytes 1933632481 (1.8 GiB)        RX errors 0  dropped 0  overruns 0  frame 0        TX packets 360561  bytes 85054851 (81.1 MiB)        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0lo: flags=73  mtu 65536        inet 127.0.0.1  netmask 255.0.0.0        inet6 ::1  prefixlen 128  scopeid 0x10        loop  txqueuelen 0  (Local Loopback)        RX packets 19044  bytes 38146469 (36.3 MiB)        RX errors 0  dropped 0  overruns 0  frame 0        TX packets 19044  bytes 38146469 (36.3 MiB)        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

由此可见,重启之后主机地址由 192.168.186.128 变为了 192.168.186.130,原来的 eno16777736 也变成了 ens33。

然后,我尝试执行重启网络的命令 service network restart 或者 systemctl restart network,发现报错:

Job for network.service failed because the control process exited with error code. See "systemctl status network.service" and "journalctl -xe" for details.

为了查看详细错误信息,执行命令 cat /var/log/messages | grep network,发现了错误所在:

...Sep 25 10:55:30 localhost network: [FAILED]Sep 25 10:55:30 localhost NetworkManager[16202]:   renaming /etc/sysconfig/network-scripts/ifcfg-eno16777736 -> /etc/sysconfig/network-scripts/ifcfg-ens33Sep 25 10:55:30 localhost network: Bringing up interface ens33:  Error: no device found for connection 'eno16777736'....

错误提示是加载网卡 eno16777736 失败。

于是执行命令 cd /etc/sysconfig/network-scripts/,进入存放网络配置的文件夹。

查看目录下的文件发现:只存在原来的网卡 eno16777736 对应的配置文件 ifcfg-eno16777736,但是没有网卡 ens33 对应的配置文件。所以推断出,重启之后,系统把原来的网卡删除了,然后启用了新的网卡有了新的 IP 地址。为此,解决方案是,更换网卡配置文件并重新配置 IP 地址为旧的 IP 地址,并重启网络。

首先执行命令 cp ifcfg-eno16777736 ifcfg-ens33,复制文件。

然后,执行命令编辑文件 vim ifcfg-ens33;把其中的网卡名字由原来的 eno16777736 更换为 ens33,同时确保 IP 地址是原来的地址:

IPADDR=192.168.186.128NAME=ens33DEVICE=ens33

同时执行命令删除无效网卡的配置文件 rm ifcfg-eno16777736。

然后执行重启网络的命令 systemctl restart network,接着执行 ifconfig 可以发现 IP 地址成功更换为原来的 IP 地址了:

[root@localhost network-scripts]# ifconfigens33: flags=4163  mtu 1500        inet 192.168.186.128  netmask 255.255.255.0  broadcast 192.168.186.255        inet6 fe80::20c:29ff:fe1a:6c13  prefixlen 64  scopeid 0x20        ether 00:0c:29:1a:6c:13  txqueuelen 1000  (Ethernet)        RX packets 777  bytes 57063 (55.7 KiB)        RX errors 0  dropped 0  overruns 0  frame 0        TX packets 280  bytes 31690 (30.9 KiB)        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0lo: flags=73  mtu 65536        inet 127.0.0.1  netmask 255.0.0.0        inet6 ::1  prefixlen 128  scopeid 0x10        loop  txqueuelen 0  (Local Loopback)        RX packets 4  bytes 352 (352.0 B)        RX errors 0  dropped 0  overruns 0  frame 0        TX packets 4  bytes 352 (352.0 B)        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

如果重启一次没有报错但是 IP 地址没有改变,那就再执行一次重启,以防止缓存问题。

重新使用 XShell 连接系统,第一次重新尝试连接超时的话,就关掉再来一次,同样防止缓存问题。

最后,重启系统,发现 IP 地址和网卡都正常,没有变更,可以正常地使用 XShell 远程访问 CentOS 7 系统。

想了解更多,欢迎关注我的微信公众号:Renda_Zhang

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值