大网数据广告活动
服务器运维问答

Ping only works twice

· 52CE 我爱测

I have created a vm inside a xen host. By following this guide , I have managed to ping www.google.com, but it only ping-pongs twice before getting Destination Host Unreachable . If I restart the vm, I can again ping twice before…

问题原文

原帖链接 · SteveL · CC BY-SA 3.0

I have created a vm inside a xen host. By following this guide, I have managed to ping www.google.com, but it only ping-pongs twice before getting Destination Host Unreachable. If I restart the vm, I can again ping twice before failing.

$ - ping www.google.com

PING www.google.com (216.58.208.228) 56(84) bytes of data.
64 bytes from par10s22-in-f4.1e100.net (216.58.208.228): icmp_seq=1 ttl=51 time=17.3 ms
64 bytes from par10s22-in-f4.1e100.net (216.58.208.228): icmp_seq=2 ttl=51 time=17.4 ms
From static.12.166.76.144.clients.your-server.de (144.76.166.12): icmp_seq=3 Redirect Host(New nexthop: 144.76.166.1)
64 bytes from 216.58.208.228: icmp_seq=3 ttl=51 time=17.3 ms
From wservervm (144.76.166.25) icmp_seq=4 Destination Host Unreachable
From wservervm (144.76.166.25) icmp_seq=5 Destination Host Unreachable
From wservervm (144.76.166.25) icmp_seq=6 Destination Host Unreachable
From wservervm (144.76.166.25) icmp_seq=7 Destination Host Unreachable
From wservervm (144.76.166.25) icmp_seq=8 Destination Host Unreachable
From wservervm (144.76.166.25) icmp_seq=9 Destination Host Unreachable
From wservervm (144.76.166.25) icmp_seq=10 Destination Host Unreachable
From wservervm (144.76.166.25) icmp_seq=11 Destination Host Unreachable
From wservervm (144.76.166.25) icmp_seq=12 Destination Host Unreachable

The ip of the host(the external thats is used to access the server from outside) is used as a default gateway for the vm. I dont know what other information to give. What could be the reason for this?

The output of arp -n for the guest is:

Address                  HWtype  HWaddress           Flags Mask            Iface
144.76.166.12            ether   d4:3d:7e:ec:ef:f8   C                     eth0
144.76.166.1                     (incomplete)                              eth0

and for the host:

Address                  HWtype  HWaddress           Flags Mask            Iface
144.76.166.27                    (incomplete)                              xenbr0
144.76.166.1             ether   cc:e1:7f:ac:52:96   C                     xenbr0
144.76.166.25            ether   00:16:3e:b0:23:21   C                     xenbr0
144.76.166.28                    (incomplete)                              xenbr0
144.76.166.29                    (incomplete)                              xenbr0

/etc/network/interfaces of the host

# loopback
auto lo
iface lo inet loopback

# physical network interface
auto  eth0
iface eth0 inet manual

# bridge public
auto xenbr0
iface xenbr0 inet static
  address   144.76.166.12
  netmask   255.255.255.224
  gateway   144.76.166.1
  bridge_ports eth0
  bridge_stp off       # disable Spanning Tree Protocol
  bridge_waitport 0    # no delay unless port available
  bridge_fd 0          # no forwarding delay
# up route add -net 188.40.103.64 netmask 255.255.255.192 gw 188.40.103.65 eth0

# bridge internal
auto xenbr1
iface xenbr1 inet static
  address   10.0.10.1
  broadcast 10.0.10.255
  netmask   255.255.255.0
  pre-up brctl addbr xenbr1

# ipv6
iface eth0 inet6 static
  address 2a01:4f8:200:420b::2
  netmask 64
  gateway fe80::1

brctl show:

bridge name bridge id       STP enabled interfaces
xenbr0      8000.d43d7eeceff8   no      eth0
                            vif6.0
xenbr1      8000.000000000000   no      

I think the main thing to focus here is that it successfully ping-pongs two times before failing.

已采纳解答

原帖链接 · Fira · CC BY-SA 3.0

You're either routing or bridging when providing access to a domain. It looks like you're attempting to do both at the same time, and chances are that triggers the redirect and indirectly breaks connectivity because of your firewall rules.

Consider the following cases:

  • You do Bridging. Packets are ran through the iptables FORWARD chain and delivered directly from your host to guest, without actual routing. It's important to know that FORWARD chain applies even for bridging by default. Usually providers will ask you to bind a specific Virtual MAC address for this to work for security reasons (spoofing & al).

  • You do Routing. Packets are ran through the iptables FORWARD chain and then routed using the kernel routing table to the correct destination. Usually this means you're using addresses of a different subnet or /32 single-addresses with routing handled specificly by the provider.

Here, you're doing a bit of both:

  • You have a bridge connecting the DomU to Host's Connection
  • Yet the DomU attempts to route through the Host to reach the provider gateway
  • The provider realizes this, maybe because it doesn't use the indicated Virtual MAC address if you've set one, and sends an ICMP REDIRECT message to notify the guest of what's happening

I'm not sure why this doesn't work exactly, considering ICMP Redirect is disabled on almost all major Linux distributions out of the box, and should work despite the problems asymetric routing can bring. This is probably a problem with the provider's gateway being too picky with ARP & MAC changes somehow...

Either way, since your Dom0 and DomU IP addresses are both in the same netmask, you have to do full bridging in your case. Simply correct the gateway address of the DomU to point toward .1, the provider gateway. Don't forget to adjust firewall rules as neccessary, as even bridged packets go through the FORWARD chain by default.

Source: I run Xen on a test box that provides access to different domains through NAT'ing, Bridging, and routing depending on domain

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-03-08)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。