无法更改本地网络中树莓派的主机名

无法更改本地网络中树莓派的主机名

我在树莓派上全新安装了基于 debian 的 OSMC 操作系统。我已经手动设置了静态IP:

$ ifconfig wlan0
wlan0: flags=-28605<UP,BROADCAST,RUNNING,MULTICAST,DYNAMIC>  mtu 1500
        inet 192.168.1.3  netmask 255.255.255.0  broadcast 192.168.1.255
        ether aa:aa:aa:aa:aa:aa  txqueuelen 1000  (Ethernet)
        RX packets 39310  bytes 7976110 (7.6 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 11710  bytes 2444978 (2.3 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

我已将主机名设置如下:

$ cat /etc/hostname
cerebro

$ cat /etc/hosts
::1             cerebro localhost6.localdomain6 localhost6
127.0.1.1       cerebro

127.0.0.1       localhost
::1             localhost ip6-localhost ip6-loopback
fe00::0         ip6-localnet
ff00::0         ip6-mcastprefix
ff02::1         ip6-allnodes
ff02::2         ip6-allrouters

然而,当我使用 nmap 扫描主机时,我看到主机报告为osmc连接:

$ nmap -sP 192.168.1.3

Starting Nmap 7.01 ( https://nmap.org ) at 2018-03-24 21:22 GMT
Nmap scan report for osmc.connect (192.168.1.3)
Host is up (0.032s latency).
Nmap done: 1 IP address (1 host up) scanned in 0.04 seconds

我觉得有某种关联的是,当我 ping 任一192.168.1.1,osmc连接或者脑局部,我得到:

$ ping 192.168.1.3
PING 192.168.1.3 (192.168.1.3) 56(84) bytes of data.
64 bytes from 192.168.1.3: icmp_seq=1 ttl=64 time=4.16 ms
64 bytes from 192.168.1.3: icmp_seq=1 ttl=64 time=4.61 ms (DUP!)
64 bytes from 192.168.1.3: icmp_seq=1 ttl=64 time=4.63 ms (DUP!)
64 bytes from 192.168.1.3: icmp_seq=1 ttl=64 time=4.88 ms (DUP!)
64 bytes from 192.168.1.3: icmp_seq=2 ttl=64 time=4.28 ms
64 bytes from 192.168.1.3: icmp_seq=2 ttl=64 time=4.32 ms (DUP!)
64 bytes from 192.168.1.3: icmp_seq=2 ttl=64 time=4.32 ms (DUP!)
64 bytes from 192.168.1.3: icmp_seq=2 ttl=64 time=4.55 ms (DUP!)

我花了一整天的时间试图解决这个问题,但没有成功。

  1. 这是哪里osmc连接主机名来自以及如何摆脱它?
  2. 为什么会有这些重复的 ping 以及如何消除它们?

值得一提的是,我最近改用沃达丰(华为 963168_HUAWEIVOX25),我非常怀疑它造成了所有这些麻烦。

我的网络上有另一个具有另一个主机名的树莓派,路由器在连接的设备中将其显示为计算机-3.连接?!?


更新:

我更改了 wifi 网络的 SSID,重新连接后,路由器已将主机视为脑连接,但重复的 ping 仍然存在。

第二次更新:

第二天早上,重复的更新消失了,一切看起来都很好。但是,我想了解发生了什么,所以我改回了主机名/etc/主机名/etc/主机OSMC并重新启动。 systemctl 状态 avahi 守护进程主机名正确显示为OSMC。但是在路由器的设备列表中,我仍然将其视为脑连接。然后我将主机名重命名为大脑并再次重新启动。现在(DUP!)ping 回来了!

$ sudo systemctl status avahi-daemon
● avahi-daemon.service - Avahi mDNS/DNS-SD Stack
   Loaded: loaded (/lib/systemd/system/avahi-daemon.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2018-03-25 10:24:15 BST; 11min ago
 Main PID: 244 (avahi-daemon)
   Status: "avahi-daemon 0.6.32 starting up."
   CGroup: /system.slice/avahi-daemon.service
           ├─244 avahi-daemon: running [cerebro.local]
           └─267 avahi-daemon: chroot helper

Mar 25 10:24:15 cerebro avahi-daemon[244]: Loading service file /services/ssh.service.
Mar 25 10:24:15 cerebro avahi-daemon[244]: Loading service file /services/udisks.service.
Mar 25 10:24:15 cerebro avahi-daemon[244]: Network interface enumeration completed.
Mar 25 10:24:15 cerebro avahi-daemon[244]: Server startup complete. Host name is cerebro.local. Local service cookie is
Mar 25 10:24:15 cerebro avahi-daemon[244]: Service "cerebro" (/services/udisks.service) successfully established.
Mar 25 10:24:15 cerebro avahi-daemon[244]: Service "cerebro" (/services/ssh.service) successfully established.
Mar 25 10:24:15 cerebro avahi-daemon[244]: Service "cerebro" (/services/sftp.service) successfully established.
Mar 25 10:24:17 cerebro avahi-daemon[244]: Joining mDNS multicast group on interface wlan0.IPv4 with address 192.168.1.
Mar 25 10:24:17 cerebro avahi-daemon[244]: New relevant interface wlan0.IPv4 for mDNS.
Mar 25 10:24:17 cerebro avahi-daemon[244]: Registering new address record for 192.168.1.3 on wlan0.IPv4.

这就像路由器正在缓存主机名。

另外,我拥有的第二个 Rpi(在有线连接上)仍然被路由器视为计算机-3.连接我仍然不知道如何改变这一点。systemctl 状态 avahi 守护进程显示正确的主机名

相关内容