etc/hosts в Ubuntu Linux

Содержание
Введение
Пример

Введение

Файл etc/hosts нужен чтобы задать соответсвие между IP адресами и доменными именами на уровне локального хоста.

Это как DNS сервер который работает только для одного хоста

Пример

У относительно чистой Ubuntu etc/hosts выглядит примерно так

cat /etc/hosts

127.0.0.1 localhost 127.0.1.1 LD-ANDREI # 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

Если у вас в сети есть хост с IP 10.1.55.55 обычный метод подключения по SSH выглядит так

ssh andrei@10.1.55.55

Если адресов много их тяжело запоминать. Возможно вам просто лень писать этот IP адрес вручную.

Обе эти проблемы решаются записью в etc/hosts

sudo vi /etc/hosts

10.1.55.55 srv.andrei.com srv

Теперь для поключения достаточно написать

ssh andrei@srv.andrei.com

Или просто

ssh andrei@srv

Если настроить доступ без пароля с помощью ssh-copy-id для andrei@10.1.55.55 то и для andrei@srv он будет работать

Banner image

Article author: Andrei Olegovich

Похожие статьи
Настройка сети в Ubuntu
DNS в Ubuntu
etc/hosts в Ubuntu Linux
UFW
hostname в CentOS
Ifconfig
iftop в Ubuntu
ip Настройка сети в Ubuntu
iperf в Ubuntu
nethogs в Ubuntu
netplan в Ubuntu
netstat в Ubuntu
Добавить новый сетевой интерфейс Ubuntu
tc в Ubuntu
Сгенерировать uuid для сетевого интерфейса Ubuntu
Подключение к VPN в Ubuntu

Search this site

Subscribe to Telegram channel @aofeed to follow new articles and updates to old ones

Go to channel

@aofeed

Ask a question in the Telegram group

@aofeedchat

Contacts and cooperation:
I recommend our hosting beget.ru
Write to info@urn.su, info@aredel.com if you:
1. Want to write an article for our site or translate an article into your native language.
2. Want to place thematically relevant ads on the site.
3. Ads on my site pass maximum censorship. If you see an ad block unsuitable for school-age children, shocking or misleading - please contact us by e-mail
4. Found a mistake, inaccuracy, bug, etc. on the site. ... .......
5. Articles can be shared on social media by clicking a network icon: