centos下搭建dhcp服务器

前端之家收集整理的这篇文章主要介绍了centos下搭建dhcp服务器前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

centos下搭建dhcp服务器

一、软件环境

CentOS release 6.5

dhcp-4.1.1-51.P1.el6.centos.x86_64

dhcp-common-4.1.1-51.P1.el6.centos.x86_64

二、网络拓扑

dhcp服务器--H3c交换机(7503)-- H3c交换机(5500)-- H3c交换机(3100)--dhcp客户端(办公电脑)

网段:

10.2.240.0/24

10.2.180.0/24

dhcp服务器ip:10.2.33.253

三、安装dhcp服务器

#yum -y installdhcpdhcp-common

#chkconfig dhcpd on

#cd/usr/share/doc/dhcp-4.1.1/

#cp dhcpd.conf.sampl /etc/dhcp/dhcpd.conf

#ifconfig

em1 Link encap:Ethernet HWaddr F0:4D:A2:01:7E:53

inet addr:10.2.33.253 Bcast:10.2.33.255 Mask:255.255.255.0

inet6 addr: fe80::f24d:a2ff:fe01:7e53/64 Scope:Link

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:331357784 errors:0 dropped:0 overruns:0 frame:0

TX packets:301154296 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:226431663072 (210.8 GiB) TX bytes:124796979532 (116.2 GiB)


# cat /etc/sysconfig/dhcpd


# Command line options here

DHCPDARGS=em1


#cat /etc/dhcp/dhcpd.conf

# dhcpd.conf

#

# Sample configuration file for ISC dhcpd

#


# option definitions common to all supported networks...

option domain-name "test.com";

option domain-name-servers 202.106.196.115,202.106.0.20;


default-lease-time 54000; #默认租约时间(秒)

max-lease-time 72000;#最大租约时间(秒)

log-facility local7;


subnet 10.2.240.0 netmask 255.255.255.0 {

range 10.2.240.11 10.2.240.100;

option routers 10.2.240.1;

option broadcast-address 10.2.240.255;

}

# This is a very basic subnet declaration.


subnet 10.2.180.0 netmask 255.255.255.0 {

range 10.2.180.101 10.2.180.150;

option routers 10.2.180.1;

option broadcast-address 10.2.180.255;

}

#为特定主机保留的ip地址

host fantasia {

hardware ethernet 00:25:64:A7:39:B4;

fixed-address 10.2.180.12;

}

#dhcp服务器网卡的网段,不加此网段,dhcp服务起不来

subnet 10.2.33.0 netmask 255.255.255.0 {

range 10.2.33.100 10.2.33.101;

option routers 10.2.33.1;

option broadcast-address 10.2.33.255;

}


#service dhcpd start

#netstat -anlp |grep dhcp


udp 0 0 0.0.0.0:67 0.0.0.0:* 14719/dhcpd

raw 0 0 0.0.0.0:1 0.0.0.0:* 7 14719/dhcpd

unix 2 [ ] DGRAM 13369026 14719/dhcpd


防火墙打开udp 67端口


四、交换机设置

登录7503交换机

[7503]dhcp relay server-group 1 ip 10.2.33.253

[7503]interface Vlan-interface 240

[7503-Vlan-interface240]dhcp select relay

[7503-Vlan-interface240]dhcp relay server-select 1

[7503]interface Vlan-interface 180

[7503-Vlan-interface180]dhcp select relay

[7503-Vlan-interface180]dhcp relay server-select 1

登录5500交换机

[5500]dhcp relay server-group 1 ip 10.2.33.253

[5500]interface Vlan-interface 240

[5500-Vlan-interface240]dhcp select relay

[5500-Vlan-interface240]dhcp relay server-select 1

[5500]interface Vlan-interface 180

[5500-Vlan-interface180]dhcp select relay

[5500-Vlan-interface180]dhcp relay server-select 1

五、测试

修改客户端电脑ip为自动获得模式,获得ip成功。

猜你在找的CentOS相关文章