IP Addresses

"What's this server's IP?" - A question you'll answer many times. Let's learn how.

ip addr - Modern Way

Terminal
$ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 inet 127.0.0.1/8 scope host lo 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 inet 192.168.1.100/24 brd 192.168.1.255 scope global eth0

Or shorter: ip a

Reading the Output

FieldMeaning
loLoopback interface (localhost)
eth0First Ethernet interface
inet 192.168.1.100/24IPv4 address with subnet
brdBroadcast address
scope globalReachable from anywhere

Interface Names

Modern systems use predictable names:

  • enp0s3 - Ethernet
  • wlp2s0 - Wireless
  • eth0, wlan0 - Traditional names (still common in VMs)

ifconfig - Legacy Way

Terminal
$ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.1.100 netmask 255.255.255.0 broadcast 192.168.1.255

ifconfig is deprecated but still widely used. ip is the modern replacement.

Just the IP Address

Terminal
$hostname -I
192.168.1.100 10.0.0.5
$ip -4 addr show eth0 | grep inet | awk '{print $2}' | cut -d'/' -f1
192.168.1.100

hostname -I is the quick way.

IPv4 vs IPv6

Terminal
$ip -4 addr
(IPv4 only)
$ip -6 addr
(IPv6 only)

Network Interfaces

List Interfaces

Terminal
$ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel

Check If Interface Is Up

Terminal
$ip link show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP>...

UP and LOWER_UP mean it's active and cable is connected.

Public vs Private IPs

Terminal
$# Local (private) IP
$hostname -I
192.168.1.100
$
$# Public IP (requires internet)
$curl -s ifconfig.me
203.0.113.45

Private IP ranges (not routable on internet):

  • 10.0.0.0/8
  • 172.16.0.0/12
  • 192.168.0.0/16
Knowledge Check

Which command shows network interfaces on a modern Linux system?

Quick Reference

CommandShows
ip addr or ip aAll IP addresses
ip -4 addrIPv4 only
hostname -IQuick IP list
ip link showInterface status
curl ifconfig.mePublic IP

Key Takeaways

  • ip addr shows IP addresses (modern)
  • ifconfig still works but is deprecated
  • hostname -I is the quick way to get IPs
  • Private IPs (192.168.x.x) aren't internet-routable
  • Check interface status with ip link show

Next: testing connectivity with ping.