rhel5下的DHCP服务和DHCP中继的配置

rhel5下的DHCP服务和DHCP中继

 

[root@localhost ~]# rpm -q dhcp
package dhcp is not installed               (
查看dhcp包没有安装)

[root@localhost ~]# mount /dev/cdrom /mnt   (挂载光盘并安装dhcp包)
mount: block device /dev/cdrom is write-protected, mounting read-only

[root@localhost ~]# rpm -ivh /mnt/Server/dhcp- 3.0.5 -3.el5.i386.rpm
warning: /mnt/Server/dhcp-3.0.5-3.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing...                ########################################### [100%]
   1:dhcp                   ########################################### [100%]

[root@localhost ~]# vi /etc/dhcpd.conf (编辑dhcp配置文件,建两个作用域)

#
# DHCP Server Configuration file.
#   see /usr/share/doc/dhcp*/dhcpd.conf.sample
#
ddns-update-style       interim;
default-lease-time      21600;
max-lease-time          43200;
option domain-name     "yang.com";
option domain-name-servers     192.168.0.20;
subnet 192.168.0.0     netmask 255.255.255.0{
        range   192.168.0.100   192.168.0.200;
        option subnet-mask     255.255.255.0;
        option routers         192.168.0.254;
}
subnet 172.16.0.0      netmask 255.255.0.0{
        range   172.16.0.100    172.16.0.200;
        option subnet-mask     255.255.0.0;
        option routers         172.16.0.254;
}
~
~
~
~
"/etc/dhcpd.conf" 19L , 522C
(保存退出)

[root@localhost ~]# service dhcpd start    (启动dhcp服务)
Starting dhcpd:                                            [ OK ]


[root@localhost ~]# netstat -nupl
(查看当前的UDP端口侦听)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name
udp        0      0 0.0.0 .0:943                 0.0.0.0:*                               1615/rpc.statd
udp        0      0 0.0.0.0:946                 0.0.0.0:*                               1615/rpc.statd
udp        0      0 0.0.0.0:67                  0.0.0.0:*                               3438/dhcpd
udp        0      0 0.0.0.0:111                 0.0.0.0:*                               1590/portmap
udp        0      0 0.0.0.0:631                 0.0.0.0:*                               1850/cupsd

客户端获取到的IP信息如下:

..............
[root@localhost ~]# cat /var/lib/dhcpd/dhcpd.leases
(查看租约文件)

lease 192.168.0.200 {
starts 5 2008/11/14 10:18:35;
ends 5 2008/11/14 16:18:35;
binding state active;
next binding state free;
hardware ethernet 00:03:ff:44: 1a :b9;
uid "\001\000\003\377D\032\271";
client-hostname "dc";
}

[root@localhost ~]# chkconfig --level 35 dhcpd on (设置dhcp服务在35级别自动启动)

DHCP中继的实现:

ogin as: root    (使用管理员用户登陆)
[email protected]'s password:
Last login: Fri Nov 14 04:33:18 2008 from 192.168.0.2
[root@localhost ~]# mount /dev/cdrom /mnt
(挂载光盘并安装dhcp包)
mount: block device /dev/cdrom is write-protected, mounting read-only
[root@localhost ~]# rpm -ivh /mnt/Server/dhcp- 3.0.5 -3.el5.i386.rpm
warning: /mnt/Server/dhcp-3.0.5-3.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing...                ########################################### [100%]
   1:dhcp                   ########################################### [100%]


[root@localhost ~]# rpm -ql dhcp |grep /etc
(查看dhcp包包含在/etc目录下的文件信息)
/etc/dhcpd.conf
/etc/rc.d/init.d/dhcpd
/etc/rc.d/init.d/dhcrelay
/etc/sysconfig/dhcpd
/etc/sysconfig/dhcrelay

[root@localhost ~]# vi /etc/sysconfig/dhcrelay (编辑/etc/sysconfig/dhcrelay 文件并启用中继功能)

# Command line options here
INTERFACES="eth0 eth1"
(定义在那个网卡上启用中继功能)
DHCPSERVERS="192.168.0.20"
(定义dhcp服务器的IP

[root@localhost ~]# service dhcrelay start (启用中继服务)
Starting dhcrelay: Internet Systems Consortium DHCP Relay Agent V 3.0.5 -RedHat
Copyright 2004-2006 Internet Systems Consortium.
All rights reserved.
For info, please visit
http://www.isc.org/sw/dhcp/
Listening on LPF/eth1/00:03:ff:4d: 1a :b9
Sending on   LPF/eth1/00:03:ff:4d: 1a :b9
Listening on LPF/eth0/00:03:ff:42: 1a :b9
Sending on   LPF/eth0/00:03:ff:42: 1a :b9
Sending on   Socket/fallback
                                                           [ OK ]

[root@localhost ~]# netstat -unpl (查看UDP端口的侦听信息)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name
udp        0      0 0.0.0 .0:646                 0.0.0.0:*                               1742/rpc.statd
udp        0      0 0.0.0.0:649                 0.0.0.0:*                               1742/rpc.statd
udp        0      0 0.0.0.0:67                  0.0.0.0:*                               3139/dhcrelay
udp        0      0 0.0.0.0:111                 0.0.0.0:*                               1717/portmap
udp        0      0 0.0.0.0:631                 0.0.0.0:*                               1977/cupsd

[root@localhost ~]# chkconfig --level 35 dhcrelay on (设置dhcp中继服务在35级别自动启用)

 

本文出自 “上善若水威加海内” 博客,转载请与作者联系!

你可能感兴趣的:(职场,休闲)