AI Hints
Home›Linux Tutorial›Networking Basics
Linux · Lesson 92 of 120

Your Network

Ip, ping and host.

⏱ 2 min read▶ Video at 2:02:55🎓 Free
Watch this lesson in the Linux courseWatch on YouTube ↗Full Linux course

Let's look at our own computer's network, and test whether we can reach other machines. A few short commands tell you a lot.

Your Network
From the video: Your Network
  • Our own network
  • Can we reach others?
  • A few short commands

Your address

Hostname dash capital I prints this computer's IP addresses. Ours is on a private network, which is why it starts with one seven two. IP address show, followed by a network card name, gives much more detail. ETH zero is the first wired network card.

Terminal
hostname -I
172.17.0.2
ip address show eth0
362: eth0@if363: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 65535 qdisc noqueue state UP group default
    link/ether 02:42:ac:11:00:02 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 172.17.0.2/16 brd 172.17.255.255 scope global eth0
       valid_lft forever preferred_lft forever

Is it reachable?

Ping sends tiny messages to another computer, and times the replies. Dash C two means, send just two. Here we ping localhost, our own machine, which answers in a fraction of a millisecond. Zero percent packet loss means every message came back.

Terminal
ping -c 2 localhost
PING localhost (::1) 56 data bytes
64 bytes from localhost (::1): icmp_seq=1 ttl=64 time=0.065 ms
64 bytes from localhost (::1): icmp_seq=2 ttl=64 time=0.060 ms

--- localhost ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1049ms
rtt min/avg/max/mdev = 0.060/0.062/0.065/0.002 ms

Names to addresses

Host asks DNS for the address behind a name. Example dot com has several addresses, because big websites use many servers. If a website won't load, checking the name with host is a good first step.

Terminal
host example.com
example.com has address 104.20.23.154
example.com has address 172.66.147.243
example.com has IPv6 address 2606:4700:10::6814:179a
example.com has IPv6 address 2606:4700:10::ac42:93f3
example.com mail is handled by 0 .

Summary

Hostname dash I and IP address show your addresses, ping tests whether a machine answers, and host looks up names. Next, downloading from the web.

Key takeaways
  • hostname -I / ip address
  • ping -c 2 host
  • host name
Next up: curl and wget — the web from the terminal