SMB、CIFS和NETBIOS协议概念及linux挂载远程文件系统

[color=red]一、SMB(Server Message Block)协议 [/color]
SMB协议是基于TCP-NETBIOS下的,一般端口使用为139,445。
服务器信息块(SMB)是微软(Microsoft)和英特尔(Intel)在1987年制定的协议,主要是作为Microsoft网络的通讯协议,用于在计算机间共享文件、打印机、串口等。SMB 协议可以用在因特网的TCP/IP协议之上,也可以用在其它网络协议如IPX和NetBEUI 之上。
 SMB 一种客户机/服务器、请求/响应协议。通过 SMB 协议,客户端应用程序可以在各种网络环境下读、写服务器上的文件,以及对服务器程序提出服务请求。此外通过 SMB 协议,应用程序可以访问远程服务器端的文件、以及打印机、邮件槽(mailslot)、命名管道(named pipe)等资源。

在 TCP/IP 环境下,客户机通过 NetBIOS over TCP/IP(或 NetBEUI/TCP 或 SPX/IPX)连接服务器。一旦连接成功,客户机可发送 SMB 命令到服务器上,从而客户机能够访问共享目录、打开文件、读写文件,以及一切在文件系统上能做的所有事情。
 从 Windows 95 开始,Microsoft Windows 操作系统(operating system)都包括了客户机和服务器 SMB 协议支持。Microsoft 为 Internet 提供了 SMB 的开源版本,即通用 Internet 文件系统 (CIFS)。
[color=green] 与现有 Internet 应用程序如文件传输协议(FTP)相比, CIFS 灵活性更大。对于 UNIX 系统,可使用一种称为 Samba 的共享软件。 [/color]

[color=red]二、CIFS(Common Internet File System) 协议 [/color]
CIFS 是一个新提出的协议,它使程序可以访问远程Internet计算机上的文件并要求此计算机的服务。CIFS 使用客户/服务器模式。客户程序请求远在服务器上的服务器程序为它提供服务。服务器获得请求并返回响应。
CIFS是公共的或开放的SMB协议版本,并由Microsoft使用。SMB协议现在是局域网上用于服务器文件访问和打印的协议。象SMB协议一样,CIFS在高层运行,而不象TCP/IP协议那样运行在底层。[color=green]CIFS可以看做是应用程序协议如文件传输协议和超文本传输协议的一个实现。[/color]

[color=red]三、NETBios协议[/color]
Netbios (网络基本输入/输出系统)最初由 IBM,Sytek 作为API开发,使用户软件能使用局域网的资源。自从诞生,Netbios成为许多其他网络应用程序的基础。严格意义上,Netbios 是接入网络服务的接口标准。
 Netbios 原来是作为THE网络控制器为 IBM 局域网设计的,是通过特定硬件用来和网络操作系统连接的软件层。Netbios经扩展,允许程序使用Netbios接口来操作IBM令牌环结构。Netbios 已被公认为工业标准,通常参照 Netbios-compatible LANs。
它提供给网络程序一套方法,相互通讯及传输数据。基本上,Netbios 允许程序和网络会话。它的目的是把程序和任何类型的硬件属性分开。它也使软件开发员可以免除以下负担:开发网络错误修复,低层信息寻址和路由。使用Netbios接口,可以为软件开发员做许多工作。

Netbios使程序和局域网操作能力之间的接口标准化。有它们可以将程序细化到为OSI模型的哪一层所写,使程序能移植到其他网络上。在Netbios局域网环境下,计算机通过名字被系统知道。网络中每台计算机都有通过不同方法编的永久性名称。这些名称将在下面做进一步讨论。
通过使用Netbios的数据报或广播方式,在Netbios局域网上的pc机建立会话彼此联络。会话允许更多的信息被传送,探测错误,和纠正。通信是在一对一的基础上的。数据报或广播方式允许一台计算机和多台其他的计算机同时通信,但信息大小受限。使用数据报或广播方式没有探测错误和纠正。然而,数据报通信可以不必建立一个会话。

在这种环境下所有的通信以一种称为“网络控制块“的格式提交给NetBIOS。内存中这些块的分配依赖于用户程序。这些“网络控制块“分配到域中,分别为输入/输出保留。
在当今的环境中,NetBIOS是使用很普遍的协议。以太网,令牌环,IBM PC网都支持NetBIOS。在它原始版本中,它仅作为程序和网络适配器的接口。从那以后,传输类功能加入NetBIOS,使它功能日益增多。
在NetBIOS里,面向连接(tcp)和无连接(udp)通信均支持。它支持广播和复播,支持三个分开的服务:命名,会话,数据报。

-----------------------------------------------------------------------------------------------------------------------------------------------
在Windows操作系统之间,可以通过映射网络驱动器的方式,将某个共享目录映射成一个磁盘文件系统,在Linux下,可以通过smbmount命令来实现相似的功能,将Windows的某个共享目录挂载到Linux下的某个目录下。在linux下需安装一个samba客户端。

下面转载一篇linux系统如何挂载远程windows系统博客:

How to mount a Windows Network Share on Linux system

Purpose: This post will explain how you can mount a Windows Network Share on to your Linux machine.

Example-Setup and Assumptions:

You have a computer running Windows XP (or may be Vista) on your home/office network on a workgroup or domain.
You have another computer running Linux say Debian Linux.
You would like to mount a shared folder/drive on your Windows computer on to your Linux machine say on “/mnt/” folder so that you can access (read/write) that folder/drive.

My setup:

Debian Linux (4.0) running 2.6.24 kernel with IP address 192.168.0.2
Windows XP SP2 machine on a network domain called “home” with IP address 192.168.0.3

[color=red]Step 1: Share a Windows folder/drive[/color]

[color=green][color=red]You will first need to share a folder/drive on your Windows computer so that it can accessed through network.[/color][/color] You can do this by right-clicking on the folder/drive that you would like to share and selecting the “Sharing” option.

[color=red]Step 2: Make sure your Kernel is configured properly[/color]

If you are using a standard Linux Kernel from any distribution then it is mostly like already configured. If not then just configure and compile your Linux Kernel with the following options in bold built-in or as a module:
# cat /boot/config-2.6.24 | grep CIFS
CONFIG_CIFS=y
# CONFIG_CIFS_STATS is not set
# CONFIG_CIFS_WEAK_PW_HASH is not set
# CONFIG_CIFS_XATTR is not set
# CONFIG_CIFS_DEBUG2 is not set
# CONFIG_CIFS_EXPERIMENTAL is not set

and

# cat /boot/config-2.6.24 | grep SMB
CONFIG_SMB_FS=y
# CONFIG_SMB_NLS_DEFAULT is not set

[color=red]Step 3: Install necessary packages on your Linux machine[/color]

[color=green][color=red]You will need smbfs package and also an optional smbclient package by giving the following commands:
#apt-get update
#apt-get install smbfs smbclient[/color][/color]

The above command will also install samba-common package. If you are asked to enter a workgroup/domain name while the above packages are installed just enter the relevant information, In my case it was “home” as my domain name. You can enter your domain name or a workgroup name depending on your LAN configuration.

[color=red]Step 4: Check which shares are available for mount[/color]

Now before you mount you can also check which shares (folders/drives) are available on your Windows machine that you can mount by giving the following command:
# smbclient -L infohighway -U kushal
where
infohighway = Name (NetBIOS Name) of my computer
kushal = Username on my Windows Machine
Password:

You will get an output similar to this:
Domain=[HOME] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]
Sharename Type Comment
--------- ---- -------
myshare Disk
IPC$ IPC Remote IPC
mydownloads Disk
ADMIN$ Disk Remote Admin
C$ Disk Default share
Domain=[HOME] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]
Server Comment
--------- -------
Workgroup Master
--------- -------

From the above output you can see that I have shared folders called “myshare” and “mydownloads” on my Windows XP machine as highlighted in bold letters. This means that I can mount these folders on my Linux machine.

[color=red]Step 5: Mount the Windows Share
[/color]
Now the real thing. There are two ways to mount: The traditional SMBFS or the newer CIFS. It seems that CIFS is going to replace SMBFS which will soon become obsolete. I will show you both the methods:

[color=green]SMBFS Method Command (Old/Deprecated/Not Recommended):
# mount -t smbfs -o username=kushal,password=******** //infohighway/drivers /mnt/[/color]
where
kushal = Username on my Windows Machine
******* = Password for the user ''kushal''
infohighway = Name (NetBIOS Name) of my computer
drivers = Windows folder shared on my Windows XP machine
/mnt = Target mount directory on my Linux Machine

[color=green]CIFS Method Command:
# mount -t cifs //infohighway/drivers /mnt/ -o username=home/kushal,password=*********[/color]
where
home = DomainName/Workgroup of your LAN network
Rest of the parameters are same as in SMBFS
[color=red]
Note: If you get any error messages after you give the mount command refer to the “Some typical errors” section below.[/color]

Now you can access the contents of the Windows share now by giving the command:
# ls /mnt/drivers
# ls /mnt/
audio INFCACHE.1 network Security storage video
#

Some typical errors:

You might see some typical error messages as follow in case if you missed any steps above:

Error 1: CIFS VFS: cifs_mount failed w/return code = -22

Solution: apt-get install smbfs

Error 2: smbfs: mount_data version 1919251317 is not supported

Solution: apt-get install smbfs

You can see the above error messages (if they do occur) by giving the following command just after you issue the mount command as mentioned in Step 5 above:

# dmesg | tail

[color=green]Error 3: mount error 13 = Permission denied

Solution: Give the name of your Domain/Workgroup as shown in bold letter in Step 5 when mounting with CIFS method otherwise you will likely get this error message.
[/color]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值