[root@dhcpser ~]# rpm -q dhcp //

放入RHEL5.9 iso镜像

[root@dhcpser ~]# cd /misc/cd/Server //

[root@dhcpser Server]# ls *dhcp*

[root@dhcpser Server]# rpm -ivh dhcp-3(tab)

[root@dhcpser Server]# rpm -q dhcp

dhcp-3.0.5-31.el5_8.1

3. 修改配置文件

[root@dhcpser ~]# cat -n /etc/dhcpd.conf 

  1 ddns-update-style none;

  2         default-lease-time 21600;

  3         max-lease-time 43200;

  4         option subnet-mask              255.255.255.0;

  5         option domain-name              "ta.com";

  6         option domain-name-servers      202.106.0.20;

  7 subnet 192.168.10.0 netmask 255.255.255.0 {

  8         option routers                  192.168.10.254;

  9         range dynamic-bootp 192.168.10.10 192.168.10.20;

 10         host win7 {

 11                 hardware ethernet 00:0C:29:E1:F6:25;

 12                 fixed-address 192.168.10.80;

 13         }

 14 }

4. 启动服务

[root@dhcpser ~]# rpm -ql dhcp | grep init.d

/etc/rc.d/init.d/dhcpd

/etc/rc.d/init.d/dhcrelay

[root@dhcpser ~]# service dhcpd restart

[root@dhcpser ~]# chkconfig dhcpd on

注:如果启动失败,可以检测主配置文件语法

[root@dhcpser ~]# service dhcpd configtest

5. 验证

Linux:

# dhclient -d eth0 临时获取

# dhclient -r eth0 释放

Windows:

cmd>ipconfig /release 释放ip

cmd>ipconfig /renew 重新获取ip






---------------RHEL5.9_A----(vmnet1)----RHEL5.9_B----------- 


RHEL5.9_A: 192.168.10.253/24

RHEL5.9_B: 192.168.10.20/24



实验一:

将/root 共享给192.168.10.20,可写、同步,允许客户机以root权限访问

NFS服务端操作:

[root@dhcpser ~]# cat /etc/exports 

/root   192.168.10.20(rw,sync,no_root_squash)

[root@dhcpser ~]# service portmap restart

[root@dhcpser ~]# service nfs restart

[root@dhcpser ~]# chkconfig portmap on

[root@dhcpser ~]# chkconfig nfs on

NFS客户端操作:

[root@localhost ~]# service portmap restart

[root@localhost ~]# showmount -e 192.168.10.253

Export list for 192.168.10.253:

/root    192.168.10.20

[root@localhost ~]# mkdir -p /data/root/

[root@localhost ~]# mount 192.168.10.253:/root/ /data/root/

[root@localhost ~]# df -hT | grep nfs

               nfs     19G  2.7G   16G  15% /data/root

[root@localhost ~]# cd /data/root/

[root@localhost root]# touch file1.txt

[root@localhost root]# ls -l file1.txt 

-rw-r--r-- 1 root root 0 06-12 17:18 file1.txt


实验二:

将/usr/src 共享给192.168.10.0/24网段,可写、异步

NFS服务端操作:

[root@dhcpser ~]# cat /etc/exports 

/root   192.168.10.20(rw,sync,no_root_squash)

/usr/src        192.168.10.0/24(rw,async)

[root@dhcpser ~]# exportfs -rv //...

[root@dhcpser ~]# setfacl -m u:nfsnobody:rwx /usr/src/

NFS客户端操作:

[root@localhost ~]# mkdir /data/src/

[root@localhost ~]# showmount -e 192.168.10.253

Export list for 192.168.10.253:

/root    192.168.10.20

/usr/src 192.168.10.0/24

[root@localhost ~]# mount 192.168.10.253:/usr/src/ /data/src/

[root@localhost ~]# cd /data/src/

[root@localhost src]# touch file1.txt

[root@localhost src]# ls -l file1.txt 

-rw-r--r-- 1 nfsnobody nfsnobody 0 06-12 17:23 file1.txt


实验三:

在上一个实验基础上实现客户端上面所有用户身份都映射成nfsnobody

NFS服务端操作:

[root@dhcpser ~]# chmod o+w /usr/src/

NFS客户端操作:

[root@localhost ~]# useradd tom

[root@localhost ~]# su - tom

[tom@localhost ~]$ cd /data/src/

[tom@localhost src]$ touch tom1.txt

[tom@localhost src]$ ls -l tom1.txt 

-rw-rw-r-- 1 tom tom 0 06-12 17:29 tom1.txt

再来修改NFS主配置文件

[root@dhcpser ~]# cat /etc/exports 

/root   192.168.10.20(rw,sync,no_root_squash)

/usr/src        192.168.10.0/24(rw,async,all_squash)

[root@dhcpser ~]# exportfs -rv

NFS客户端操作:

[tom@localhost src]$ touch tom2.txt

[tom@localhost src]$ ls -l tom2.txt 

-rw-rw-r-- 1 nfsnobody nfsnobody 0 06-12 17:31 tom2.txt