Hacker News new | ask | show | jobs
by ripperdoc 1683 days ago
Nice! A network tool I've always wanted is one that automates the investigation you have to do manually if you are experienceing "internet issues". I mean, the check list is quite straightforward but still a pretty manual process, stuff like: - Do I have the expected IP? - Is there large packet loss or latency issues hinting at connectivity issues? - Can I ping the local gateway? - Can I ping to outside network? - Is my nearest DNS responding? - Is another, remote DNS responding? - What does Downdetector or similar say about the service I'm trying?

It would be nice with a one click tool that just went through this in order and gave a diagnosis.

6 comments

    #!/bin/zsh
    ip addr | grep $localNetworkPrefix
    ping $localGateway
    ping 1.1.1.1
    ping $DNS01
    ping $DNS02
    open -a Safari https://downdetector.com/status/%1
Do `chmod +x ./scriptname.sh` to make executable and run with argument (e.g. net.sh facebook) to check a particular service.

Edit: Thanks @Shared404

ip doesn't exist on macOS. That is a Linuxism.

You can use the following:

   netstat -rn -f inet | grep default | head -n 1 | awk '{ print $2 }'
To get the default gateway that is the preferred one on macOS, so you don't need to hard code it.

  scutil --dns
Will display the DNS servers/split DNS configuration as well.
I still type 'ip a s' on osx machines multiple times a week, even though I know it doesn't exist for many years.

If on wifi one can also simply option click the wifi icon in the menu bar. Maybe some people don't know yet, it was a late discovery for me option click shows more information there.

For quick internet access check I like 'curl ipconfig.sh'

I'm on my phone but I think you can do this if you're using awk anyway:

  netstat -rn -f inet | awk '/default/ {print $2;exit}'
> Edit: Not sure how to do single spaced newline here.

If you prepend each line with 4 spaces it'll format as code.

  I believe only 2 spaces
  are required.
Check out https://github.com/ycd/dstp . It's still pretty young but it tries to solve that problem. The author needs more feedback.
This is what windows network troubleshooter was meant to be. But it never seems to work.
I have xBar plugin (formely BitBar) that pings Cloudflare:

   ping -c 1 -n 1.1  2>/dev/null | awk -F '/' 'END {printf "%.2f ms\n", $5}'

Also your router

   GATEWAY=$(netstat -nr | grep '^default' | grep en0 | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}')
   ping -c 1 -n -q $GATEWAY 2>/dev/null | awk -F '/' 'END {printf "%.2f ms\n", $5}'
Needs something about MTU too. A popular way to mess up a network is to configure it for a too large MTU and not send the ICMPs that would tell you otherwise.
It's not "one click", but flent is the goto tool we use to probe networks for a multiplicity of problems. It's available for most OSes, including OSx. See flent.org.