其他分享
首页 > 其他分享> > DHCP给不同vlan分配IP

DHCP给不同vlan分配IP

作者:互联网

网络拓扑图如下:

 

接入层交换机划分vlan、与核心交换机相连的接口打trunk

SW3:

<Huawei>system-view
[Huawei]undo info-center enable 
[Huawei]sysname SW3
[SW3]vlan 10
[SW3-vlan10]quit
[SW3]port-group group-member Ethernet 0/0/2 to Ethernet 0/0/3 #端口组操作 [SW3-port-group]port link-type access [SW3-port-group]port default vlan 10 [SW3-port-group]quit [SW3]interface Ethernet0/0/1 [SW3-Ethernet0/0/1]port link-type trunk [SW3-Ethernet0/0/1]port trunk allow-pass vlan 10

 

SW4:

<Huawei>system-view
[Huawei]undo info-center enable 
[Huawei]sysname SW4
[SW4]vlan 20
[SW4-vlan20]quit
[SW4]interface Ethernet0/0/2 [SW4-Ethernet0/0/2]port link-type access [SW4-Ethernet0/0/2]port default vlan 20 [SW4-Ethernet0/0/2]quit [SW4]interface Ethernet0/0/1 [SW4-Ethernet0/0/1]port link-type trunk [SW4-Ethernet0/0/1]port trunk allow-pass vlan 20

 

SW5:

<Huawei>system-view
[Huawei]undo info-center enable
[Huawei]sysname SW5
[SW5]vlan 30
[SW5-vlan30]quit
[SW5]port-group group-member Ethernet 0/0/2 to Ethernet 0/0/3 [SW5-port-group]port link-type access [SW5-port-group]port default vlan 30 [SW5-port-group]quit
[SW5]interface Ethernet0/0/1 [SW5-Ethernet0/0/1]port link-type trunk [SW5-Ethernet0/0/1]port trunk allow-pass vlan 30

 

SW6:

<Huawei>system-view
[Huawei]undo info-center enable
[Huawei]sysname SW6
[SW6]vlan 80
[SW6-vlan80]quit
[SW6]interface Ethernet0/0/2 [SW6-Ethernet0/0/2]port link-type access [SW6-Ethernet0/0/2]port default vlan 80 [SW6-Ethernet0/0/2]quit [SW6]interface Ethernet0/0/1 [SW6-Ethernet0/0/1]port link-type trunk [SW6-Ethernet0/0/1]port trunk allow-pass vlan all

 

SW7:

<Huawei>system-view 
[Huawei]undo info-center enable
[Huawei]sysname SW7
[SW7]vlan 90
[SW7-vlan90]quit

[SW7]interface Ethernet0/0/2
[SW7-Ethernet0/0/2]port link-type access 
[SW7-Ethernet0/0/2]port default vlan 90
[SW7-Ethernet0/0/2]quit

[SW7]interface Ethernet0/0/1
[SW7-Ethernet0/0/1]port link-type trunk
[SW7-Ethernet0/0/1]port trunk allow-pass vlan all

 

核心交换机配置:

SW1:

<Huawei>system-view
[Huawei]undo info-center enable
[Huawei]sysname SW1
[SW1]vlan batch 10 20 30 80 90

[SW1]port-group group-member GigabitEthernet 0/0/1 to GigabitEthernet 0/0/5
[SW1-port-group]port link-type trunk 
[SW1-port-group]quit

 

SW2:

<Huawei>system-view
[Huawei]undo info-center enable
[Huawei]sysname SW2
[SW2]vlan batch 80 90

[SW2]port-group group-member GigabitEthernet 0/0/1 to GigabitEthernet 0/0/3
[SW2-port-group]port link-type trunk
[SW2-port-group]port trunk allow-pass vlan all

 

DHCP服务器配置

AR1:

<Huawei>system-view 
[Huawei]undo info-center enable 
[Huawei]sysname AR1
[AR1]dhcp enable

VLAN 10配置DHCP:
[AR1]interface GigabitEthernet 0/0/0.10    #创建子接口
[AR1-GigabitEthernet0/0/0.10]ip address 10.10.10.1 24    #配置IP地址
[AR1-GigabitEthernet0/0/0.10]dot1q termination vid 10    #绑定vlan10
[AR1-GigabitEthernet0/0/0.10]arp broadcast enable    #开启arp广播
[AR1-GigabitEthernet0/0/0.10]dhcp select global    #全局分配地址
[AR1-GigabitEthernet0/0/0.10]quit       #退出

[AR1]ip pool vlan10        #创建地址池vlan10
[AR1-ip-pool-vlan10]network 10.10.10.0 mask 24        #设定网段
[AR1-ip-pool-vlan10]gateway-list 10.10.10.1        #配置网关地址
[AR1-ip-pool-vlan10]dns-list 10.10.10.1        #配置dns地址
[AR1-ip-pool-vlan10]quit



VLAN 20配置DHCP:
[AR1]interface GigabitEthernet 0/0/0.20
[AR1-GigabitEthernet0/0/0.20]ip address 20.20.20.1 24
[AR1-GigabitEthernet0/0/0.20]dot1q termination vid 20
[AR1-GigabitEthernet0/0/0.20]arp broadcast enable
[AR1-GigabitEthernet0/0/0.20]dhcp select global
[AR1-GigabitEthernet0/0/0.20]quit 

[AR1]ip pool vlan20
[AR1-ip-pool-vlan20]network 20.20.20.0 mask 24
[AR1-ip-pool-vlan20]gateway-list 20.20.20.1
[AR1-ip-pool-vlan20]dns-list 20.20.20.1
[AR1-ip-pool-vlan20]quit 



VLAN 30配置DHCP:
[AR1]interface GigabitEthernet 0/0/0.30
[AR1-GigabitEthernet0/0/0.30]ip address 30.30.30.1 24
[AR1-GigabitEthernet0/0/0.30]dot1q termination vid 30
[AR1-GigabitEthernet0/0/0.30]arp broadcast enable
[AR1-GigabitEthernet0/0/0.30]dhcp select global
[AR1-GigabitEthernet0/0/0.30]quit

[AR1]ip pool vlan30
[AR1-ip-pool-vlan30]network 30.30.30.0 mask 24
[AR1-ip-pool-vlan30]gateway-list 30.30.30.1
[AR1-ip-pool-vlan30]dns-list 30.30.30.1



VLAN 80配置DHCP:
[AR1]interface GigabitEthernet 0/0/0.80
[AR1-GigabitEthernet0/0/0.80]ip address 80.80.80.1 24
[AR1-GigabitEthernet0/0/0.80]dot1q termination vid 80
[AR1-GigabitEthernet0/0/0.80]arp broadcast enable
[AR1-GigabitEthernet0/0/0.80]dhcp select global
[AR1-GigabitEthernet0/0/0.80]quit

[AR1]ip pool vlan80
[AR1-ip-pool-vlan80]network 80.80.80.0 mask 24
[AR1-ip-pool-vlan80]gateway-list 80.80.80.1
[AR1-ip-pool-vlan80]dns-list 80.80.80.1



VLAN 90配置DHCP:
[AR1]interface GigabitEthernet 0/0/0.90
[AR1-GigabitEthernet0/0/0.90]ip address 90.90.90.1 24
[AR1-GigabitEthernet0/0/0.90]dot1q termination vid 90
[AR1-GigabitEthernet0/0/0.90]arp broadcast enable
[AR1-GigabitEthernet0/0/0.90]dhcp select global 
[AR1-GigabitEthernet0/0/0.90]quit

[AR1]ip pool vlan90
[AR1-ip-pool-vlan90]network 90.90.90.0 mask 24
[AR1-ip-pool-vlan90]gateway-list 90.90.90.1
[AR1-ip-pool-vlan90]dns-list 90.90.90.1

 

配置完成后,我们在PC上改为自动获取IP,然后再去ping不同vlan的电脑IP

标签:AR1,IP,Ethernet0,vlan,GigabitEthernet0,ip,DHCP,port,pool
来源: https://www.cnblogs.com/xiykj/p/15211161.html