How to edit host file on etc/hosts?

Asked

Viewed 119 times

0

How to edit host file in etc/hosts?

The website is out, so I added the ip: xxx.xxxx.xxx www.meusite.com.br

But when I go ping or scan to see the servers, it finds no signal.

  • You can consult the manual of this file by typing in the terminal: man 5 hosts. See if it helps you.

  • What is the return of ping?

1 answer

1

The syntax of the /etc/hosts file is as follows:

# Endereço IP      Nome "completo" do host       Apelido (opcional)
10.10.10.10        www.meusite.com.br            meusite

Following this pattern, it is to work. Remembering that you must edit the file as root (or using the "sudo" command to call the editor):

$ sudo vim /etc/hosts

The result should be as follows::

$ ping -c3 www.meusite.com.br
PING www.meusite.com.br (10.10.10.10) 56 data bytes
64 bytes from 10.10.10.10 (10.10.10.10): icmp_seq=1 ttl=50 time=18.0 ms
64 bytes from 10.10.10.10 (10.10.10.10): icmp_seq=2 ttl=50 time=19.0 ms
64 bytes from 10.10.10.10 (10.10.10.10): icmp_seq=3 ttl=50 time=19.0 ms
--- www.meusite.com.br ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2045ms
rtt min/avg/max/mdev = 0.028/0.039/0.059/0.013 ms

$ getent hosts meusite
10.10.10.10    www.meusite.com.br     meusite

Check if you followed this pattern and do the above tests to validate the changes.

I hope this helps.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.