LINUX.ORG.RU

Домашний сервер доступ по имени хоста

 ,


2

3

Значит у меня есть старый комп (я себе ноут купил, епта), решил я из него сервер-помойку сделать, поставил Ubuntu Server и на нее поставил avahi-daemon. Значит avahi-daemon.service запущен, но подключиться я могу только по айпи:

~ on ☁️  took 36m13s 
❯ ssh sergey@ubuntu.local      
ssh: Could not resolve hostname ubuntu.local: Name or service not known

~ on ☁️  
❯ ssh sergey@192.168.0.103     
sergey@192.168.0.103's password: 
Permission denied, please try again.
sergey@192.168.0.103's password: 
Welcome to Ubuntu 21.04 (GNU/Linux 5.11.0-18-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Sun Jun 20 08:55:12 PM UTC 2021

  System load:    0.14      Memory usage: 1%   Processes:       274
  Usage of /home: unknown   Swap usage:   0%   Users logged in: 0

  => There were exceptions while processing one or more plugins. See
     /var/log/landscape/sysinfo.log for more information.

 * Super-optimized for small spaces - read how we shrank the memory
   footprint of MicroK8s to make it the smallest full K8s around.

   https://ubuntu.com/blog/microk8s-memory-optimisation

34 updates can be installed immediately.
0 of these updates are security updates.
To see these additional updates run: apt list --upgradable


Last login: Sun Jun 20 20:15:09 2021 from 192.168.0.106
sergey@ubuntu:~$

Что где еще прописать нужно?

★★

Откуда клиент узнает про имя хоста? Тебе нужен DNS. Ну или лапками прописывать на клиенте /etc/hosts, но это тупняк.

mord0d ★★★★★
()
Ответ на: комментарий от anonymous

Avahi — мутная дичь. Я видел корректно работающий Avahi только с KDE Connect. И этот тред лишний раз подтверждает что Avahi — какаха. ☺

mord0d ★★★★★
()
Ответ на: комментарий от mord0d

Откуда клиент узнает про имя хоста?
Avahi — мутная дичь.

ok, держи в курсе. По сути мы оба оффтопим, но ОП тред вроде именно про avahi завел, зачем ему советовать dns?

anonymous
()

А на ноуте Avahi стоит? А libnss-mdns на обоих компах?

solvent
()
Ответ на: комментарий от anonymous

Кстати, тут мне пишут, что даже KDE Connect по имени хоста не хочет коннектится, только по IP.

зачем ему советовать dns?

Если топикстартеру шашечки, то на этом наши полномочия как бы всё, кончились. Я предлагаю ехать, dnsmasq, например (BIND дома — из пушки по воробьям).

mord0d ★★★★★
()

Лично я пользуюсь в локалках банальной связкой dhcp+dns. Просто и достаточно надёжно.

targitaj ★★★★★
()

Я у себя сделал так - на сервере указал имя хоста при установке (у меня OMV 5, Дебиан де факто), а на роутере по МАС сетевухи привязал выдачу постоянного ІР.

Результат - все девайсы в локалке знают к какому ІР обращаться при работе по hostname.

ololoid ★★★★
()
Ответ на: комментарий от ololoid

я из wsl пробовал пинговать, отзывается, а из линукса:

❯ ping -c 3 ubuntu.local       
ping: ubuntu.local: Name or service not known
tz4678 ★★
() автор топика
Ответ на: комментарий от tz4678

А может вы DNS не роутера используете на клиентах?

ololoid ★★★★
()
Ответ на: комментарий от mord0d

Хост неправильно настроен. Я с телефона пробовал пинговать, там тоже что-то не так, а вот убунтовский сервак все видит, видит WSL:

❯ ping 192.168.0.103      
PING 192.168.0.103 (192.168.0.103) 56(84) bytes of data.
64 bytes from 192.168.0.103: icmp_seq=1 ttl=64 time=5.98 ms
64 bytes from 192.168.0.103: icmp_seq=2 ttl=64 time=1.29 ms
64 bytes from 192.168.0.103: icmp_seq=3 ttl=64 time=4.19 ms
^C
--- 192.168.0.103 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
rtt min/avg/max/mdev = 1.294/3.819/5.978/1.929 ms

~ on ☁️  took 2s 
❯ ping ubuntu.local 
ping: ubuntu.local: Name or service not known

~ on ☁️  
❯ ssh sergey@192.168.0.103
Welcome to Ubuntu 21.04 (GNU/Linux 5.11.0-18-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Mon Jun 21 10:40:38 AM UTC 2021

  System load:    0.0       Memory usage: 1%   Processes:       264
  Usage of /home: unknown   Swap usage:   0%   Users logged in: 0

  => There were exceptions while processing one or more plugins. See
     /var/log/landscape/sysinfo.log for more information.

 * Super-optimized for small spaces - read how we shrank the memory
   footprint of MicroK8s to make it the smallest full K8s around.

   https://ubuntu.com/blog/microk8s-memory-optimisation

34 updates can be installed immediately.
0 of these updates are security updates.
To see these additional updates run: apt list --upgradable


Last login: Mon Jun 21 10:39:50 2021 from 192.168.0.106
sergey@ubuntu:~$ ping arch-laptop.local
PING arch-laptop.local (192.168.0.106) 56(84) bytes of data.
64 bytes from 192.168.0.106 (192.168.0.106): icmp_seq=1 ttl=64 time=1.06 ms
64 bytes from 192.168.0.106 (192.168.0.106): icmp_seq=2 ttl=64 time=114 ms
64 bytes from 192.168.0.106 (192.168.0.106): icmp_seq=3 ttl=64 time=34.7 ms
^C
--- arch-laptop.local ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 1.055/49.876/113.909/47.311 ms
sergey@ubuntu:~$ ping ubuntu.local
PING ubuntu.local (172.17.0.1) 56(84) bytes of data.
64 bytes from ubuntu (172.17.0.1): icmp_seq=1 ttl=64 time=0.034 ms
64 bytes from ubuntu (172.17.0.1): icmp_seq=2 ttl=64 time=0.064 ms
^C
--- ubuntu.local ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1002ms
rtt min/avg/max/mdev = 0.034/0.049/0.064/0.015 ms
sergey@ubuntu:~$
tz4678 ★★
() автор топика
Ответ на: комментарий от tz4678
sergey@ubuntu:~$ cat /etc/resolv.conf 
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "resolvectl status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs should typically not access this file directly, but only
# through the symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a
# different way, replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 127.0.0.53
options edns0 trust-ad
search .
sergey@ubuntu:~$ exit
logout
Connection to 192.168.0.103 closed.

~ on ☁️  took 5m7s 
❯ sudo mount /dev/nvme0n1p4 /mnt/windows                                                     

~ on ☁️  
❯ sudo modprobe nbd                     

~ on ☁️  
❯ sudo qemu-nbd -c /dev/nbd0 /mnt/windows/Users/Sergey/AppData/Local/Packages/CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc/LocalState/ext4.vhdx

~ on ☁️  
❯ sudo mount -o rw /dev/nbd0 /mnt/wsl

~ on ☁️  
❯ cat /mnt/wsl/etc/resolv.conf       
cat: /mnt/wsl/etc/resolv.conf: No such file or directory

~ on ☁️  
❯ 

tz4678 ★★
() автор топика
Ответ на: комментарий от tz4678

А зачем в весле свой dns? Он наверное использует виндовый.

anonymous
()

Нужно настроить nsswitch. Avahi тупо не используется. Это распространенная проблема, с сетевыми принтерами например, которые анонсируют себя через zeroconf.
Не знаю почему авторы дистрибутивов так делают.

Khnazile ★★★★★
()
Ответ на: комментарий от Khnazile

Hostname resolution Avahi provides local hostname resolution using a «hostname.local» naming scheme. To enable it, install the nss-mdns package and start avahi-daemon.service.

Then, edit the file /etc/nsswitch.conf and change the hosts line to include mdns_minimal [NOTFOUND=return] before resolve and dns:

hosts: … mdns_minimal [NOTFOUND=return] resolve [!UNAVAIL=return] dns …

заработало

❯ ping ubuntu.local                  
PING ubuntu.local(ubuntu.local (fe80::264b:feff:fe89:ed8f%wlan0)) 56 data bytes
64 bytes from ubuntu.local (fe80::264b:feff:fe89:ed8f%wlan0): icmp_seq=1 ttl=64 time=11.6 ms
64 bytes from ubuntu.local (fe80::264b:feff:fe89:ed8f%wlan0): icmp_seq=2 ttl=64 time=2.19 ms
^C
--- ubuntu.local ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 2.186/6.872/11.559/4.686 ms
tz4678 ★★
() автор топика

Это, конечно, не по теме, но на кой пес тебе вообще в локалке имена? У тебя много старых системников, заделанных под сервер? Путаешь айпишники?

pihter ★★★★★
()
Ответ на: комментарий от tz4678

Проверил у себя - да, есть установлен пакет libnss-mdns.

Но я не уверен, что ставил его «ручками».

ololoid ★★★★
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.