ping 非本地子网时报"ping: sendmsg: Network Is Down"

来源:互联网 发布:好收益网络贷款 编辑:程序博客网 时间:2024/05/17 05:02

Oracle Linux: Ping to IP address on non-local subnet returns "ping: sendmsg: Network Is Down" (文档 ID 1625215.1)


APPLIES TO:

Linux OS - Version Oracle Linux 5.9 with Unbreakable Enterprise Kernel [2.6.39] and later
Linux x86
Linux x86-64

SYMPTOMS

Issuing a ping(8) to an IP address on a non-local subnet reports “network is down” message as described below.
However, other applications/utilities e.g. ssh(1)sftp(1), etc. successfully connect to the same IP address that ping reported as unavailable.
All pings to hosts on the local network connect successfully..

# cat /etc/sysconfig/network/scripts/ifcfg-eth0
BROADCAST=192.168.xx.255
IPADDR=192.168.xx.18
NETMASK=255.255.255.0
NETWORK=192.168.xx.0
ONBOOT=yes
GATEWAY=192.168.xx.1

# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.xx.0    192.168.xx.1    255.255.255.0   U     0      0        0 eth0
0.0.0.0         192.168.xx.1    0.0.0.0         UG    0      0        0 eth0

$ ping 192.168.xx.12
PING 192.168.xx.12  56(84) bytes of data.
ping: sendmsg: Network is down
ping: sendmsg: Network is down
ping: sendmsg: Network is down
ping: sendmsg: Network is down
ping: sendmsg: Network is down
ping: sendmsg: Network is down

CAUSE

Above, IP address 192.168.xx.12 resides in a non-local network.
Ping, a part of the iputils package, is a basic network diagnostic utility that uses Internet Control Message Protocol (ICMP) to communicate to a specified network host to discover whether the system is alive and receiving network traffic.
Where the ping target happens resides on a non-local network, ICMP packets must traverse the default gateway router to reach the host.
In some instances, however, routers may not enable ICMP redirect functionality necessary for ping to reach the target system, therefore ping reports the non-local network as down.
The following Cisco reference discusses ICMP redirect: http://www.cisco.com/en/US/tech/tk365/technologies_tech_note09186a0080094702.shtml

SOLUTION

To address the issue, configure static routes to targets on the non-local network (192.168.xx.0/24 in this instance) on hosts within the local network (192.168.70.0 in this instance) to avoid the need for ICMP redirection.

Perform the following to configure a static route, ensuring to modify file names and content to reflect your own requirements):

1. Create a file file in which to define static routes for the relevant network interface e.g. /etc/sysconfig/network-scripts/route-eth0

# touch /etc/sysconfig/network-scripts/route-eth0

2. Add the following line to file /etc/sysconfig/network-scripts/route-eth0 , replace <gateway_ip_which_can_get_to_192.168.xx.12> to a gateway to access for non-local network 192.168.xx.0/24

192.168.71.0/24 via <gateway_ip_which_can_get_to_192.168.71.12> dev eth0

3. Save the file, then restart the network srvice (or reboot the server):

# /sbin/service network restart

4. Use the route(8) command to verify the new routing table entry:

# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.xx.0    192.168.xx.1    255.255.255.0   U     0      0        0 eth0
192.168.xx.0    <another gateway>   255.255.255.0   UG    0      0        0 eth0
0.0.0.0         192.168.xx.1    0.0.0.0         UG    0      0        0 eth0

With the new static route in place, ping ICMP packets will directly access remote network gateway router <another gateway> rather than the default local gateway router 192.168.70.1.


0 0
原创粉丝点击