局域网中window可以解析hostname,而linux却不可以?

场景如下:
小型局域网,有数台ubuntu,hostname为ubuntu01,02….等等(ubuntu上都装了SAMBA ),其他都是windows。在windows上可以通过hostname(例如ubuntu03)ping通其他主机,而在linux上则不行。如下图,

这里写图片描述

这里写图片描述

找到些有用的信息,

Windows uses NetBIOS names, and such protocol, being a broadcast one, allows them to find each other without any central server.

Linux machines in modern distros uses natively a protocol called Avahi, which is also a server-independent, broadcast protocol. Local network machines have a suffix .local, so you can ping from Linux to Linux using ping hostname.local, or see them with avahi-discover package. some apps in Gnome use avahi to list machines in the network (for example, the Remote Desktop Viewer)

Installing SAMBA on a Linux machine will assign it a NetBIOS name (or, more technically, will make a Linux machine advertise itself in broadcast requests with their NetBIOS name, which is by default their hostname), and that allows Windows machines to find the Linux ones.

Gotcha: Although Linux machines with Samba will reply to NetBIOS protocol requests, with default settings in distros like Ubuntu it won’t use NetBIOS as a method to resolve names, and that’s why Linux machines can’t “see” each other or the Windows machines. For that, you need to edit /etc/nsswitch.conf file and add wins to the list in this line:

hosts:          files mdns4_minimal [NOTFOUND=return] dns wins mdns4

You may need to install winbind package for the above to work.
So, for the visibility issue, you either install Samba on all Linux machines (and also edit /etc/nsswitch.conf to enable NetBIOS name resolution), or you install Avahi support in Windows machines.

As for file sharing, Samba provides Linux machines file-sharing capabilities with Windows. Theres no need to edit /etc/nsswitch.conf for Linux machines to see shared folders of each other and Windows (and vice-versa) in the “Network” section of Nautilus

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值