我有一台 centos 机器,它有两个网络接口,分别用于 162.* 和 172.* 子网。这台机器以前工作正常,但从今天起,172.* 网络已无法访问。我不知道发生了什么变化,以前的配置是什么。以下是 ifconfig、ip route 和 ip link 的输出以及 /etc/sysconfig/network-scripts 下的接口文件的内容
ifconfig -a
eno16777984: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 162.70.42.93 netmask 255.255.255.0 broadcast 162.70.42.255
ether 00:50:56:ba:b0:83 txqueuelen 1000 (Ethernet)
RX packets 1935793 bytes 195710508 (186.6 MiB)
RX errors 0 dropped 16501 overruns 0 frame 0
TX packets 638906 bytes 47382225 (45.1 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eno33557248: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::250:56ff:feba:6875 prefixlen 64 scopeid 0x20<link>
ether 00:50:56:ba:68:75 txqueuelen 1000 (Ethernet)
RX packets 147161 bytes 8837081 (8.4 MiB)
RX errors 0 dropped 639 overruns 0 frame 0
TX packets 8098 bytes 1436275 (1.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
loop txqueuelen 0 (Local Loopback)
RX packets 318746 bytes 17084987 (16.2 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 318746 bytes 17084987 (16.2 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ip route
default via 162.70.42.1 dev eno16777984 proto static metric 100
162.70.42.0/24 dev eno16777984 proto kernel scope link src 162.70.42.93 metric 100
ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eno16777984: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT qlen 1000
link/ether 00:50:56:ba:b0:83 brd ff:ff:ff:ff:ff:ff
3: eno33557248: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT qlen 1000
link/ether 00:50:56:ba:68:75 brd ff:ff:ff:ff:ff:ff
/etc/sysconfig/network-scripts/ifcfg-eno33557248:
TYPE="Ethernet"
BOOTPROTO="none"
DEFROUTE=no
IPV4_FAILURE_FATAL=yes
IPV6INIT="no"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_PEERDNS="yes"
IPV6_PEERROUTES="yes"
IPV6_FAILURE_FATAL="no"
NAME=eno33557248
UUID="e157d343-3acb-4498-8ab2-83251bf5e098"
ONBOOT="yes"
HWADDR=00:50:56:BA:68:75
IPADDR=172.16.3.2
PREFIX=24
GATEWAY=172.16.3.1
/etc/sysconfig/network-scripts/ ifcfg-eno16777984:
TYPE="Ethernet"
BOOTPROTO="none"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="no"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_PEERDNS="yes"
IPV6_PEERROUTES="yes"
IPV6_FAILURE_FATAL="no"
NAME="eno16777984"
UUID="e157d343-3acb-4498-8ab2-83251bf5e098"
ONBOOT="yes"
HWADDR="00:50:56:BA:B0:83"
DNS1="162.70.113.10"
DNS2="162.70.113.11"
IPADDR=162.70.42.93
PREFIX=24
GATEWAY=162.70.42.1
ZONE=public
ifconfig eno33557248 关闭
Feb 16 17:01:46 sassy-admin-uat NetworkManager[692]: <info> (eno33557248): link disconnected
Feb 16 17:01:46 sassy-admin-uat NetworkManager[692]: <info> (eno33557248): device state change: disconnected -> unavailable (reason 'carrier-changed') [30 20 40]
ifconfig eno33557248 启动
eb 16 17:01:54 sassy-admin-uat kernel: vmxnet3 0000:0b:00.0 eno33557248: intr type 3, mode 0, 5 vectors allocated
Feb 16 17:01:54 sassy-admin-uat kernel: vmxnet3 0000:0b:00.0 eno33557248: NIC Link is Up 10000 Mbps
Feb 16 17:01:54 sassy-admin-uat NetworkManager[692]: <info> (eno33557248): link connected
Feb 16 17:01:54 sassy-admin-uat NetworkManager[692]: <info> (eno33557248): device state change: unavailable -> disconnected (reason 'carrier-changed') [20 30 40]
Feb 16 17:01:54 sassy-admin-uat NetworkManager[692]: <info> Auto-activating connection 'Wired connection 1'.
Feb 16 17:01:54 sassy-admin-uat NetworkManager[692]: <info> (eno33557248): Activation: starting connection 'Wired connection 1' (529d729a-48e0-4ecb-94d0-07dc43dca703)
Feb 16 17:01:54 sassy-admin-uat NetworkManager[692]: <info> (eno33557248): device state change: disconnected -> prepare (reason 'none') [30 40 0]
Feb 16 17:01:54 sassy-admin-uat NetworkManager[692]: <info> (eno33557248): device state change: prepare -> config (reason 'none') [40 50 0]
Feb 16 17:01:54 sassy-admin-uat NetworkManager[692]: <info> (eno33557248): device state change: config -> ip-config (reason 'none') [50 70 0]
Feb 16 17:01:54 sassy-admin-uat NetworkManager[692]: <info> Activation (eno33557248) Beginning DHCPv4 transaction (timeout in 45 seconds)
Feb 16 17:01:54 sassy-admin-uat NetworkManager[692]: <info> dhclient started with pid 12676
Feb 16 17:01:54 sassy-admin-uat dhclient[12676]: DHCPDISCOVER on eno33557248 to 255.255.255.255 port 67 interval 5 (xid=0x74c85128)
Feb 16 17:01:56 sassy-admin-uat avahi-daemon[621]: Registering new address record for fe80::250:56ff:feba:6875 on eno33557248.*.
Feb 16 17:01:59 sassy-admin-uat dhclient[12676]: DHCPDISCOVER on eno33557248 to 255.255.255.255 port 67 interval 5 (xid=0x74c85128)
Feb 16 17:02:04 sassy-admin-uat dhclient[12676]: DHCPDISCOVER on eno33557248 to 255.255.255.255 port 67 interval 13 (xid=0x74c85128)
Feb 16 17:02:17 sassy-admin-uat dhclient[12676]: DHCPDISCOVER on eno33557248 to 255.255.255.255 port 67 interval 17 (xid=0x74c85128)
Feb 16 17:02:34 sassy-admin-uat dhclient[12676]: DHCPDISCOVER on eno33557248 to 255.255.255.255 port 67 interval 17 (xid=0x74c85128)
Feb 16 17:02:40 sassy-admin-uat NetworkManager[692]: <warn> (eno33557248): DHCPv4 request timed out.
Feb 16 17:02:40 sassy-admin-uat NetworkManager[692]: <info> (eno33557248): DHCPv4 state changed unknown -> timeout
Feb 16 17:02:40 sassy-admin-uat NetworkManager[692]: <info> (eno33557248): canceled DHCP transaction, DHCP client pid 12676
Feb 16 17:02:40 sassy-admin-uat NetworkManager[692]: <info> (eno33557248): DHCPv4 state changed timeout -> done
Feb 16 17:02:40 sassy-admin-uat NetworkManager[692]: <info> (eno33557248): device state change: ip-config -> failed (reason 'ip-config-unavailable') [70 120 5]
答案1
我在 ifconfig 命令的输出中没有看到 IPv4 (inet) 地址。看来您的 eno33557248 接口只有一个 IPv6 (inet6) 地址。
eno16777984: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 162.70.42.93 netmask 255.255.255.0 broadcast 162.70.42.255
ether 00:50:56:ba:b0:83 txqueuelen 1000 (Ethernet)
eno33557248: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 .
inet6 fe80::250:56ff:feba:6875 prefixlen 64 scopeid 0x20<link>
ether 00:50:56:ba:68:75 txqueuelen 1000 (Ethernet)
如果您使用的是静态寻址,而不是 DHCP,请查看您的 ipcfg(可能是 /etc/sysconfig/network-scripts/ipcfg-eno33557248)以确保地址已配置。然后,“ifconfig eno33557248 down”和“ifconfig eno33557248 up”应该会将其恢复。