Quickly get your machine's public and private IP addresses.
- Verify
curl
andjq
are installed.
-
Ubuntu
sudo apt install curl jq
-
Download
quickip.sh
and place it somewhere you can leave it indefinitely (ex ~/.local/bin/quickip.sh). -
Add the following line to your
.bashrc
(found at~/.bashrc
). Make sure to modify the path to where you put the script.source ~/.local/bin/quickip.sh
-
Resource your
.bashrc
by either quitting and reopening your terminal or with the commandsource ~/.bashrc
. -
The script should now be ready to use.
QuickIP has 3 functions, each with their own name:
pubip
to get your public IP
locip
to get all local interfaces that have an IP assigned
allip
to get both public and private IPs.
Usage: pubip [ OPTION ]
-m Minimal - Don\'t show IP address location.
-M Extra Minimal - Only show IP address.
Usage: locip [ OPTION ]
-d Down - Only show interfaces that are currently down.
-m Minimal - Only show interface name and address.
-M Extra Minimal - Only show interface address(es).
-u Up - Only show interfaces that are up.
Usage: allip [ OPTION ]
-m Minimal - Equivalent to `pubip -m && locip -m`.
-M Extra Minimal - Equivalent to `pubip -M && locip -M`.
[user@computer: ~ ] pubip
Public IP Address:
45.152.182.131 (United States)
[user@computer: ~ ] locip
Local IP Address(es):
lo 127.0.0.1 UNKNOWN
eth0 192.168.1.12 UP
wlan0 192.168.1.248 DOWN
vpn0 10.8.8.17 UNKNOWN
[user@computer: ~ ] allip
Public IP Address:
45.152.182.131 (United States)
Local IP Address(es):
lo 127.0.0.1 UNKNOWN
eth0 192.168.1.12 UP
wlan0 192.168.1.248 DOWN
vpn0 10.8.8.17 UNKNOWN
Please report any issues you encounter and include your operating system in the issue description.