The simplest way to get your local ip address is using the
which lists out all configured addresses on all network interfaces in a space
separated string. The
-I option is required as it allows all IP addresses to
roast@planetroast:~$ hostname -I 192.168.0.106
This method of getting your local IP number is a little easier to remember than the above method and gives a fairly clean output making it quick to find the number.
roast@planetroast:~$ ip route default via 192.168.0.1 dev wlp4s0 proto dhcp metric 601 192.168.0.0/24 dev wlp4s0 proto kernel scope link src 192.168.0.106 metric 601
The output of the
ifconfig command shows loads of info about your network so
it’s best to pipe the output into
grep to just show lines matching ‘192’.
Despite that this method is the longest to type I still find myself using it
more often than the others for some reason?
roast@planetroast:~$ ifconfig | grep 192 inet 192.168.0.106 netmask 255.255.255.0 broadcast 192.168.0.255
To get the IP address of your router as supplied by your internet service provider we can curl a 3rd party web service which will return your IP number. Any of the following options will work.
curl icanhazip.com curl ifconfig.me curl ipinfo.io curl ident.me