{ "version": "https://jsonfeed.org/version/1.1", "user_comment": "This feed allows you to read the posts from this site in any feed reader that supports the JSON Feed format. To add this feed to your reader, copy the following URL -- https://matoken.org/blog/tag/ping/feed/json -- and add it your reader.", "home_page_url": "https://matoken.org/blog/tag/ping", "feed_url": "https://matoken.org/blog/tag/ping/feed/json", "language": "ja", "title": "ping – matoken's blog", "description": "Is there no plan B?", "icon": "https://matoken.org/blog/wp-content/uploads/2025/03/cropped-1865f695c4eecc844385acef2f078255036adccd42c254580ea3844543ab56d9.jpeg", "items": [ { "id": "https://matoken.org/blog/?p=4131", "url": "https://matoken.org/blog/2024/10/14/tcping-to-check-communication-with-tcp-port/", "title": "TCP port\u306b\u5bfe\u3057\u3066\u758e\u901a\u78ba\u8a8d\u3092\u3059\u308btcping", "content_html": "
\ntcping \u3068\u3044\u3046 TCP port \u3067 ping \u306e\u3088\u3046\u306a\u52d5\u4f5c\u3092\u3059\u308b\u30c4\u30fc\u30eb\u3092\u77e5\u3063\u305f\u306e\u3067\u8a66\u3057\u3066\u307f\u307e\u3057\u305f\uff0e
\n
\u5c0e\u5165\u306freleases\u30da\u30fc\u30b8\u304b\u3089\u74b0\u5883\u306b\u5408\u3063\u305f\u30d0\u30a4\u30ca\u30ea\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\uff0cdocker\uff0cgo install\uff0cbrew\uff0csource \u304b\u3089make \u304c\u7d39\u4ecb\u3055\u308c\u3066\u3044\u307e\u3059\uff0e\u4eca\u56de\u306f go install \u3092\u5229\u7528\u3057\u307e\u3057\u305f\uff0e
\n$ go install github.com/pouriyajamshidi/tcping@latest\n$ which tcping\n/home/matoken/go/bin/tcping\n$ ls -l `!!`\nls -l `which tcping `\n-rwxrwxr-x 1 matoken matoken 8897290 Oct 13 06:13 /home/matoken/go/bin/tcping\n
$ tcping --help\n\nTCPING version 1.21.2\n\nTry running tcping like:\ntcping <hostname/ip> <port number>. For example:\ntcping www.example.com 443\n\n[optional flags]\n -4 : use IPv4 only.\n -6 : use IPv6 only.\n -j : output in JSON format.\n --pretty : use indentation when using json output format. No effect without the -j flag.\n -r : retry resolving target's hostname after <n> number of failed requests. e.g. -r 10 for 10 failed probes.\n -u : check for updates.\n -v : show version.\n
$ python -m http.server -b 127.0.0.1 -d `mktemp -d` 8000 &\n[1] 3553818\nServing HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...\n\n$ tcping localhost 8000\nTCPinging localhost on port 8000\nReply from localhost (127.0.0.1) on port 8000 TCP_conn=1 time=0.136 ms\nReply from localhost (127.0.0.1) on port 8000 TCP_conn=2 time=0.148 ms\nReply from localhost (127.0.0.1) on port 8000 TCP_conn=3 time=0.224 ms\nReply from localhost (127.0.0.1) on port 8000 TCP_conn=4 time=0.851 ms\n^C\n--- localhost (127.0.0.1) TCPing statistics ---\n4 probes transmitted on port 8000 | 4 received, 0.00% packet loss\nsuccessful probes: 4\nunsuccessful probes: 0\nlast successful probe: 2024-10-14 04:45:57\nlast unsuccessful probe: Never failed\ntotal uptime: 4 seconds\ntotal downtime: 0 second\nlongest consecutive uptime: 4 seconds from 2024-10-14 04:45:54 to 2024-10-14 04:45:57\nretried to resolve hostname 0 times\nrtt min/avg/max: 0.136/0.340/0.851 ms\n--------------------------------------\nTCPing started at: 2024-10-14 04:45:54\nTCPing ended at: 2024-10-14 04:45:57\nduration (HH:MM:SS): 00:00:03\n\n$ kill %1\n
$ tcping localhost 22\nTCPinging localhost on port 22\nReply from localhost (::1) on port 22 TCP_conn=1 time=0.250 ms\nReply from localhost (::1) on port 22 TCP_conn=2 time=0.146 ms\nReply from localhost (::1) on port 22 TCP_conn=3 time=0.116 ms\nReply from localhost (::1) on port 22 TCP_conn=4 time=0.125 ms\n^C\n--- localhost (::1) TCPing statistics ---\n4 probes transmitted on port 22 | 4 received, 0.00% packet loss\nsuccessful probes: 4\nunsuccessful probes: 0\nlast successful probe: 2024-10-14 04:46:06\nlast unsuccessful probe: Never failed\ntotal uptime: 4 seconds\ntotal downtime: 0 second\nlongest consecutive uptime: 4 seconds from 2024-10-14 04:46:03 to 2024-10-14 04:46:06\nretried to resolve hostname 0 times\nrtt min/avg/max: 0.116/0.159/0.250 ms\n--------------------------------------\nTCPing started at: 2024-10-14 04:46:03\nTCPing ended at: 2024-10-14 04:46:06\nduration (HH:MM:SS): 00:00:03\n
$ tcping -j localhost 22 | jq .\n{\n \"type\": \"start\",\n \"message\": \"TCPinging localhost on port 22\",\n \"timestamp\": \"2024-10-14T04:48:32.714879161+09:00\",\n \"hostname\": \"localhost\",\n \"port\": 22\n}\n{\n \"type\": \"probe\",\n \"message\": \"Reply from localhost (127.0.0.1) on port 22\",\n \"timestamp\": \"2024-10-14T04:48:32.715343413+09:00\",\n \"addr\": \"127.0.0.1\",\n \"hostname\": \"localhost\",\n \"is_ip\": false,\n \"port\": 22,\n \"success\": true,\n \"latency\": 0.19192,\n \"total_successful_probes\": 1\n}\n^C\n$ sudo tcpdump -i lo tcp port 8000\ntcpdump: verbose output suppressed, use -v[v]... for full protocol decode\nlistening on lo, link-type EN10MB (Ethernet), snapshot length 262144 bytes\n05:13:01.427935 IP6 localhost.40168 > localhost.http-alt: Flags [S], seq 1037512037, win 65476, options [mss 65476,sackOK,TS val 3135501668 ecr 0,nop,wscale 7], length 0\n05:13:01.427970 IP6 localhost.http-alt > localhost.40168: Flags [R.], seq 0, ack 1037512038, win 0, length 0\n05:13:02.428466 IP6 localhost.40170 > localhost.http-alt: Flags [S], seq 1664447724, win 65476, options [mss 65476,sackOK,TS val 3135502669 ecr 0,nop,wscale 7], length 0\n05:13:02.428497 IP6 localhost.http-alt > localhost.40170: Flags [R.], seq 0, ack 1664447725, win 0, length 0\n05:13:03.428880 IP6 localhost.43762 > localhost.http-alt: Flags [S], seq 3418125052, win 65476, options [mss 65476,sackOK,TS val 3135503669 ecr 0,nop,wscale 7], length 0\n05:13:03.428896 IP6 localhost.http-alt > localhost.43762: Flags [R.], seq 0, ack 3418125053, win 0, length 0\n05:13:04.429298 IP6 localhost.43778 > localhost.http-alt: Flags [S], seq 1854699496, win 65476, options [mss 65476,sackOK,TS val 3135504670 ecr 0,nop,wscale 7], length 0\n05:13:04.429373 IP6 localhost.http-alt > localhost.43778: Flags [R.], seq 0, ack 1854699497, win 0, length 0\n
\u3068\u3044\u3046\u611f\u3058\u3067 TCP port \u3092\u4f7f\u3063\u3066\u758e\u901a\u78ba\u8a8d\u304c\u3067\u304d\u307e\u3059\uff0e
\n\u4f3c\u305f\u3082\u306e\u306b httping \u306a\u3069\u3082\u3042\u308a\u307e\u3059\u304c httpd \u7528\u306a\u306e\u3067\u4eca\u56de\u306e tcping \u306e\u307b\u3046\u304c\u6c4e\u7528\u6027\u304c\u3042\u308a\u307e\u3059\u306d\uff0e
$ httping www.matoken.org -l\nPING www.matoken.org:443 (/):\nconnected to 153.121.44.87:443 (290 bytes), seq=0 time=358.74 ms\nconnected to 153.121.44.87:443 (290 bytes), seq=1 time=291.96 ms\nconnected to 153.121.44.87:443 (290 bytes), seq=2 time=343.24 ms\nconnected to 153.121.44.87:443 (290 bytes), seq=3 time=301.26 ms\n^CGot signal 2\n--- https://www.matoken.org/ ping statistics ---\n4 connects, 4 ok, 0.00% failed, time 4776ms\nround-trip min/avg/max = 292.0/323.8/358.7 ms\n
$ tcping -v\nTCPING version 1.21.2\n$ dpkg-query -W python3 httping\nhttping 2.5-5.2+b2\npython3 3.12.6-1\n$ lsb_release -dr\nDescription: Debian GNU/Linux trixie/sid\nRelease: n/a\n$ arch\nx86_64\n
\n\n\n\u30d1\u30b1\u30c3\u30c8\u304c\u5e30\u3063\u3066\u304f\u308b\u3068\u30d4\u30f3\u30b0\u30fc\u304c\u51fa\u3066\u304f\u308bping\u30b3\u30de\u30f3\u30c9\u3092\u4f5c\u308a\u307e\u3057\u305f
\n
\n\u697d\u3057\u3044\uff57\uff57\uff57https://t.co/VxeVtIt2IB#golang #cli #ping pic.twitter.com/KoLlEou9Ou\u2014 ((
\n<9F><90><91>++)) (@Sheeeeepla)
\nJune 11, 2022
\u53ef\u611b\u3044
\n\u3066\u3053\u3068\u3067\u624b\u5143\u3067\u3082\u52d5\u304b\u3057\u3066\u307f\u307e\u3057\u305f\uff0e
\n
$ go install github.com/sheepla/pingu@latest\n
| \n Note \n | \n\n \n \ninstall\u3057\u3066\u304b\u3089\u6c17\u3065\u3044\u305f\u306e\u3067\u3059\u304c\uff0cGitHub\u306erelease\u306b\u3044\u304f\u3064\u304b\u306e\u30d0\u30a4\u30ca\u30ea\u304c\u3042\u308a\u307e\u3057\u305f\uff0e \n \n\n \n$ git clone https://github.com/sheepla/pingu && cd pingu\n$ GOARCH=\"arm\" GOOS=\"linux\" go build -o pingu_linux-arm main.go\n$ GOARCH=\"amd64\" GOOS=\"openbsd\" go build -o pingu_openbsd-amd64 main.go\n$ file ./pingu_*\n./pingu_linux-arm: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, Go BuildID=murva-OzxIcI_YixZ4Ug/cNCKM_axMOq6C247-ffX/ZvpTdtm8O3oDXPd__Lpl/cHptxGGRawpNVtoik-SP, not stripped\n./pingu_openbsd-amd64: ELF 64-bit LSB executable, x86-64, version 1 (OpenBSD), dynamically linked, interpreter /usr/libexec/ld.so, for OpenBSD, Go BuildID=Q-bDgKXcAqG8C7jI1-AU/tFPAi4Y1vzFywav4YxWJ/RlLmE89x6Zh42bIsaKyQ/oVjfJQxr0rf9Z5byo_ZF, not stripped\n | \n
\u65e9\u901f\u5b9f\u884c\u3059\u308b\u3068permission denied\u3067\u5931\u6557\u3057\u307e\u3059\uff0e
\n$ pingu localhost\nPING localhost (127.0.0.1) type `Ctrl-C` to abort\n[ERROR] an error occurred when running ping: socket: permission denied\n
SUID \u3092\u8a2d\u5b9a\u3057\u3066\u307f\u305f\u308a\uff0c
\n$ cp -a $(which pingu) .\n$ sudo chown 0.0 ./pingu\n$ sudo chmod u+s ./pingu\n$ ./pingu localhost\nPING localhost (127.0.0.1) type `Ctrl-C` to abort\n[ERROR] an error occurred when running ping: socket: permission denied\n
sudo\u3067\u3082\u99c4\u76ee\u3067\u3059\uff0e
\n$ sudo ~matoken/go/bin/pingu localhost\nPING localhost (127.0.0.1) type `Ctrl-C` to abort\n[ERROR] an error occurred when running ping: socket: permission denied\n
\u691c\u7d22\u3057\u3066\u307f\u308b\u3068\u3053\u306e\u30da\u30fc\u30b8\u3092\u898b\u3064\u3051\u307e\u3057\u305f\uff0e
\nping \u30b3\u30de\u30f3\u30c9\u304c\u7279\u5225\u3067\u901a\u5e38\u306f net.ipv4.ping_group_range \u306e\u6a29\u9650\u304c\u5fc5\u8981\u306a\u3088\u3046\u3067\u3059\uff0e
\nprettyping \u306f\u52d5\u304f\u306e\u306b\u306a\u3068\u601d\u3063\u305f\u3051\u3069\u3053\u308c\u306f ping \u30b3\u30de\u30f3\u30c9\u3092\u547c\u3093\u3067\u3044\u308b\u306e\u3067\u52d5\u304f\u306e\u3067\u3059\u306d\uff0e
net.ipv4.ping_group_range \u3092\u78ba\u8a8d\u3059\u308b\u3068 1 0 \u306b\u306a\u3063\u3066\u3044\u307e\u3059\uff0e
$ sysctl -a 2>&1 | grep ping\nnet.ipv4.ping_group_range = 1 0\n$ cat /proc/sys/net/ipv4/ping_group_range\n1 0\n
0 0 \u306b\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u3067 gid 0 \u3067\u5b9f\u884c\u53ef\u80fd\u306b$ sudo id -g\n0\n$ sudo sysctl net.ipv4.ping_group_range=\"0 0\"\nnet.ipv4.ping_group_range = 0 0\n$ sudo ~matoken/go/bin/pingu localhost\nPING localhost (127.0.0.1) type `Ctrl-C` to abort\n ... . ... .. .. ......... seq=0 32bytes from 127.0.0.1: ttl=64 time=242.773\u00b5s\n ... .... .. .. ... ..... .. .. seq=1 32bytes from 127.0.0.1: ttl=64 time=241.504\u00b5s\n^C\n\u2500\u2500\u2500\u2500\u2500 localhost ping statistics \u2500\u2500\u2500\u2500\u2500\nPACKET STATISTICS: 2 transmitted => 2 received (0% loss)\nROUND TRIP: min=241.504\u00b5s avg=242.139\u00b5s max=242.773\u00b5s stddev=634ns\n
0 1000 \u306b\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u3067 gid 1000 \u306e\u4e00\u822c\u30e6\u30fc\u30b6\u3067\u3082\u5b9f\u884c\u53ef\u80fd\u306b$ sudo sysctl net.ipv4.ping_group_range=\"0 $(id -g)\"\nnet.ipv4.ping_group_range = 0 1000\n$ pingu localhost\nPING localhost (127.0.0.1) type `Ctrl-C` to abort\n ... . ... .. .. ......... seq=0 32bytes from 127.0.0.1: ttl=64 time=149.711\u00b5s\n ... .... .. .. ... ..... .. .. seq=1 32bytes from 127.0.0.1: ttl=64 time=235.975\u00b5s\n ... ....... ... ... . ..... ####### seq=2 32bytes from 127.0.0.1: ttl=64 time=195.434\u00b5s\n..... ........ .###############..... ... ##########. . seq=3 32bytes from 127.0.0.1: ttl=64 time=179.31\u00b5s\n .... ........#####################. ... ########### seq=4 32bytes from 127.0.0.1: ttl=64 time=201.388\u00b5s\n ....... ######################.... ############ seq=5 32bytes from 127.0.0.1: ttl=64 time=242.148\u00b5s\n. . .... ########################... ########### seq=6 32bytes from 127.0.0.1: ttl=64 time=219.127\u00b5s\n .. ....#########################.. .########### seq=7 32bytes from 127.0.0.1: ttl=64 time=163.007\u00b5s\n . #########################. .########## seq=8 32bytes from 127.0.0.1: ttl=64 time=136.878\u00b5s\n .... .########################. ######## seq=9 32bytes from 127.0.0.1: ttl=64 time=203.288\u00b5s\n ..... . ####################. #######. seq=10 32bytes from 127.0.0.1: ttl=64 time=128.612\u00b5s\n^C\n\u2500\u2500\u2500\u2500\u2500 localhost ping statistics \u2500\u2500\u2500\u2500\u2500\nPACKET STATISTICS: 11 transmitted => 11 received (0% loss)\nROUND TRIP: min=128.612\u00b5s avg=186.807\u00b5s max=242.148\u00b5s stddev=36.88\u00b5s\n
1001 1000 \u306e\u69d8\u306b\u304a\u304b\u3057\u306a\u7bc4\u56f2\u306b\u8a2d\u5b9a\u3059\u308b\u3068\u52d5\u304b\u306a\u304f\u306a\u308a\u307e\u3059\uff0e$ sudo sysctl net.ipv4.ping_group_range=\"1001 $(id -g)\"\nnet.ipv4.ping_group_range = 1001 1000\n$ pingu localhost\nPING localhost (127.0.0.1) type `Ctrl-C` to abort\n[ERROR] an error occurred when running ping: socket: permission denied\n
| \u30c7\u30a3\u30b9\u30c8\u30ea\u30d3\u30e5\u30fc\u30b7\u30e7\u30f3 | \nuname -r | \nnet.ipv4.ping_group_range | \npingu | \n
|---|---|---|---|
| \n Debian sid amd64 \n | \n\n 5.17.0-3-amd64 \n | \n\n 1\t0 \n | \n\n NG \n | \n
| \n Debian bullseye amd64 \n | \n\n 5.10.0-14-amd64 \n | \n\n 1\t0 \n | \n\n NG \n | \n
| \n Debian buster amd64 \n | \n\n 5.10.0-0.bpo.12-amd64 \n | \n\n 1\t0 \n | \n\n NG \n | \n
| \n Raspberry Pi OS bullseye armhf \n | \n\n 5.15.32-v7+ \n | \n\n 0\t2147483647 \n | \n\n OK \n | \n
| \n Ubuntu 22.10 amd64(development branch) \n | \n\n 5.15.0-33-generic \n | \n\n 0\t2147483647 \n | \n\n OK \n | \n
| \n Note \n | \n\nsysctl\u306f\u518d\u8d77\u52d5\u3067\u3082\u3068\u306b\u623b\u308b\u306e\u3067\u6c38\u7d9a\u5316\u3057\u305f\u3044\u5834\u5408\u306f /etc/sysctl.conf, /etc/sysctl.d/* \u8fba\u308a\u306b\u66f8\u3044\u3066\u304a\u304d\u307e\u3057\u3087\u3046\uff0e | \n
pingu\u52d5\u3044\u305f\u3051\u3069\u8272\u306a\u3057\u306e\u30c6\u30ad\u30b9\u30c8\u30c7\u30fc\u30bf\u3060\u3068\u3088\u304f\u308f\u304b\u3089\u306a\u3044\u306e\u3067\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u3092\uff0e
\n\u3061\u306a\u307f\u306b\u7aef\u672b\u5e45\u304c\u72ed\u3044\u3068\u3053\u3093\u306a\u611f\u3058\u306b\u306a\u308b\u306e\u3067\u5e83\u3052\u3066\u3042\u3052\u307e\u3057\u3087\u3046(\u4e0a\u306e\u753b\u50cf\u306fcols 111)
\n\u4e0d\u5b89\u5b9a\u306a\u56de\u7dda\u3060\u3068\u884c\u304c\u6e1b\u308a\u30d4\u30f3\u30b0\u30fc\u304c\u7e2e\u307f\u307e\u3059(\u81ea\u5b85\u3067\u306epovo 2.0\u56de\u7dda
)
\u4e0d\u5b89\u5b9a\u306a\u56de\u7dda\u3060\u3068 prettyping \u304c\u3044\u3044\u3067\u3059\u306d\uff0e
$ pingu --version\npingu: v???-rev???\n$ ls ~/go/pkg/mod/github.com/sheepla/\npingu@v0.0.1\n$ dpkg-query -W linux-image-`uname -r` golang iputils-ping\ngolang:amd64 2:1.18~3\niputils-ping 3:20211215-1\nlinux-image-5.17.0-3-amd64 5.17.11-1\n$ lsb_release -dr\nDescription: Debian GNU/Linux bookworm/sid\nRelease: unstable\n
ping\u306e\u30ab\u30e9\u30d5\u30eb\u306a\u30e9\u30c3\u30d1\u30fc\u306e prettyping \u3068\u3044\u3046\u3082\u306e\u3092\u77e5\u308a\u307e\u3057\u305f\uff0e
\u5c11\u3057\u8a66\u3057\u3066\u307f\u307e\u3057\u305f\uff0e
\n$ curl -O https://raw.githubusercontent.com/denilsonsa/prettyping/master/prettyping\n$ install -m 755 ./prettyping ~/bin/\n$ ls -l ~/bin/prettyping\n-rwxr-xr-x 1 pi pi 23396 Apr 1 22:08 /home/pi/bin/prettyping\n$ ~/bin/prettyping 1.1.1.1\n0 \u2581 10 \u2582 20 \u2583 30 \u2584 40 \u2585 50 \u2586 60 \u2587 70 \u2588 80 \u2581 90 \u2582 100 \u2583 110 \u2584 120 \u2585 130 \u2586 140 \u2587 150 \u2588 160 \u2581 170 \u2582\n180 \u2583 190 \u2584 200 \u2585 210 \u2586 220 \u2587 230 \u2588 \u221e\nPING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.\n\u2582\u2585\u2588\u2581\u2584\u2582\u2588\n 0/ 7 ( 0%) lost; 76/ 107/ 178ms; last: 76ms\n 0/ 7 ( 0%) lost; 76/ 107/ 178/ 27ms (last 7)\n\u30ab\u30e9\u30fc\u3067\u898b\u308b\u3068\u304d\u308c\u3044\u3067\u3059\uff0e
\n\u5b89\u5b9a\u3057\u305f\u56de\u7dda\u3060\u3068\u7dd1\u3067\u9762\u767d\u304f\u306a\u3044\u306e\u3067\u4e0d\u5b89\u5b9a\u306a\u56de\u7dda\u3084\u9060\u304f\u306e\u30a2\u30c9\u30ec\u30b9\u3092\u6307\u5b9a\u3059\u308b\u3068\u3044\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\uff0e\u4eca\u56de\u306f\u96fb\u6ce2\u72b6\u6cc1\u306e\u60aa\u3044\u643a\u5e2f\u56de\u7dda\u3067\u8a66\u3057\u307e\u3057\u305f\uff0e(-120dBM\u524d\u5f8c\u306e\u570f\u5916\u306b\u306a\u3063\u305f\u308a\u623b\u3063\u305f\u308a\u306a\u5834\u6240)
\n$ dpkg-query -W iputils-ping curl coreutils\ncoreutils\t8.30-3\ncurl\t7.64.0-4+deb10u1\niputils-ping\t3:20180629-2+deb10u2\n$ lsb_release -dr\nDescription:\tRaspbian GNU/Linux 10 (buster)\nRelease:\t10\n$ arch\narmv7l\n$ cat /proc/device-tree/model ;echo\nRaspberry Pi 3 Model B Rev 1.2\n