Find your IP Address on Linux

Your IPv4 Address

ISP:
City:
Country:

Your IPv6 Address

ISP:
City:
Country:

Find your public IP / external address via Linux CLI

Using curl

Get your public IP / external address (IPv4 or IPv6 depending on your setup) using curl

curl https://api.getpublicip.com/ip

Get your external IPv4 address using curl

curl https://ipv4.getpublicip.com/ip

Get your external IPv6 address using curl

curl https://ipv6.getpublicip.com/ip

Using wget

Get your public IP address (IPv4 or IPv6 depending on your connection) using wget

wget -O- https://api.getpublicip.com/ip

Get your external IPv4 address using wget

wget -O- https://ipv4.getpublicip.com/ip

Get your external IPv6 address using wget

wget -O- https://ipv6.getpublicip.com/ip

The output of these commands will look like:

IP Address: 172.21.0.1
ISP: Unknown
City: Unknown
Country: Unknown

Find your local IP address via Linux CLI

On new Linux systems you can use:

ip a

You will see an output similar to:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host noprefixroute 
       valid_lft forever preferred_lft forever
2: eno0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:94:37:b7:8a:88 brd ff:ff:ff:ff:ff:ff
    inet 192.168.66.245/24 brd 192.168.66.255 scope global dynamic noprefixroute wlan0
       valid_lft 71625sec preferred_lft 71625sec
    inet6 fe80::767e:5882:2cdd:686e/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

On the left hand side you will see an interface name such as lo and eno0. These represent the interface. lo is the loopback interface and eno0 is the ethernet interface. Wireless adapters usually have the name of wlan0

The link/ether line shows the MAC address of the interface. A MAC address is a unique identifier assigned by the devices' manufacturer.

The inet line shows the IP v4 address of the interface. In this case its 192.168.66.245

The inet6 line shows the IP v6 address of the interface. In this case its fe80::767e:5882:2cdd:686e. All IPv6 addresses that start with fe80 is a reserved link local address.

Older Linux systems

If your system does not have the ip command, you can use:

ifconfig

Which will output similar information:

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 1535085  bytes 4922556517 (4.5 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1535085  bytes 4922556517 (4.5 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eno0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.66.245  netmask 255.255.255.0  broadcast 192.168.66.255
        inet6 fe80::767e:5882:2cdd:686e  prefixlen 64  scopeid 0x20<link>
        ether 00:94:37:b7:8a:88  txqueuelen 1000  (Ethernet)
        RX packets 3281743  bytes 3550552348 (3.3 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 686125  bytes 467475315 (445.8 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Again the left hand side shows the interface name such as lo and eno0.

The inet line shows the IP v4 address of the interface.

The inet6 line shows the IP v6 address of the interface.

Check out our other guides