|
Network Programming This website demonstrates using wikis as teaching and learning tool. The course instructor is happy to share the teaching materials here with those who find it readable. |
Lecture /
Network FilesystemsA Network Programming Lecture by Steven Choy Overview: Introduction to NFS (Network File System) - NFS Architecture - NFS Protocol - NFS Implementation - Starting up NFS - Exporting File System - NFS Transport protocol - Introduction to SMB/CIFS - What is Samba? - SMB Protocol - What is the difference between NFS and CIFS? Introduction to NFS (Network File System)"The Network File System (NFS) software allows one computer (an NFS client) attached to a network to access the filesystems present on the hard disk of another computer (an NFS server) on the network. An NFS client can mount the whole or part of a remote filesystem. It can then access the files in this filesystem almost as if they were present on a local hard disk."
"The Network File System (NFS) was developed to allow machines to mount a disk partition on a remote machine as if it were a local disk. It allows for fast, seamless sharing of files across a network."
NFS Architecture
NFS Protocol
NFS Implementation
Starting up NFS
/usr/sbin/rpc.portmap
/usr/sbin/rpc.mountd
/usr/sbin/rpc.nfsd
rpcinfo -p localhost
program vers proto port
100000 2 tcp 111 portmapper
100000 2 udp 111 portmapper
100005 1 udp 679 mountd
100005 1 tcp 681 mountd
100003 2 udp 2049 nfs
100003 2 tcp 2049 nfs
Exporting File System
/home/yourname 192.168.12.1(rw) /master(rw) trusty(rw,no_root_squash) /projects proj*.local.domain(rw) /usr *.local.domain(ro) @trusted(rw) /home/joe pc001(rw,all_squash,anonuid=150,anongid=100) /pub (ro,insecure,all_squash) /pub/private (noaccess)
# etc/rc.d/init.d/nfs stop # etc/rc.s/init.d/nfs start
mount –t nfs Server1:/export/people /usr/students mount –t nfs Server2:/nfs/users /usr/staff
NFS Transport protocol
DemonstrationNFS Server
apt-get install nfs-kernel-server nfs-common
rpcinfo -p
/root/shared 202.40.219.247(rw,sync,no_subtree_check)
/tmp 192.168.1.0/24(ro) localhost(rw) *.ev.ncku.edu.tw(ro,sync)
# [分享目錄] [第一部主機(權限)] [可用主機名] [可用萬用字元]
exportfs -ra
/etc/init.d/portmap restart
/etc/init.d/nfs-kernel-server restart
NFS Client
apt-get install portmap nfs-common
mount 202.40.219.240:/root/shared /root/import Introduction to SMB/CIFS
"The Server Message Block (SMB) Protocol is a network file sharing protocol, and as implemented in Microsoft Windows is known as Microsoft SMB Protocol. The set of message packets that defines a particular version of the protocol is called a dialect. The Common Internet File System (CIFS) Protocol is a dialect of SMB. Both SMB and CIFS are also available on VMS, several versions of Unix, and other operating systems." (Source)
NetBIOS (Network Basic Input/Output System): The NetBIOS API allows applications on separate computers to communicate over a local area network. In modern networks, it normally runs over TCP/IP, giving each computer in the network both a NetBIOS name and an IP address corresponding to a host name. (Source)
NBTSTAT - MS-DOS utility that displays protocol statistics and current TCP/IP connections using NBT (NetBIOS over TCP/IP)
nbtstat -a
Lists the remote machine's name table given its name
nbtstat -A IP
Lists the remote machine's name table given its IP address
nbtstat -n
Lists local NetBIOS names
Windows Internet Name Service (WINS) is Microsoft's implementation of NetBIOS Name Server (NBNS) on Windows, a name server and service for NetBIOS computer names. Effectively, WINS is to NetBIOS names, what DNS is to domain names - a central mapping of host names to network addresses. (Source)
How to find WINS Server IP Address if your PC have one?
What is Samba?
SMB Protocol
Samba: How does it work?
SMB Message
Establishing a SMB Connection
A brief on setting up SAMBA
sudo aptitude install samba
sudo /etc/init.d/samba stop
sudo gedit /etc/samba/smb.conf
[global]
workgroup = YOUR_WORKGROUP
[MyFiles]
path = /media/samba/
browseable = yes
read only = no
guest ok = no
create mask = 0644
directory mask = 0755
force user = YOUR_USERNAME
force group = YOUR_USERGROUP
sudo /etc/init.d/samba start
sudo smbpasswd -L -a root
sudo smbpasswd -L -e root
01 - Click "START"
02 - Click "Control Panel"
03 - Click "Network Connections"
04 - Find your "LAN Connection"
05 - Right-click the icon and select "Properties"
06 - Select the "TCP/IP" Protocol and click the "Properties" button
07 - Click "Advanced"
08 - Select the third Tab entitled "WINS"
09 - Click "Add"
10 - Type in the ip-address of your Linux box
11 - Click "Add"
12 - Select "Use NetBIOS over TCP/IP"
13 - Click "OK"
14 - Click "OK"
15 - Click "OK"
16 - Reboot Windows
What is the difference between NFS and CIFS?"NFS is the "Network File System" for Unix and Linux operating systems. It allows files to be shared transparently between servers desktops laptops etc. It is a client/server application that allows a user to view store and update files on a remote computer as though they were on their own computer. Using NFS the user or a system administrator can mount all or a portion of a file system."
"CIFS is the "Common Internet File System" used by Windows operating systems for file sharing. CIFS uses the client/server programming model. A client program makes a request of a server program (usually in another computer) for access to a file or to pass a message to a program that runs in the server computer. The server takes the requested action and returns a response. CIFS is a public or open variation of the Server Message Block Protocol (SMB) developed and used by Microsoft and it uses the TCP/IP protocol."
"NFS and CIFS are the primary file systems used in NAS. CIFS tends to be a bit more "chatty" in its communications."
(Source)
Class Discussion
References and ResourcesNetwork File System (NFS) is a network file system protocol originally jointly developed by Sun Microsystems and IBM in 1984, allowing a user on a client computer to access files over a network as easily as if the network devices were attached to its local disks. NFS, like many other protocols, builds on the Open Network Computing Remote Procedure Call (ONC RPC) system. The Network File System protocol is specified in RFC 1094, RFC 1813, and RFC 3530.
NFS為 Network FileSystem 的簡稱,最早之前是由 Sun 這家公司所發展出來的,他的目的就是想讓不同的機器、 不同的作業系統可以彼此分享個別的檔案啦!目前在 Unix Like 當中用來做為 file server 是相當不錯的一個方案喔!基本上, Unix Like 主機連接到另一部 Unix Like 主機來分享彼此的檔案時,使用 NFS 要比 SAMBA 這個伺服器快速且方便的多了!此外, NFS 的設定真的很簡單,幾乎只要記得啟動 Remote Procedure Call 這個咚咚 (RPC, 就是 portmap 這個套件啦!) 就一定可以架設的起來!真是不錯啊!不過,如果要達成 Windows 與 Linux 之間的溝通,那麼還是以 SAMBA 比較容易啊!無論如何, NFS 還是可以做為小公司或學校單位內部 Unix Like 機器共享 file 的一個 Server 喔!
在一般的區域網路中 (LAN) 如果都是 Windows 電腦,那麼使用『網路上的芳鄰』這個功能,就可以讓不同的 Windows 電腦分享彼此的檔案囉!但萬一這個 LAN 裡面有個 Linux 主機時,我怎麼讓 Linux 也加入這個 Windows 電腦當中的『網路上的芳鄰』呢?也就是說,讓 Windows 電腦可以透過『網路上的芳鄰』來存取 Linux 主機上面的檔案!呵呵!那就是 SAMBA 這個伺服器的主要目的了!
As many fellow Ubuntu users seem to have trouble setting up samba peer-to-peer with Windows I decided to write a small howto on this matter. NOTE: I am aware that there's a wiki-page as well as several other howto's around - but by looking at the constant "how do I setup samba" posts that are floating around in the forum I simply see the need for a more thourough guide on this matter.
Samba is a set of tools to share files and printers with computers running Windows. It implements the SMB network protocol, which is the heart of Windows networking.
Samba is an Open Source/Free Software suite that has provided file and print services to all manner of SMB/CIFS clients, including the numerous versions of Microsoft Windows operating systems. Samba is freely available under the GNU General Public License.
在 Windows 環境中,我們通常透過網路芳鄰來達成彼此機器間的資源分享工作,但是若想要與 Unix-Based 作業系統間做到資源分享,就會比較困難。一般在 Windows 與 Unix-Based 作業系統間,我們都會利用 FTP 或 NFS 來做檔案交換的工作,但這只能做到單方面資源的要求,而無法達到雙向互通。幸好 Samba Server 的出現可以解決這個難題。
This tutorial explains how to turn an old PC with additional hard disks into a simple home file server. The file server is intended for home use. The home file server is accessible by Windows and Linux computers in the home network.
Thanks for ReadingIf you would rather like to have this lecture note in printed format, please click the print action link in the top right corner. If you find any problem in this lecture note, please feel free to tell Steven via steven@findaway.hk. |