DHCP实验

Linux–DHCP实验

实验环境:

wmware station上的centos 7.6虚拟机, ENSP

实验目的:利用linux中DHCP 给不同VLAN下终端划分IP,实现互通,从而更好的理解DHCP工作原理

实验步骤:

1 在ENSP上进行绘制拓扑图,并配置

2在centos7.6虚拟机上进行DHCP配置

一:在ENSP上进行绘制拓扑图,并配置

mark

1.1LSW2配置

1.1.1关闭提示功能

undo terminal monitor
Info: Current terminal monitor is off.

1.1.2Ethernet0/0/2口配VLAN10

[LSW2]int e0/0/2
[LSW2-Ethernet0/0/2]p l a
[LSW2-Ethernet0/0/2]p d v 10
[LSW2-Ethernet0/0/2]undo sh

1.1.3Ethernet0/0/3口配VLAN20

[LSW2-Ethernet0/0/2]int e0/0/3
[LSW2-Ethernet0/0/3]p l a
[LSW2-Ethernet0/0/3]p d v 20
[LSW2-Ethernet0/0/3]undo sh

1.1.4Ethernet0/0/4口配VLAN100

[LSW2-Ethernet0/0/3]int e0/0/4
[LSW2-Ethernet0/0/4]p l a
[LSW2-Ethernet0/0/4]p d v 100
[LSW2-Ethernet0/0/4]undo sh

1.1.5Ethernet0/0/1口配trunk

[LSW2-GigabitEthernet0/0/1]port link-type trunk
[LSW2-GigabitEthernet0/0/1]port trunk allow-pass vlan all

1.2 LSW1配置

1.2.1关闭提示功能

undo terminal monitor
Info: Current terminal monitor is off.

[LSW1]v b 10 20 100

1.2.2三层交换机配网关地址

[LSW1]int vlanif10
[LSW1-Vlanif10]ip add 192.168.10.1/24
[LSW1-Vlanif10]ip add 192.168.10.1 24
[LSW1-Vlanif10]int vlanif20
[LSW1-Vlanif20]ip add 192.168.20.1 24
[LSW1-Vlanif20]int vlanif100
[LSW1-Vlanif100]ip add 192.168.100.1 24

1.2.3配trunk

[LSW1]int g0/0/1
[LSW1-GigabitEthernet0/0/1]port link-type trunk
[LSW1-GigabitEthernet0/0/1]port trunk allow-pass vlan all

1.2.4DHCP配置

[LSW1]dhcp enable 全局模式开启DHCP功能
[LSW1]int vlanif10
[LSW1-Vlanif10]dhcp select relay
[LSW1-Vlanif10]dhcp relay server-ip 192.168.100.100
[LSW1-Vlanif10]int vlanif20
[LSW1-Vlanif20]dhcp select relay
[LSW1-Vlanif20]dhcp relay server-ip 192.168.100.100
[LSW1-Vlanif20]int vlanif100
[LSW1-Vlanif100]dhcp select relay
[LSW1-Vlanif100]dhcp relay server-ip 192.168.100.100

二:在centos7.6虚拟机上进行DHCP配置

2.1安装DHCP

  •  root@promote ~]# yum -y install dhcp*
     已加载插件:fastestmirror, langpacks
     Loading mirror speeds from cached hostfile
     
    * base: mirrors.ustc.edu.cn
    * extras: mirrors.ustc.edu.cn
    * updates: mirrors.ustc.edu.cn
      软件包 12:dhcp-4.2.5-79.el7.centos.x86_64 已安装并且是最新版本
      软件包 12:dhcp-common-4.2.5-79.el7.centos.x86_64 已安装并且是最新版本
      软件包 12:dhcp-devel-4.2.5-79.el7.centos.x86_64 已安装并且是最新版本
      软件包 12:dhcp-libs-4.2.5-79.el7.centos.x86_64 已安装并且是最新版本
      无须任何处理
    
2.2绑定wmnet3网卡

mark

2.3修改网卡配置信息

[root@promote ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33

mark

[root@promote ~]# systemctl restart network 重启网卡
[root@promote ~]# setenforce 0 临时关闭防火墙
[root@promote ~]# iptables -F


[root@promote ~]# ifconfig 查看网卡信息
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.100.100 netmask 255.255.255.0 broadcast 192.168.100.255
inet6 fe80::4692:cf70:d003:ced4 prefixlen 64 scopeid 0x20
ether 00:0c:29:9b:e6:9e txqueuelen 1000 (Ethernet)
RX packets 114 bytes 25666 (25.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 267 bytes 29039 (28.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0


### 2.4ping网关能否连通

检查自己的网关

[root@promote ~]# ping 192.168.100.1
PING 192.168.100.1 (192.168.100.1) 56(84) bytes of data.
64 bytes from 192.168.100.1: icmp_seq=1 ttl=128 time=0.216 ms
64 bytes from 192.168.100.1: icmp_seq=2 ttl=128 time=0.409 ms
64 bytes from 192.168.100.1: icmp_seq=3 ttl=128 time=0.465 ms




ping 192.168.10.1

### 2.5 修改配置文件

[root@localhost dhcp]# cp /usr/share/doc/dhcp-/dhcpd.conf.example
cp: 在"/usr/share/doc/dhcp-4.2.5/dhcpd.conf.example" 后缺少了要操作的目标文件 复制提示的dhcp包
[root@localhost dhcp]#cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp

[root@localhost dhcp]# vim dhcpd.conf

mark

三 ping 测试连通性

pc1分配到了10网段地址池的IP

mark

ping pc2

mark

能ping通

pc2分配到了20网段地址池的IP

mark

ping pc1

mark

能ping通

ping服务器

mark

  • 5
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值