ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

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

2021-05-20 12:08:20  阅读:280  来源: 互联网

标签:linux protocol Windows hostname window Linux machines NetBIOS


场景如下:
小型局域网,有数台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

标签:linux,protocol,Windows,hostname,window,Linux,machines,NetBIOS
来源: https://blog.51cto.com/u_15147256/2792579

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有