ping

Why is this running like it isn't threaded?

拜拜、爱过 提交于 2019-12-19 10:12:48
问题 I'm writing a script that will ping my ip range. Here's what I have so far: lines = `ipconfig`.split("\n") thr = [] ip_line = lines.detect { |l| l=~/Ip Address/i } matcher = /\d+\.\d+\.\d+\.\d+/.match(ip_line) if matcher.length > 0 address = matcher[0] address.sub!(/\.\d+$/,"") (1 .. 254).each do |i| xaddr = address + "." + i.to_s puts "pinging #{xaddr}" thr << Thread.new { `ping #{xaddr}` } end thr.each do |t| t.join output = t.value puts output end end The thing is, this executes extremely

Connecting Real device to Android emulator

梦想与她 提交于 2019-12-19 10:07:11
问题 I am developing a network app for Android and I'm still stuck on connecting my real Android device with an device-emulator running on my desktop computer. I've created private network with a router, so the only ones connected to the network are my pc and my mobile phone, in order to avoid firewall/closed ports problems. My PC ip is 192.168.1.100 and I'm trying to ping each other so I can sea reachability of each network node. Ping works fine from my PC (not the emulator console) to the phone.

centos 7 连接无线wifi

扶醉桌前 提交于 2019-12-19 09:59:42
一、软件及硬件条件 系统:centos 7.7.1908 ,内核:3.10.0_1062.e17.x86-64,位数:64位 ,安装时选择的4.3G的标准安装附加基础设施服务器中的部分软件。 硬件:y470 笔记本一台,使用无线网卡连接wifi 二、问题的发现: 系统安装完后登陆root用户,但是没法切换到图形界面,所以打算用yum安装图形界面,但是安装时发现网络不通,于是使用ping www.baidu.com和ping 内网网关进行测试: ping: www.baidu.com: Name or service not known 三、解决过程 首先用ifconfig命令查看了网卡名,查到了2个网卡:enp7s0 和 lo。 1、怀疑是DNS没配置: 于是在/etc/resolv.conf 中配置了电信和Google的DNS,并且重启网络服务,但是问题依然没解决。 nameserver 202.96.128.86 nameserver 8.8.8.8 2、怀疑是没添加路由: 手动添加了路由,问题依然没解决,我的网关是192.168.3.1。 route add_default gw 192.168.3.1 3、怀疑是网卡配置错误: 修改了网卡onboot属性为yes,改完后发现网络服务无法启动了,并验证了跟NetworkManager.service无关。不是这个原因

ansible

喜夏-厌秋 提交于 2019-12-19 09:55:46
安装ansible: AnbleVersion2.4及更高版本可以管理包含Python2.6或更高版本的早期操作系统。 y um方式安装: yum源或rpm包来源: 埃佩尔 以及 Relases.ansible.com . $ sudo yum install ansible 您也可以自己构建一个可以分发和安装的RPM。 $ git clone https://github.com/ansible/ansible.git $ cd ./ansible $ make rpm $ sudo rpm -Uvh ./rpm-build/ansible-*.noarch.rpm 托管节点的需求 在托管节点上,需要ssh。默认情况下使用sftp。如果sftp不可用,可以在 ansible.cfg切换到scp 。您还需要Python 2(版本2.6或更高版本)或Python 3(版本3.5或更高版本)。 注 如果在远程节点上启用了SELinux,需要安装 libselinux-python。 yum install libselinux-python 默认情况下,Ansible使用位于 /usr/bin/python的解释器 。如果是 python2/3 您可能会看到以下错误: "module_stdout": "/bin/sh: /usr/bin/python: No such file or

Java InetAddress.isReachable() timeout

余生长醉 提交于 2019-12-19 06:06:47
问题 I am trying to find out if specific hosts on my network are reachable. My java code is as follows: InetAddress adr = InetAddress.getByName(host); if(adr.isReachable(3000)){ System.out.println(host + " is reachable"); } This works quite well, however if I lower the timeout to say 500ms instead, it will not designate the host reachable anymore. I plan to check quite a few hosts in a loop, so having a low timeout is quite important. If I ping the host manually from the windows command line, it

awk: hping: print difference between icmp originate/receive

谁说我不能喝 提交于 2019-12-19 04:33:12
问题 I have the following output from hping on OpenBSD: # hping --icmp-ts www.openbsd.org HPING www.openbsd.org (re0 129.128.5.194): icmp mode set, 28 headers + 0 data bytes len=46 ip=129.128.5.194 ttl=237 id=23807 icmp_seq=0 rtt=155.3 ms ICMP timestamp: Originate=22085077 Receive=22085171 Transmit=22085171 ICMP timestamp RTT tsrtt=156 len=46 ip=129.128.5.194 ttl=237 id=4150 icmp_seq=1 rtt=154.8 ms ICMP timestamp: Originate=22086078 Receive=22086171 Transmit=22086171 ICMP timestamp RTT tsrtt=155

Django and root processes

送分小仙女□ 提交于 2019-12-19 03:16:14
问题 In my Django project I need to be able to check whether a host on the LAN is up using an ICMP ping. I found this SO question which answers how to ping something in Python and this SO question which links to resources explaining how to use the sodoers file. The Setting A Device model stores an IP address for a host on the LAN, and after adding a new Device instance to the DB (via a custom view, not the admin) I envisage checking to see if the device responds to a ping using an AJAX call to an

域名错误处理 dns 地址不通

独自空忆成欢 提交于 2019-12-19 02:58:03
http://blog.163.com/sunshine_linting/blog/static/44893323201382361750455/ 可能解决问题的方法一: 在/etc/resolv.conf中添点东西 格式如下: nameserver xxx.xxx.xxx.xxx nameserver xxx.xxx.xxx.xxx 后面的ip地址是dns服务器的地址,可以添加多个地址 如: nameserver 202.106.46.151 然后 service network restart 可能解决问题的方法二: 今天在开发的同事来说,内网不能通过域名访问自己的服务器!然后做了下面的测试发现这样的问题:   [root@Aaronwang ~]# ping www.aaronw.cn   ping: unknown host www.aaronw.cn   [root@Aaronwang ~]#ping 192.168.1.1   PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.   64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.537 ms   64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.430 ms

入门必须掌握8个DOS命令

試著忘記壹切 提交于 2019-12-19 00:26:30
 一,ping   它是用来检查网络是否通畅或者网络连接速度的命令。作为一个生活在网络上的管理员或者黑客来说,ping命令是第一个必须掌握的DOS命令,它所利用的原理是这样的:网络上的机器都有唯一确定的IP地址,我们给目标IP地址发送一个数据包,对方就要返回一个同样大小的数据包,根据返回的数据包我们可以确定目标主机的存在,可以初步判断目标主机的操作系统等。下面就来看看它的一些常用的操作。先看看帮助吧,在DOS窗口中键入:ping /? 回车,。所示的帮助画面。在此,我们只掌握一些基本的很有用的参数就可以了(下同)。   -t 表示将不间断向目标IP发送数据包,直到我们强迫其停止。试想,如果你使用100M的宽带接入,而目标IP是56K的小猫,那么要不了多久,目标IP就因为承受不了这么多的数据而掉线,呵呵,一次攻击就这么简单的实现了。   -l 定义发送数据包的大小,默认为32字节,我们利用它可以最大定义到65500字节。结合上面介绍的-t参数一起使用,会有更好的效果哦。   -n 定义向目标IP发送数据包的次数,默认为3次。如果网络速度比较慢,3次对我们来说也浪费了不少时间,因为现在我们的目的仅仅是判断目标IP是否存在,那么就定义为一次吧。   说明一下,如果-t 参数和 -n参数一起使用,ping命令就以放在后面的参数为标准,比如“ping IP -t -n 3”,虽然使用了

4.ICMP协议,ping和Traceroute

柔情痞子 提交于 2019-12-18 17:56:11
1.IMCP协议介绍 前面讲到了,IP协议并不是一个可靠的协议,它不保证数据被送达,那么,自然的,保证数据送达的工作应该由其他的模块来完成。其中一个重要的模块就是ICMP(网络控制报文)协议。 当传送IP数据包发生错误--比如主机不可达,路由不可达等等,ICMP协议将会把错误信息封包,然后传送回给主机。给主机一个处理错误的机会,这 也就是为什么说建立在IP层以上的协议是可能做到安全的原因。ICMP数据包由8bit的错误类型和8bit的代码和16bit的校验和组成。而前 16bit就组成了ICMP所要传递的信息。书上的图6-3清楚的给出了错误类型和代码的组合代表的意思。 尽管在大多数情况下,错误的包传送应该给出ICMP报文,但是在特殊情况下,是不产生ICMP错误报文的。如下 ICMP差错报文不会产生ICMP差错报文(出IMCP查询报文)(防止IMCP的无限产生和传送) 目的地址是广播地址或多播地址的IP数据报。 作为链路层广播的数据报。 不是IP分片的第一片。 源地址不是单个主机的数据报。这就是说,源地址不能为零地址、环回地址、广播地 址或多播地址。 以上规则是为了防止产生ICMP报文广播风暴。 ICMP协议大致分为两类,一种是查询报文,一种是差错报文。其中查询报文有以下几种用途: ping查询(不要告诉我你不知道ping程序) 子网掩码查询