Get IP Address
To get the local IP address use the following:
echo $(hostname -I) | cut -d' ' -f1
To find the public IP address that your computer is using, you can call an API to get the IP address.
curl -s -X GET https://checkip.amazonaws.com
Network Interfaces
Ubuntu uses Netplan to manage network interfaces. Netplan configuration files are stored in the /etc/netplan/
directory. By viewing the contents of the /etc/netplan/
directory, you can see the configuration files which are usually named *.yaml
. The name often corresponds to the name of the network interface. To view the network interfaces on your system, run the following command:
ip link
To view the ip addresses for each network interface, run the following command:
ip addr