Skip to content

Instantly share code, notes, and snippets.

@optman
optman / dig gist.github.com on xxx vps
Last active October 10, 2015 03:15
resolve gist.github.com name
root@VPS1:~# dig gist.github.com @8.8.8.8
; <<>> DiG 9.8.1-P1 <<>> gist.github.com @8.8.8.8
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 33582
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;gist.github.com. IN A
@optman
optman / fping
Last active October 9, 2015 09:59
find all alive machines in a subnet.
optman@ubuntu:~$ fping -aq -d -g 192.168.199.0/24
Hiwifi.lan
192.168.199.3
Smartisan-T1.lan
android-3756d69fca495fb4.lan
p2p-pi.lan
optman@ubuntu:~$ mtr -rw www.google.com
Start: Fri Oct 9 17:37:41 2015
HOST: ubuntu Loss% Snt Last Avg Best Wrst StDev
1.|-- Hiwifi.lan 0.0% 10 0.5 0.4 0.3 0.6 0.0
2.|-- 10.10.10.1 0.0% 10 5.4 5.9 5.2 10.4 1.6
3.|-- 10.0.6.1 70.0% 10 88.7 100.8 88.7 124.9 20.9
4.|-- 106.187.33.2 70.0% 10 92.3 99.2 85.8 119.5 17.8
5.|-- 124.215.199.169 70.0% 10 98.1 100.8 98.1 104.6 3.3
6.|-- otejbb206.int-gw.kddi.ne.jp 80.0% 10 88.7 88.5 88.3 88.7 0.0
7.|-- ix-ote213.int-gw.kddi.ne.jp 80.0% 10 86.6 86.9 86.6 87.2 0.0
optman@ubuntu:~$ iperf -c 10.10.10.1 -d
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)
------------------------------------------------------------
------------------------------------------------------------
Client connecting to 10.10.10.1, TCP port 5001
TCP window size: 85.0 KByte (default)
------------------------------------------------------------
[ 5] local 192.168.199.3 port 54435 connected with 10.10.10.1 port 5001
@optman
optman / nload
Created October 9, 2015 09:53
nload
Device eth0 [192.168.1.2] (1/4):
================================================================================
Incoming:
Curr: 2.11 MBit/s
Avg: 1.14 MBit/s
pi@pi2 ~ $ sudo netstat -tunp
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 192.168.1.2:1723 111.206.27.194:40221 ESTABLISHED 14026/pptpd [111.20
tcp 0 232 192.168.1.2:22 111.206.27.194:62388 ESTABLISHED 13660/sshd: pi [pri
tcp 0 0 192.168.1.2:54861 106.185.54.176:1723 ESTABLISHED 13735/pptp
pi@pi2 ~ $ sudo netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
@optman
optman / ip_conntrack
Created October 9, 2015 10:15
use instead of netstat -M
pi@pi2 ~ $ sudo cat /proc/net/ip_conntrack
tcp 6 47 TIME_WAIT src=10.10.10.234 dst=123.125.105.246 sport=63062 dport=80 src=123.125.105.246 dst=192.168.1.2 sport=80 dport=63062 [ASSURED] mark=0 use=2
udp 17 55 src=10.10.10.234 dst=10.10.10.1 sport=41984 dport=53 src=10.10.10.1 dst=10.10.10.234 sport=53 dport=41984 [ASSURED] mark=0 use=2
udp 17 73 src=10.10.10.234 dst=10.10.10.1 sport=32966 dport=53 src=10.10.10.1 dst=10.10.10.234 sport=53 dport=32966 [ASSURED] mark=0 use=2
tcp 6 431737 ESTABLISHED src=10.10.10.234 dst=111.206.200.2 sport=50459 dport=5222 src=111.206.200.2 dst=192.168.1.2 sport=5222 dport=50459 [ASSURED] mark=0 use=2
tcp 6 431658 ESTABLISHED src=10.10.10.234 dst=123.58.180.78 sport=38317 dport=6002 src=123.58.180.78 dst=192.168.1.2 sport=6002 dport=38317 [ASSURED] mark=0 use=2
udp 17 24 src=10.10.10.234 dst=8.8.4.4 sport=52636 dport=53 src=8.8.4.4 dst=10.0.6.5 sport=53 dport=52636 mark=0 use=2
udp 17 11 src=10.10.10.234 dst=114.114.114.114 sport=51715 dport=5
@optman
optman / pi@pi2 ~ $ sudo traceroute -T 221.194.130.209
Last active October 12, 2015 07:44
traceroute download.microsoft.com
pi@pi2 ~ $ sudo traceroute -T 221.194.130.209
traceroute to 221.194.130.209 (221.194.130.209), 30 hops max, 60 byte packets
1 localhost (192.168.1.1) 0.882 ms 0.682 ms 0.706 ms
2 * * *
3 61.148.163.205 (61.148.163.205) 15.087 ms 14.741 ms 14.398 ms
4 124.65.56.157 (124.65.56.157) 20.646 ms 20.313 ms 19.971 ms
5 124.65.194.13 (124.65.194.13) 19.619 ms 19.271 ms 18.926 ms
6 * * *
7 pppa174.sj.he.cn (202.99.160.174) 20.141 ms pppa214.sj.he.cn (202.99.160.214) 31.130 ms pppa218.sj.he.cn (202.99.160.218) 37.270 ms
8 218.12.255.194 (218.12.255.194) 29.148 ms 24.036 ms 28.062 ms
client(199.3) <-> router(199.1)<-> chinadns(199.3)
//client -> router
10:52:02.298528 IP 192.168.199.3.52133 > Hiwifi.lan.domain: 46227+ [1au] A? www.douban.com. (43)
//router -> chinadns
10:52:02.299806 IP Hiwifi.lan.44563 > 192.168.199.3.domain: 19371+ [1au] A? www.douban.com. (43)
//chinadns -> uper
10:52:02.299936 IP 192.168.199.3.34984 > public1.114dns.com.domain: 16780+ [1au] A? www.douban.com. (43)
//dig @8.8.8.8
11:08:48.254393 IP (tos 0x0, ttl 64, id 24379, offset 0, flags [none], proto UDP (17), length 71)
192.168.199.3.49860 > 8.8.8.8.53: 50653+ [1au] A? www.google.com. (43)
11:08:48.413252 IP (tos 0x0, ttl 38, id 5516, offset 0, flags [none], proto UDP (17), length 87)
8.8.8.8.53 > 192.168.199.3.49860: 50653 1/0/1 www.google.com. A 216.58.221.132 (59)
//dig @192.168.199.1 (which's dns is point to 8.8.8.8)
11:09:17.174259 IP (tos 0x0, ttl 64, id 16284, offset 0, flags [none], proto UDP (17), length 71)
192.168.199.3.44789 > 192.168.199.1.53: 53494+ [1au] A? www.google.com. (43)
11:09:17.175213 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 151)