3 ms·
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 d
by X-Istence 5y ago
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.
- mzi 5y agoI'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}'
- mobilemidget 5y agoI 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'