24. Le fichier hosts

24.1. Travaux pratiques

Voici le contenu de mon fichier hosts (/etc/hosts) :


vanvincq@CP2L /media/Emulation/Master-2-ISIDIS/CPLL/JournalDeBord $ cat /etc/hosts
127.0.0.1	CP2L	localhost.localdomain	localhost
127.0.1.1 	CP2L.home CP2L.home
192.168.1.1 routeur

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Il est donc possible de faire un ping directement via le nom de l'hôte.


vanvincq@CP2L /media/Emulation/Master-2-ISIDIS/CPLL/JournalDeBord $ ping -c 5 routeur
PING routeur (192.168.1.1) 56(84) bytes of data.
64 bytes from routeur (192.168.1.1): icmp_req=1 ttl=64 time=0.651 ms
64 bytes from routeur (192.168.1.1): icmp_req=2 ttl=64 time=0.543 ms
64 bytes from routeur (192.168.1.1): icmp_req=3 ttl=64 time=0.537 ms
64 bytes from routeur (192.168.1.1): icmp_req=4 ttl=64 time=0.532 ms
64 bytes from routeur (192.168.1.1): icmp_req=5 ttl=64 time=0.527 ms

--- routeur ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 3998ms
rtt min/avg/max/mdev = 0.527/0.558/0.651/0.046 ms

vanvincq@CP2L /media/Emulation/Master-2-ISIDIS/CPLL/JournalDeBord $ ping -c 5 CP2L
PING CP2L (127.0.0.1) 56(84) bytes of data.
64 bytes from CP2L (127.0.0.1): icmp_req=1 ttl=64 time=0.020 ms
64 bytes from CP2L (127.0.0.1): icmp_req=2 ttl=64 time=0.022 ms
64 bytes from CP2L (127.0.0.1): icmp_req=3 ttl=64 time=0.024 ms
64 bytes from CP2L (127.0.0.1): icmp_req=4 ttl=64 time=0.026 ms
64 bytes from CP2L (127.0.0.1): icmp_req=5 ttl=64 time=0.026 ms

--- CP2L ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 3998ms
rtt min/avg/max/mdev = 0.020/0.023/0.026/0.005 ms

24.2. Questions