三层交换机实现DHCP功能

典型操作:三层交换机+VLAN实现网络

可以实现基本的企业需求

华为的三层交换机实现DHCP功能,需要给vlan划分地址池

1.网络拓扑图

三层交换机实现DHCP功能_第1张图片

2.三层交换机的配置 

//三层交换机的配置
//配置IP地址池,实现DHCP时分配给vlan下的终端
[Huawei]ip pool vlan20
Info:It's successful to create an IP address pool.
//地址池的IP范围
[Huawei-ip-pool-vlan20]network 192.168.2.0 mask 24	
//不进行分配的IP地址
[Huawei-ip-pool-vlan10]excluded-ip-address 192.168.1.253
[Huawei-ip-pool-vlan10]q
[Huawei]ip pool vlan20
Info:It's successful to create an IP address pool.
[Huawei-ip-pool-vlan20]network 192.168.2.0 mask 24	
[Huawei-ip-pool-vlan20]excluded-ip-address 192.168.2.253
[Huawei-ip-pool-vlan20]q
[Huawei]ip pool vlan30
Info:It's successful to create an IP address pool.
[Huawei-ip-pool-vlan30]network 192.168.3.0 mask 24
[Huawei-ip-pool-vlan30]excluded-ip-address 192.168.3.253
[Huawei-ip-pool-vlan30]q
//开启DHCP功能
[Huawei]dhcp enable
Info: The operation may take a few seconds. Please wait for a moment.done.
[Huawei]int vlan 10
[Huawei-Vlanif10]dhcp select global
[Huawei-Vlanif10]q
[Huawei]int vlan 20
[Huawei-Vlanif20]dhcp select global
[Huawei-Vlanif20]q
[Huawei]int vlan 30
[Huawei-Vlanif30]dhcp select global 
[Huawei]ip pool vlan10
//这里出现问题,接口开启DHCP全局模式后,vlan配置网关失败需要我们手动清理占用此网关的设备,重新配置网关
[Huawei-ip-pool-vlan10]gateway-list 192.168.1.254
Error:The IP address's status is error.
//首先查看vlan下的IP池子是否存在,池子的使用情况
[Huawei]dis ip pool name vlan10 
  Pool-name      : vlan10
  Pool-No        : 0
  Lease          : 1 Days 0 Hours 0 Minutes
  Domain-name    : -
  DNS-server0    : -               
  NBNS-server0   : -               
  Netbios-type   : -               
  Position       : Local           Status           : Unlocked
  Gateway-0      : -               
  Mask           : 255.255.255.0
  VPN instance   : --
 -----------------------------------------------------------------------------
         Start           End     Total  Used  Idle(Expired)  Conflict  Disable
 -----------------------------------------------------------------------------
     192.168.1.1   192.168.1.254   254     3        249(0)         1        1
 -----------------------------------------------------------------------------

//退出配置模式
[Huawei]q
//在全局模式下关闭被占用的地址
reset ip pool name vlan10 192.168.1.254
Warning: If the IP addresses that are being used are reclaimed, may influence no
rmal user in the network. Are you sure to continue?[Y/N]:y
sy
Enter system view, return user view with Ctrl+Z.
[Huawei]ip pool vlan10
//配置网关	
[Huawei-ip-pool-vlan10]gateway-list 192.168.1.254	
[Huawei-ip-pool-vlan10]IP POol vlan20	
[Huawei-ip-pool-vlan20]gateway-list 192.168.2.254
Error:The IP address's status is error.
[Huawei]q
reset ip pool name vlan20 192.168.2.254
Warning: If the IP addresses that are being used are reclaimed, may influence no
rmal user in the network. Are you sure to continue?[Y/N]:y
sy
Enter system view, return user view with Ctrl+Z.
[Huawei]ip pool vlan20
[Huawei-ip-pool-vlan20]gateway-list 192.168.2.254
[Huawei-ip-pool-vlan20]q
reset ip pool name vlan30 192.168.3.254
Warning: If the IP addresses that are being used are reclaimed, may influence no
rmal user in the network. Are you sure to continue?[Y/N]:y
sy
Enter system view, return user view with Ctrl+Z.
[Huawei]ip pool vlan30	
[Huawei-ip-pool-vlan30]gateway-list 192.168.3.254
[Huawei-ip-pool-vlan30]q

3.DHCP的两种模式interface和global的区别

dhcp select interface

该命令用于在指定接口上启用DHCP服务

1、在系统模式启用DHCP的功能-----dhcp enable

2、给路由器(服务器)接口配地址

3、进入接口dhcp的选择模式为接口模式:dhcp select interface

4、IP池子、掩码、网关:不用配

原因:这一个接口的地址所在的网段就自动变成了地址池范围里

dhcp select global

1、在系统模式启用DHCP的功能-----dhcp enable

2、给路由器(服务器)接口配地址

3、在系统模式启用一个地址池(需起名)----ip pool c1  (c1为地址池名)

4、在地址池里定义

IP池子(地址池范围:必须和接口地址在一个网段内)-----network

网络掩码----mask

网关(与路由接口地址一致)----geteway-list

DNS(需两个后一个为备份)----dns-list(eg:61.134.1.4   8.8.8.8    8.8.4.4)

排除地址----excloud-ip-address(用户常用固定ip)

网址租约----lease day# hour# minute#

上网必配:IP、网络掩码、网关、DNS

5、在接口把dncp的生成方式选择称为全局模式  ----dhcp select global

4.注释

1.三层功能

二次交换机和三层交换机的区别在于:是否具备三层功能

三层功能,是帮助不同网段做数据转发的功能,也叫路由功能

2.交换机接口的access和trunk的区别

一、Access

三层交换机实现DHCP功能_第2张图片
1.Access只能属于一个vlan,一般用来连接计算机的端口
2.Access接受和转发的数据包必是无VID的数据包
3.Access端口发送出去的数据包无VID,可被PC接受或access口接受。
4.Access : 收到一个报文,先判断是否有vlan消息,无则打上端口的PVID在SW内转交给相同PVID的端口去掉标记的无VID数据包,有则直接丢弃。
二、Trunk

三层交换机实现DHCP功能_第3张图片
1.Trunk:可以允许多个vlan通过,可以接收和发送多个vlan的报文,一般用于交换机之间连接端口
2.Trunk:默认PVID与vlan1相等
3.在默认状态下,Trunk端口允许所有的Vlan发送和接口传输信息。
4.Trunk:收到一个报文,先判断是否有vlan消息,无则打上端口的PVID在SW内转交给其它端口;有则先判断trunk端口是否允许该vlan的数据进入,如果可以则转发,否则丢弃。
5.Trunk:在发送时,比较要发送报文的VID与端口的PVID,不相等则直接发送;相等则剥离VID,再发送

 

 

你可能感兴趣的:(网络,服务器,linux)