You are on page 1of 15

TRUNG DAI HC SU PHAM KY THUAT TP HO CHI MINH

KHOA CNTT
./








BO CO HJ DIEU HNH UNIX






GVHD: Nguyn Thi Thanh Vn
SVTH: Nguyn Trong Nghia 08110077
Nguyn Hoang Qun






SPKT-Thang 11
IV. H thng thng tin mng NIS - Network Information System rror!
Bookmark not deIined.
1. Gioi thiu v NIS
- NIS (Network InIormation System) la mt ung dung cung cp cac tin ich truy nhp co so du liu d phn
phi thng tin.
-Dich vu thng tin mang NIS cho phep ban tao ra cac tai khoan co kha nng chia se trn moi h thng trong mang
cua ban.
2. Hoat dng cua NIS
-NIS la 1 dich vu cho phep chung thuc user tp trung. Cac tai khoan nguoi dung chi duoc tao ra trn NIS server. Cac NIS
client tai thng tin va mt khu cn thit tu NIS server d chung thuc mi khi user dng nhprror! Bookmark
not defined.
3. Cai dt va cu hinh cho may chu NIS rror! Bookmark not defined.
a. Cai dt may chu NIS chinh:
-Buoc 1: Install portmap
Su dung lnh: sudo apt-get install portmap
-Buoc 2:Update portmap deIaults
Su dung lnh: sudo update-rc.d portmap defaults 10
-Buoc3 : Install NIS
Su dung lnh: sudo apt-get install nis
-Buoc 4: dit/etc/deIault/nis
Su dung lnh: sudo nano /etc/default/nis
NISS#V# master
NISCLINTIalse
-Buoc 5: dit/ etc/ypserv.securenets
Su dung lnh: sudo nano /etc/ypserv.securenets
-Buoc 6: dit/var/yp/MakeIile
Su dung lnh: sudo nano /var/yp/Makefile
-Buoc 7: #estart the portmap daemon
Su dung lnh: sudo service portmap restart
-Buoc 8: #estart the NIS daemon
Su dung lnh: sudo service nis restart
-Buoc 9: Invoke /usr/lib/yp/ypinit m
Su dung lnh: sudo nano /usr/lib/yp/ypinit -m
-Buoc 10: Add the users
Su dung lnh: sudo useradd -d /home/username -m username
-Buoc 11: Set password cho user
Su dung lnh: sudo passwd username
-Buoc 12: Compile new user
Su dung lnh: cd /var/yp/rror! Bookmark not defined.
b. Cai dt may chu NIS phu rror! Bookmark not defined.
c. Cai dt tram khach NIS
-Buoc 1: Install portmap
Su dung lnh: sudo apt-get install portmap
-Buoc 2: update portmap
Su dung lnh: sudo update-rc.d portmap defaults 10
-Buoc 3: install Nis
Su dung lnh: sudo apt-get install nis
-Buoc 4: dit /etc/host.Add server`s hostname
Su dung lnh: sudo nano /etc/hosts
-Buoc 5: dit/etc/yp.conI
Su dung lnh :sudo nano /etc/yp.conf
-Buoc 6: dit /etc/nisswitch.conI
Su dung lnh: sudo nano /etc/nisswitch.conf
-Buoc 7: ModiIy the permissions
Su dung lnh: sudo chmod 777 /home
-Buoc 8: #eboot Client
Su dung lnh: sudo reboot
-Buoc 9:Test the NIS client`s connection to the NIS server
Su dung lnh: ypcat passwd

V. H thng tp mng NFS - Network File System (431)rror! Bookmark not defined.
1. Gioi thiu v NFS
neLwork llle SysLem nlS do cng Ly Sun MlcrosysLems Lro ra vrl mrc dlch dung dr chla sr cc Lrp Lln v Lhr
mrc glra nhrng hr dlru hnh unlx vrl nlS khl mrL Lrp Lln horc Lhr mrc drrc dung chung n grn nhr Lrr
Lhnh mrL phrn hr Lhrng cra ngrrl dung Lhay vl c mrL Lrn my r xa nlS c Lhr sr drng cho nhlru klru
mrng khc nhau nhrng Lhrc Lr n drrc LhlrL kr dr lm vlrc vrl 1C/l v hlrn nay nlS vrn drrc sr drng phr
blrn Lrn cc mrng 1C/l8n Lrong hr dlru hnh Llnux v unlx nlS sr horL drng r chr dr ngang hngulru
ny c nghla my Llnh cra ngrrl dung c val Lr nhr mrL my khch cra drch vr nlS Lrn mrL my khc v l
my phrc vr cho nhrng my khc Lrn mrng horc drng Lhrl dng cr hal val Lr
2. Hoat dng cua NFS
nlS l mrL cr chr hr Lrr vlrc chla sr Ll nguyn glra cc my chr Llnux nlS drrc phL Lrlrn dr cho phep hr Lhrng nrl
br c Lhr Lruy xurL mrL Lhr mrc Lrn hr Lhrng my khc brng cch grn (mounL) n vo hr Lhrng Lrp Lln crc br ngrrl
quan Lrr Lrn hr Lhrng nlS Server chr crn xurL (exporL) cc Lhr mrc dr cung crp cho cc nlS CllenL sr drng

rror! Bookmark not defined.rror! Bookmark not defined.3. Cac chuong trinh cua dich vu
NFS
nlS (nfsd) vrn hnh phr Lhurc vo 3 daemon
a. portmap: cung cap co ch map gia dch vu va port tuong ng
b. mountd: mountd xu ly cac mount request tu phia client
c. lockd : ly file locking
d statd: cng xu ly xu ly Iile locking
e. rquoLad poo l flle pooto tto cc tb mc cblo s
4. Cac buoc thuc hin cu hinh NFS sever:
Cai dt:
S Check if instSeu
nfs
(Readhat: rpm qa | grep nfs-utils)
\[^tmS\



dpkg --get-selections | grep portmap

portmap install
dpkg --get-selections | grep nfs

libnfsidmap2 install
nfs-common install
nfs-kernel-server install


b nstS


(Readhat:yum install nfs-utils)
c. KiHm t^S stStus
r


Cu hinh:

a. se^be^
Cc file cu hnh:
O /etc/exports Main conIiguration Iile
O /etc/hosts.allow Hosts to allow access
O /etc/hosts.deny Hosts to deny access
Ngoai ra con co cac Iile lien quan dn pormap
O /etc/deIault/portmap: configuration file
O sudo dpkg-reconIigure portmap: configuration script

Flle ,etc,exportx
llle ny grm nhlru dng Mrl dng c 3 Lhnh Lhnh phrnuru Lln l Ln Lhr mrc chla sr 1hr 2 l hosLname horc lp
cra my crn chla sr 1a c Lhr dung *" horc neLmask dr chr nhlru my nru La br qua Lhnh phrn ny Lhl Lhr mrc sr
drrc chla sr vrl LrL cr vrl mrl my Lrong mrng1hnh phrn Lhr ba l cc opLlons



pub (ro,sync) dns2.spkt.net(rw,no_subtree_check,sync)
pubdata 192.168.2.5(ro)
hone *.spkt.net(ro ,sync)
tftpboot nodisk.example.org(rw,no_root_squash,no_subtree_check,sync)
hometronghiaspk 192.168.0.0255.255.255.0(ro)
hometronghiaspk 192.168.0.024(ro)
hometronghiaspk192.168.0.024(ro)

etcinit.dnfs-kernel-server
etcinit.dportmap
sudo service nfs-kernel-server status
sudo service portmap status
dpkg --get-selections | grep nfs

libnfsidmap2 install
nfs-common install
nfs-kernel-server install

sudo apt-get install portmap nfs-common nfs-kernel-server
2
3
,etc,exportx Optlonx
ption Description
ro llows read-only access
rw Supports readwrite access
sync Requires synchronous reads and writes
async llows reads, with data to be written held in memory
secure Specifies communication through TCPP ports below 1024
insecure llows communication through TCPP ports above 1024
wdelay Groups writes from multiple systems together
no_wdelay llows immediate writes to a shared NFS directory
hide Prevents sharing of subdirectories
no_hide ncludes subdirectories of shared directories
subtree_check Checks higher level directories for permissions
no_subtree_check Does not check higher level directories for permissions
insecure_locks Disables file locking; needed for older NFS clients
secure_locks llows file locking
all_squash Maps all connected users to anonymous
root_squash Maps requests from the root user to anonymous
no_root_squash llows the root user full administrative access to the shared directory
anonuid=xyz Specifies the UD of the anonymous user
anongid=xyz Specifies the GD of the anonymous group


t's not enough to configure etcexports. The first time the file is created, you'll need toactivate those exports with the
command.

When modifying, moving, or deleting a share, it is safest to temporarilyunexport all filesystems first with theflowing
command before re-exporting theshares with the exportfs -a command.

nce exports are active, they're easy to check:
n the share pc

n the other pc


Flle ,etc,hoxtx.Jeny vd ,etc,hoxtx.ullow
Hai Iile nay xac dinh nhung may nao duoc su dung hay khng duoc su dung dich vu trn may chu NFS. Mi
dong cua nhung Iile nay lit k ra mt dich vu va dia chi cua cac may. Khi may chu nhn duoc mt yu cu tu 1
may A no s xu ly theo thu tu nhu sau:
klrm Lra flle hosLsallow dr xem my A c Lrung vrl rule Lrong d khng nru c Lhl my A drrc phep Lruy crp
2 nru my A khng Lrung vrl brL ky rule no Lrong flle hosLsallow server sr klrm Lra flle hosLsdeny nru A Lrung
vrl rule Lrong flle ny Lhl sr br Lr chrl Lruy crp
3 nru A khng Lrung vrl rule no Lrong cr 2 flle Lhl n drrc cho phep Lruy crp
Do do 1 nguyn tc d cu hinh 2 Iile nay la:
1r chrl quyrn Lruy crp Lrn LrL cr cc drch vr r flle hosLsdeny
2 Crp quyrn Lruy crp Lrng drch vr cr Lhr r flle hosLsallow
showmount -e sharePcName
showmount -e localhost
exportfs -ua
exportfs a
Cu th ni dung cua Iile hosts.deny nhu sau:

Va Iile host.allow nhu sau:

O dy cng co th thay bng dia chi network tuong tu nhu trong Iile exports.
KbHi dHng dHcb vH:

(Readhat: service nfs start)
Nu khoi dng cac dich vu 1 cach thu cng thi theo thu tu: portmap mountd nIsd statd lockd rquotad.
Co th kim tra cac dich vu d khoi dng dy du chua bng lnh ps -eI hoc rpcinIo.
5. Cac buoc thuc hin cu hinh NFS client
- Install
nIs
- Mount thu muc chia se tu server vao h thng thu muc local:

- Umount:

- dit Iile /etc/Istab d tu dng mount thu muc chia se khi khoi dng may:

# device mountpoint fs-type options dump fsckorder

spkt.net:/home/tronghiaspk /var/nfs_share nfs rw 0 0

sudo umount /var/nfs_share
sudo mount -t nfsspkt.net:/home /var/nfs_share
Ho!c ch can.
sudo mount spkt.net:/home /var/nfs_share
sudo apt-get install portmap nfs-common nfs-kernel-server
service nfs-kernel-server start
portmap: 192.168.2.0/24
mountd: 192.168.2.0/24
statd: 192.168.2.0/24
lockd: 192.168.2.0/24
rquotad: 192.168.2.0/24
portmap: ALL
mountd: ALL
lockd: ALL
statd: ALL
rquotad: ALL
.u : Trn Fedora Core 14 h thng Iirewall iptables duoc kich hoat mc dinh do do d NFS client co th kt
ni duoc vao server cn phai tao rule cho iptables hoc don gian nht la tt iptables di bng lnh 8ervice
iptable8 8top.

VI. Samba - Chia se tai nguyn voi Windows rror! Bookmark not defined.
Gioi thiu Cai dt
a.Gioi thiu
Samba l chrrng Lrlnh Llrn lch hr Lrr vlrc chla sr Ll nguyn Lr hr Lhrng Llnux vrl cc hr
Lhrngkhc(Llnux Wlndows) n hr Lrr Llnh nng gla nhrp([oln) Llnux vrl Wlndows nhr gla nhrp Llnuxvo
uC Lrn Wlndows gla nhrp vo Wlndows Workgroup

Cc hr Lhrng Llnux sr drng glao Lhrc 1C/l Lrong krL nrl mrng Lrong khl d hr dlru hnh cra MlcrosofL
sr drng mrL glao Lhrc krL nrl mrng khc glao Lhrc Server Message 8lock (SM8) glao Lhrc ny sr drng
neL8lS dr cho phep cc my Llnh chry Wlndows chla sr cc Ll nguyn vrl nhau Lrong mrng crc br ur
krL nrl Lrl cc mrng lrn bao grm cr nhrng hr Lhrng unlx MlcrosofL phL Lrlrn Common lnLerneL llle
SysLem (CllS) CllS vrn sr drng SM8 v neL8lS cho mrng Wlndows Samba l chrrng Lrlnh Llnux ngurn
mr cl drL glao Lhrc SM8 hr Lrr vlrc glao Llrp glra 2 hr Lhrng wlndows v Llnux

Samba cung crp brn drch vr chlnh drch vr chla sr Lrp Lln v my ln xc Lhrc v crp phep phn glrl Ln
v Lhng bo drch vr8r Samba grm nhlru Lhnh phrnuaemon mang Ln smbd cung crp drch vr ln rn
v Lrp Lln LrpLln cru hlnh cra uaemon ny l smbconf Cn daemon nmbd Lhl cung crp chrc nng phn
glrl Ln neL8lS v hr Lrr drch vr duyrL Lhr mrc cho phep cc my Llnh khc Lruy crp v sr drng cc Ll
nguyn drrc crp brl my chr Samba uaemon smbcllenL horL drng nhr mrL cllenL blnh Lhrrng glrng
nhr fLp 1rlnh Llrn lch ny dung khl brn Lruy crp nhrng Ll nguyn Lrn cc server Lrrng Lhlch khc

Samba c sr drng Lrp Lln /eLc/samba/smbpassword dr lru Lrr cc mrL m Lruy nhrp ngrrl dung

b Cai dt

Check if
instSeu

(Readhat: rpm qa | grep nfs-utils )
nstS

Hu tS khng hH t^H cc my winu[ws thi khng cHn ci smbfs

(Readhat:yum install nfs-utils)
KiHm t^S stStus

^




etcinit.dnfs-kernel-server
etcinit.dportmap
sudo service nfs-kernel-server status
sudo service portmap status
sudo apt-get install samba

sudo apt-get install samba smbfs
dpkg --get-selections | egrep "smb|samba"

Cac lnh samba thuong dung:
smbclient -L //hostname
findsmb
smbtree

2. Thuc hin cac chuong trinh Samba Deamon rror! Bookmark not defined.
3. Tp cu hinh /etc/smb.conI
8ackup Lhe /etc/samba/smb.conf flle
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.original

Tao Iile master
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.master

Sinh file thu gon
testparms/etc/samba/smb.conf.master/etc/samba/smb.conf


restart the samba services to enable the new conIiguration:
sudo restart smbd&&sudo restart nmbd
rror! Bookmark not defined.
4. Chia se tp tin cua Linux cho Windows rror! Bookmark not defined.
5. Chia se cac tp tin Windows cho Linux
sudo mount.cifs 192.168.2.11backups hometronghiaspkmnt
sudoumount.cifs hometronghiaspkmnt

H kbc nbau cHa NF va
Sr khc blrL lrn nhrL d l
+ SAM8A ru dlrm lrn nhrL l cung crp khr nng share cho mrl hr Lhrng Lrc l c Lhr cho 2 hay nhlru hr Lhrng khc
nhau nhr l llnux cho wlndows v ngrrc lrlnhrng hrn chr r mrL khla crnh no d khr nng v cr chr cra SAM8A
khng Lhrc sr hlru qur brng nlS
+ nlS drrc nng cao hrn vr hlru surL v khr nng sr drng Ll nguyn glra cc my chr llnux vrl nhau nhrng hrn chr
rrL lrn d l khng Lhr chla sr glra cc hr Lhrng khc nhau Lrc l khng Lhr chla sr llnux v wlndows v ngrrc lrl

asic Linux networking Commands

is\Sy Cu^^ent C[nfig f[^ S Cs ifc[nfig

is\Sy Cu^^ent C[nfig f[^ eth ifc[nfig eth

Assign ifc[nfig eth 98 |netmSsk <i\ mSsk>j

llle scrlpL conflg card mang
/eLc/sysconflg/neLworkscrlpLs/lfcfgcar name
/eLc/neLwork/lnLerfaces (ueblan)

ing \ing -c 98

Assign muti\e s ifc[nfig eth 98

Assign sec[nu ifc[nfig eth 98

isSbe netw[^k cS^u ifc[nfig eth u[wn

EnSbe netw[^k cS^u ifc[nfig eth u\

view cu^^ent ^[uting tSbe ^[ute [^ ^[ute -n

view S^\ cSche S^\ [^ S^\ -n

Assign ubnet ifc[nfig eth 98 netmSsk

Assign efSut uStewSy ^[ute Suu uefSut gw 98

T^Sce R[ute t^Sce^[ute wwwwhStismyi\c[m

T^Sce Sth t^Sce\Sth wwwwhStismyi\c[m

Test h[st wwwwhStismyi\c[m

AubSnceu Test uig wwwwhStismyi\c[m

Rebe^se L[[ku\ h[st 99

AubSnceu Rebe^se L[[ku\ uig -x 99

Xem ten pc cua may: hosLname

Set ten pc cua may hosLname Len mol
Poac sua Lrong flle
/eLc/hosLname ubunLu
/eLc/sysconflg/neLwork ledora

I||e host (dung thay dns serv|ce)
/eLc/hosLs

estart network serv|ce
servlce neLwork resLarL
sudo /eLc/lnlLd/neLworklng resLarL

Set gateway cho tung mang
rouLe add neL dla chl mang neLmask neL mask gw dla chl gaLeway

|ng a|| hosts on LAN
for lp ln $(seq 233) do plng c 22$lp/dev/null $? eq 0 echo 2$lp u || done
Danh sach cac serv|ces
/eLc/servlces
|vates I range
0000 0233233233
200 23233233
200 2233233
ebmin
Change password
#eadHead: sudo/usr/share/webmln/changepasspl /eLc/webmln rooL rooL
ueblan sudo /usr/llbexec/webmln/changepasspl /eLc/webmln rooL rooL
N
bttps:JJbelp.ubuntu.comJ.JserverguideJCJdns.btml
Cbeck if N installed
dpkg --get-selections , grep bind

nstallation N
At a terminal prompt enter the Iollowing command to install dns:
sudo apt-get install bind9
(bind9utils)

sudoservicebind9

nsIookup, host, and dig (https://heIp.ubuntu.com/11.10/serverguide/C/dns-troubIeshooting.htmI)


be N configuration files are stored in tbe /etc/bind directory
$ Configuration FiIe escription
named.conf Primary BND9 configuration file
named.conf.options BND9 configuration file for caching and forwarding
named.conf.local BND9 configuration file for administrator input
db.0 Reverse zone file for the default zone
db.127 Reverse zone file for the loopback interface
db.255 Reverse zone file for the broadcast zone
db.empty Reverse zone designated for private P address networks
db.local Zone file for the loopback interface
db.root List of root servers for the nternet
rndc.key uthentication key for DNS requests; can be changedwith the rndc-confgen command
zones.rfc1918 File for reverse lookups of private P address networks
etcdefaultbind9 File with start parameters for the BND9 service
etcbindnamed.conf.default-zones

File cau binb N client
caL /eLc/resolvconf
et ddress from C to tatic
II the Ubuntu Server installer has set your server to use DHCP you will want to change it to a static IP address
so that people can actually use it.
Changing this setting without a GUI will require some text editing but that`s classic linux right?
Let`s open up the /etc/network/interIaces Iile. I`m going to use vi but you can choose a diIIerent editor
sudo vi /etc/network/interIaces
For the primary interIace which is usually eth0 you will see these lines:

auto eth0
iface eth0 inet dhcp
As you can see it`s using DHCP right now. We are going to change dhcp to static and then there are a number
oI options that should be added below it. Obviously you`d customize this to your network.
auto eth0
iface eth0 inet static
address 192.168.2.3
netmask 255.255.255.0
network 192.168.2.0
broadcast 192.168.2.255
gateway 192.168.2.1

vanngyenqb[gmallcom
nop de cuong bao cao som de Cv dleu chlnh
nop nol dung bao cao(wordslldevldeo) Lruoc 3 ngay (//20)
ngay bao cao nop ban ln sllde

You might also like