来自 openvz VM 的 Ping 不可用

发布于 2024-10-08 07:21:46 字数 2811 浏览 2 评论 0原文

这个 openvz 盒子几周前工作正常,现在却无法 ping 通外界。

我不是网络专家,我认为最初的工作设置会持续更长时间。

另一个奇怪的事情是这个虚拟机的网络服务可以从外部获得。

Ping 网络接口:

vz:/# ping 88.191.118.xxx
PING 88.191.118.xxx (88.191.118.xxx) 56(84) bytes of data.
64 bytes from 88.191.118.xxx: icmp_req=1 ttl=64 time=0.048 ms
64 bytes from 88.191.118.xxx: icmp_req=2 ttl=64 time=0.043 ms
--- 88.191.118.xxx ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.043/0.045/0.048/0.007 ms

Ping google:

vz:/# ping 74.125.230.83
PING 74.125.230.83 (74.125.230.83) 56(84) bytes of data.
--- 74.125.230.83 ping statistics ---
4 packets transmitted, 0 received, 100% packet loss, time 3023ms

ifconfig:

vz:/# ifconfig
lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:59 errors:0 dropped:0 overruns:0 frame:0
          TX packets:59 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:5507 (5.3 KiB)  TX bytes:5507 (5.3 KiB)

venet0    Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          inet addr:127.0.0.1  P-t-P:127.0.0.1  Bcast:0.0.0.0  Mask:255.255.255.255
          UP BROADCAST POINTOPOINT RUNNING NOARP  MTU:1500  Metric:1
          RX packets:89 errors:0 dropped:0 overruns:0 frame:0
          TX packets:584 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:20938 (20.4 KiB)  TX bytes:395767 (386.4 KiB)

venet0:0  Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          inet addr:192.168.23.101  P-t-P:192.168.23.101  Bcast:0.0.0.0  Mask:255.255.255.255
          UP BROADCAST POINTOPOINT RUNNING NOARP  MTU:1500  Metric:1

路由:

vz:/# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.0.2.1       0.0.0.0         255.255.255.255 UH    0      0        0 venet0
0.0.0.0         192.0.2.1       0.0.0.0         UG    0      0        0 venet0

主机上的 iptable:

iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
fail2ban-ssh  tcp  --  anywhere             anywhere            multiport dports ssh 

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         

Chain fail2ban-ssh (1 references)
target     prot opt source               destination         
RETURN     all  --  anywhere             anywhere 

This openvz box was working properly few weeks ago, and now it can't ping the outside world.

I'm not expert on networking, and I thought the initial working setup will last longer.

Another stange stuff is that web services of this VM are available from outside.

Ping network interface:

vz:/# ping 88.191.118.xxx
PING 88.191.118.xxx (88.191.118.xxx) 56(84) bytes of data.
64 bytes from 88.191.118.xxx: icmp_req=1 ttl=64 time=0.048 ms
64 bytes from 88.191.118.xxx: icmp_req=2 ttl=64 time=0.043 ms
--- 88.191.118.xxx ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.043/0.045/0.048/0.007 ms

Ping google:

vz:/# ping 74.125.230.83
PING 74.125.230.83 (74.125.230.83) 56(84) bytes of data.
--- 74.125.230.83 ping statistics ---
4 packets transmitted, 0 received, 100% packet loss, time 3023ms

ifconfig:

vz:/# ifconfig
lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:59 errors:0 dropped:0 overruns:0 frame:0
          TX packets:59 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:5507 (5.3 KiB)  TX bytes:5507 (5.3 KiB)

venet0    Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          inet addr:127.0.0.1  P-t-P:127.0.0.1  Bcast:0.0.0.0  Mask:255.255.255.255
          UP BROADCAST POINTOPOINT RUNNING NOARP  MTU:1500  Metric:1
          RX packets:89 errors:0 dropped:0 overruns:0 frame:0
          TX packets:584 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:20938 (20.4 KiB)  TX bytes:395767 (386.4 KiB)

venet0:0  Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          inet addr:192.168.23.101  P-t-P:192.168.23.101  Bcast:0.0.0.0  Mask:255.255.255.255
          UP BROADCAST POINTOPOINT RUNNING NOARP  MTU:1500  Metric:1

Routes:

vz:/# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.0.2.1       0.0.0.0         255.255.255.255 UH    0      0        0 venet0
0.0.0.0         192.0.2.1       0.0.0.0         UG    0      0        0 venet0

iptable on host:

iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
fail2ban-ssh  tcp  --  anywhere             anywhere            multiport dports ssh 

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         

Chain fail2ban-ssh (1 references)
target     prot opt source               destination         
RETURN     all  --  anywhere             anywhere 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

错爱 2024-10-15 07:21:46

已解决:两周前重新启动了盒子,并且 iptables 脚本未启动。

当前的firewall.sh脚本:

sd-20628:~# more firewall.sh 
#!/bin/bash
IPTABLES='/sbin/iptables';

VZ101_WEB="192.168.23.101";

LAN="192.168.23.0/24";

WAN_IFACE="eth0";
WAN_IP="88.191.xxx.xxx";

# Flushing tables
$IPTABLES -F
$IPTABLES -X
$IPTABLES -t nat -F

# Define default policy
$IPTABLES -P INPUT DROP
$IPTABLES -P OUTPUT ACCEPT
$IPTABLES -P FORWARD ACCEPT

$IPTABLES -A INPUT -j ACCEPT -d $LAN;
$IPTABLES -A INPUT -j ACCEPT -m state --state ESTABLISHED,RELATED
$IPTABLES -A INPUT -j ACCEPT -p tcp --dport 22
$IPTABLES -A INPUT -j ACCEPT -p tcp --dport 80
$IPTABLES -A INPUT -j ACCEPT -p tcp --dport 9102
$IPTABLES -A INPUT -j ACCEPT -p icmp


# SSH in VZ access
$IPTABLES -t nat -A PREROUTING -p tcp --dport 22101 -d $WAN_IP -j DNAT --to-destination $VZ101_WEB:22

Solved: the box was rebooted 2 weeks ago, and the iptables script was not launched.

Current firewall.sh script:

sd-20628:~# more firewall.sh 
#!/bin/bash
IPTABLES='/sbin/iptables';

VZ101_WEB="192.168.23.101";

LAN="192.168.23.0/24";

WAN_IFACE="eth0";
WAN_IP="88.191.xxx.xxx";

# Flushing tables
$IPTABLES -F
$IPTABLES -X
$IPTABLES -t nat -F

# Define default policy
$IPTABLES -P INPUT DROP
$IPTABLES -P OUTPUT ACCEPT
$IPTABLES -P FORWARD ACCEPT

$IPTABLES -A INPUT -j ACCEPT -d $LAN;
$IPTABLES -A INPUT -j ACCEPT -m state --state ESTABLISHED,RELATED
$IPTABLES -A INPUT -j ACCEPT -p tcp --dport 22
$IPTABLES -A INPUT -j ACCEPT -p tcp --dport 80
$IPTABLES -A INPUT -j ACCEPT -p tcp --dport 9102
$IPTABLES -A INPUT -j ACCEPT -p icmp


# SSH in VZ access
$IPTABLES -t nat -A PREROUTING -p tcp --dport 22101 -d $WAN_IP -j DNAT --to-destination $VZ101_WEB:22
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文