[英]Why does the Python3 ipaddress.IPv6Network.hosts function omit the first and last IPv6 address?
[英]Python ping list of IPv6 hosts and make a dictionary of reachable and unreachable hosts with time
下面的脚本对于IPv4来说可以正常工作,但是我的工作是对IPv6进行同样的操作。
#!/usr/bin/python
import pyping
response = pyping.ping('8.8.8.8')
if response.ret_code == 0:
print("reachable")
else:
print("unreachable")
有没有办法..我试图安装aioping或aio_ping ..但没有成功,..是否有任何替代方法可以在Linux机器上针对IPv6运行与上述相同的方法
使用multi-ping ( pip install multiping
)文档中的示例:
from multiping import MultiPing
# Create a MultiPing object
mp = MultiPing(["2a00:1450:4005:803::200e"])
# Send the pings to those addresses
mp.send()
# With a 1 second timout, wait for responses (may return sooner if all
# results are received).
responses, no_responses = mp.receive(1)
if responses:
print("reachable: %s" % responses)
if no_responses:
print("unreachable: %s" % no_responses)
请查看文档,以了解如何构造responses
/ no_responses
以及如何同时ping通多个地址。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.