开发者社区> 科技小能手> 正文
阿里云
为了无法计算的价值
打开APP
阿里云APP内打开

毕业设计之DHCP服务器的搭建

简介:
+关注继续查看

 

动态主机配置协议(Dynamic Host Configuration Protocol ,DHCP)是一个局域网的网络协议,使用udp协议工作,主要有两个用途:给内部网络或网络服务供应商自动分配IP地址;给用户或者内部网络管理员作为对所有计算机作中央管理的手段。端口号:server端 67 ,client端 68

服务器环境:

操作系统:

Red Hat Enterprise Linux Server 5.4 内核版本: 2.6.18-164.el5

需要的软件:

dhcp-3.0.5-21.el5.i386.rpm

网络参数:

IP: 192.168.1.178/28 netmask:255.255.255.240 Gateway:192.168.1.190

准备工作:

image 下的settings

image

[root@localhost ~]# mkdir /mnt/cdrom 
[root@localhost ~]# mount /dev/cdrom /mnt/cdrom 
mount: block device /dev/cdrom is write-protected, mounting read-only 
[root@localhost ~]# cd /mnt/cdrom/Server/ 
[root@localhost Server]# rpm -ivh dhcp-3.0.5-21.el5.i386.rpm 
warning: dhcp-3.0.5-21.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186 
Preparing...                ########################################### [100%] 
   1:dhcp                   ########################################### [100%]

[root@localhost Server]# vim /etc/dhcpd.conf

image

subnet 192.168.1.64 netmask 255.255.255.224 {

# --- default gateway 
        option routers                  192.168.1.94; 
        option subnet-mask              255.255.255.224;

        option nis-domain               "domain.org"; 
        option domain-name              "domain.org"; 
        option domain-name-servers      192.168.1.177;

        option time-offset              -18000; # Eastern Standard Time 
#       option ntp-servers              192.168.1.1; 
#       option netbios-name-servers     192.168.1.1; 
# -- you understand Netbios very well 
#       option netbios-node-type 2;

        range dynamic-bootp 192.168.1.65 192.168.1.92; 
        default-lease-time 21600; 
        max-lease-time 43200;

        # we want the nameserver to appear at a fixed address 
        host vlan10 { 
                next-server marvin.redhat.com; 
                hardware ethernet 12:34:56:78:AB:CD; 
                fixed-address 207.175.42.254; 
        } 

# DHCP Server Configuration file. 
#   see /usr/share/doc/dhcp*/dhcpd.conf.sample

subnet 192.168.1.0 netmask 255.255.255.192 {

# --- default gateway 
        option routers                  192.168.1.62; 
        option subnet-mask              255.255.255.192;

        option domain-name              "domain.org"; 
        option domain-name-servers      192.168.1.177;

        option time-offset              -18000; # Eastern Standard Time

        range dynamic-bootp 192.168.1.1 192.168.1.60; 
        default-lease-time 21600; 
        max-lease-time 43200;

        # we want the nameserver to appear at a fixed address 
        host vlan20 { 
                next-server marvin.redhat.com; 
                hardware ethernet 12:34:56:78:AB:CD; 
                fixed-address 207.175.42.254; 
        } 

subnet 192.168.1.96 netmask 255.255.255.224 {

# --- default gateway 
        option routers                  192.168.1.126; 
        option subnet-mask              255.255.255.224;

        option domain-name              "domain.org"; 
        option domain-name-servers      192.168.1.177;

        option time-offset              -18000; # Eastern Standard Time

        range dynamic-bootp 192.168.1.97 192.168.1.124; 
        default-lease-time 21600; 
        max-lease-time 43200;

        # we want the nameserver to appear at a fixed address 
        host vlan30 { 
                next-server marvin.redhat.com; 
                hardware ethernet 12:34:56:78:AB:CD; 
                fixed-address 207.175.42.254; 
        } 
}

subnet 192.168.1.160 netmask 255.255.255.240 {

# --- default gateway 
        option routers                  192.168.1.174; 
        option subnet-mask              255.255.255.240;

        option domain-name              "domain.org"; 
        option domain-name-servers      192.168.1.177;

        option time-offset              -18000; # Eastern Standard Time

        range dynamic-bootp 192.168.1.161 192.168.1.172; 
        default-lease-time 21600; 
        max-lease-time 43200;

        # we want the nameserver to appear at a fixed address 
        host vlan40 { 
                next-server marvin.redhat.com;

                hardware ethernet 12:34:56:78:AB:CD; 
                fixed-address 207.175.42.254; 
        } 
}

 

subnet 192.168.1.128 netmask 255.255.255.224 {

# --- default gateway 
        option routers                  192.168.1.158; 
        option subnet-mask              255.255.255.224;

        option domain-name              "domain.org"; 
        option domain-name-servers      192.168.1.177;

        option time-offset              -18000; # Eastern Standard Time

        range dynamic-bootp 192.168.1.129 192.168.1.156; 
        default-lease-time 21600; 
        max-lease-time 43200;

        # we want the nameserver to appear at a fixed address 
        host vlan50 { 
                next-server marvin.redhat.com; 
                hardware ethernet 12:34:56:78:AB:CD; 
                fixed-address 207.175.42.254; 
        } 
}

subnet 192.168.1.176 netmask 255.255.255.240 
{      }

image

 

SNMP代理配置:

安装net-snmp软件,使该主机成为agent。由于安装需要依赖lm_sensors软件,所以使用yum工具解决依赖关系

[root@localhost ~]# vim /etc/yum.repos.d/rhel-debuginfo.repo

image

[root@localhost ~]# yum install net-snmp -y 
Loaded plugins: rhnplugin, security 
This system is not registered with RHN. 
RHN support will be disabled. 
Setting up Install Process 
Resolving Dependencies 
--> Running transaction check 
---> Package net-snmp.i386 1:5.3.2.2-7.el5 set to be updated 
--> Processing Dependency: libsensors.so.3 for package: net-snmp 
--> Running transaction check 
---> Package lm_sensors.i386 0:2.10.7-4.el5 set to be updated 
--> Finished Dependency Resolution

Installed: 
  net-snmp.i386 1:5.3.2.2-7.el5                                           

Dependency Installed: 
  lm_sensors.i386 0:2.10.7-4.el5                                          

Complete! 
[root@localhost ~]# vim /etc/snmp/snmpd.conf

image

image去掉#号,启用该行的功能

49 rocommunity public 
50 rwcommunity private

77 com2sec mynetwork  192.168.1.193/28 public

[root@localhost ~]# service snmpd start 
Starting snmpd:                                            [  OK  ] 
[root@localhost ~]# chkconfig snmpd on 
[root@localhost ~]# netstat -tupln|grep snmp 
tcp        0      0 127.0.0.1:199               0.0.0.0:*                   LISTEN      28703/snmpd         
udp        0      0 0.0.0.0:161                 0.0.0.0:*                               28703/snmpd       

日志转发:

编辑系统日志配置文件/etc/syslog.conf,将需要转发的日志发送到指定的日志服务器上。咋日志类型后面加 @日志服务器的地址 即可将日志发送到指定的日志服务器上。

[root@localhost ~]# vim /etc/syslog.conf

7 *.info;mail.none;authpriv.none;cron.none                @192.168.1.194

 image




本文转自 gjp0731 51CTO博客,原文链接:http://blog.51cto.com/guojiping/1157472

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
23704
文章
0
问答
文章排行榜
最热
最新
相关电子书
更多
低代码开发师(初级)实战教程
立即下载
阿里巴巴DevOps 最佳实践手册
立即下载
冬季实战营第三期:MySQL数据库进阶实战
立即下载