Method 1: Get Local IP using hostname

The simplest way to get your local ip address is using the hostname package 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 be displayed.

roast@planetroast:~$ hostname -I

Method 2: Get Local IP using ip

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 dev wlp4s0 proto dhcp metric 601 dev wlp4s0 proto kernel scope link src metric 601

Method 3: Get Local IP using ifconfig

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  netmask  broadcast

Get Your Public / WAN IP Address

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.