I need to write a script that gets the IP address of the interface that is used for unknown routes (e.g. where 0.0.0.0/0 is routed through)
That script should work on Ubuntu, Debian, Arch and Mac OS Systems without the need of installing extra packages.
On Ubuntu, I use
hostname -I, that gives the primary IP address. But in older versions of ubuntu, debian and arch and in Mac OS the
-I-Flag is not available.
Second Idea was to parse the
ifconfig-output, but as the naming is very different on each system and in german systems for example there is no
addr: but something different, this also won't work.
I need this to write a little script to start up a web-application and a little Python-Webserver to server the static content. The script is then used by our designers that barely can code some html and css but don't know anything about bash.