开始不知道瞎折腾了什么东西,samba的广播服务没了
看看日志
vim /var/log/samba/log.nmbd # 查看日志
# 结果如下
[2024/02/04 13:58:52.041843, 0] ../../source3/nmbd/nmbd_subnetdb.c:127(make_subnet)
make_subnet: Failed to open nmb bcast socket on interface 172.17.0.1 for port 137: Cannot assign requested address
172.17.0.1?发现是docker的ip地址
ifconfig # 看ip地址
# 输出
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
inet6 fe80::XXXXXXXXXXXXXXXXX prefixlen 64 scopeid 0x20<link>
ether XXXXXXXXXXXXXXXXX txqueuelen 0 (Ethernet)
RX packets 49 bytes 5235 (5.2 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 614 bytes 143487 (143.4 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.123.151 netmask 255.255.255.0 broadcast 192.168.123.255
inet6 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX prefixlen 64 scopeid 0x0<global>
inet6 XXXXXXXXXXXXXXXXXXXXXXXX prefixlen 64 scopeid 0x20<link>
ether 00:11:22:33:44:55 txqueuelen 1000 (Ethernet)
RX packets 3137566 bytes 2631980879 (2.6 GB)
RX errors 0 dropped 1 overruns 0 frame 0
TX packets 1860788 bytes 1459541033 (1.4 GB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 23
实际上需要广播的是eth0这个网卡,去samba配置文件里面设置一下
# 去smb.conf里面配置
vim /etc/samba/smb.conf
# 在[global]后面添加下面的
server min protocol = NT1 # 某些老设备只支持smb1.0,可能需要开启
netbios name = hnas # 广播的名称
interfaces = eth0 # 固定到局域网网卡
bind interfaces only = yes # 只在局域网广播
这样就解决问题了,可以正常广播