VLAN的划分实现全网可达

配置了华为路由器上的DHCP服务,创建了10网段和20网段的地址池,并通过dot1q配置虚拟子接口实现VLAN间的路由。交换机上配置了VLAN10和20,以及相应的access和trunk接口,确保全网可达。PC通过DHCP获取IP地址后能ping通不同VLAN的主机。
摘要由CSDN通过智能技术生成

根据条件1可知,我们需要在路由器上配置dhcp,两个池子分别放入10网段和20网段,根据vlan划分和地址配置要求,需要用到虚拟子接口并配置dot1q,实现vlan间的路由,配置代码如下:

<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys R1	
[R1]user-interface console 0
[R1-ui-console0]idle-timeout 0 0
[R1-ui-console0]q

[R1]interface g0/0/0.100	
[R1-GigabitEthernet0/0/0.100]dot1q termination vid 10
[R1-GigabitEthernet0/0/0.100]ip address 10.1.1.100 24	
[R1-GigabitEthernet0/0/0.100]arp broadcast enable 
[R1-GigabitEthernet0/0/0.100]q
[R1]int g0/0/0.200
[R1-GigabitEthernet0/0/0.200]dot1q termination vid 20
[R1-GigabitEthernet0/0/0.200]ip address 20.1.1.200 24
[R1-GigabitEthernet0/0/0.200]arp broadcast  enable 
[R1-GigabitEthernet0/0/0.200]q

[R1]dhcp enable 
[R1]ip pool 10
[R1-ip-pool-10]network 10.1.1.0 mask 24
[R1-ip-pool-10]gateway-list 10.1.1.100	
[R1-ip-pool-10]dns-list 8.8.8.8


[R1]ip pool 20
[R1-ip-pool-20]network 20.1.1.0 mask 24
[R1-ip-pool-20]gateway-list 20.1.1.200	
[R1-ip-pool-20]dns-list 8.8.8.8

[R1]interface g0/0/0.100
[R1-GigabitEthernet0/0/0.100]dhcp select global 
	
[R1-GigabitEthernet0/0/0.100]int g0/0/0.200
[R1-GigabitEthernet0/0/0.200]dhcp select global 


[R1]dis ip pool 
  -----------------------------------------------------------------------
  Pool-name      : 10
  Pool-No        : 0
  Position       : Local           Status           : Unlocked
  Gateway-0      : 10.1.1.100      
  Mask           : 255.255.255.0
  VPN instance   : --

  -----------------------------------------------------------------------
  Pool-name      : 20
  Pool-No        : 1
  Position       : Local           Status           : Unlocked
  Gateway-0      : 20.1.1.200      
  Mask           : 255.255.255.0
  VPN instance   : --


  IP address Statistic
    Total       :506   
    Used        :0          Idle        :506   
    Expired     :0          Conflict    :0          Disable   :0     


[R1]dis ip int br
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 4
The number of interface that is DOWN in Physical is 2
The number of interface that is UP in Protocol is 3
The number of interface that is DOWN in Protocol is 3

Interface                         IP Address/Mask      Physical   Protocol  
GigabitEthernet0/0/0              unassigned           up         down      
GigabitEthernet0/0/0.100          10.1.1.100/24        up         up        
GigabitEthernet0/0/0.200          20.1.1.200/24        up         up        
GigabitEthernet0/0/1              unassigned           down       down      
GigabitEthernet0/0/2              unassigned           down       down      
NULL0                             unassigned           up         up(s)     


在交换机上配置好vlan10和vlan20,同一vlan用access接口,vlan间通信用trunk接口,在交换机L1和路由器R1之间仍然需要配置trunk接口

[L1]vlan batch 10 20
Info: This operation may take a few seconds. Please wait for a moment...done.

[L1]int g0/0/1
[L1-GigabitEthernet0/0/1]port link-type access 	
[L1-GigabitEthernet0/0/1]port default vlan 10

[L1]interface g0/0/2
[L1-GigabitEthernet0/0/2]port link-type access 
[L1-GigabitEthernet0/0/2]port default vlan 20
[L1-GigabitEthernet0/0/2]q
                        
[L1]interface int	
[L1]interface g0/0/3	
[L1-GigabitEthernet0/0/3]port link-type trunk 
[L1-GigabitEthernet0/0/3]port trunk allow-pass vlan all
                        
	
[L1]int g0/0/4	
[L1-GigabitEthernet0/0/4]port link-type trunk 
[L1-GigabitEthernet0/0/4]port trunk allow-pass vlan all

[L1]dis vlan
The total number of vlans is : 3
--------------------------------------------------------------------------------
U: Up;         D: Down;         TG: Tagged;         UT: Untagged;
MP: Vlan-mapping;               ST: Vlan-stacking;
#: ProtocolTransparent-vlan;    *: Management-vlan;
--------------------------------------------------------------------------------

VID  Type    Ports                                                          
--------------------------------------------------------------------------------
1    common  UT:GE0/0/3(U)      GE0/0/4(U)      GE0/0/5(D)      GE0/0/6(D)      
                GE0/0/7(D)      GE0/0/8(D)      GE0/0/9(D)      GE0/0/10(D)     
                GE0/0/11(D)     GE0/0/12(D)     GE0/0/13(D)     GE0/0/14(D)     
                GE0/0/15(D)     GE0/0/16(D)     GE0/0/17(D)     GE0/0/18(D)     
                GE0/0/19(D)     GE0/0/20(D)     GE0/0/21(D)     GE0/0/22(D)     
                GE0/0/23(D)     GE0/0/24(D)                                     

10   common  UT:GE0/0/1(U)                                                      
             TG:GE0/0/3(U)      GE0/0/4(U)                                      

20   common  UT:GE0/0/2(U)                                                      

             TG:GE0/0/3(U)      GE0/0/4(U)                                      


VID  Status  Property      MAC-LRN Statistics Description      
--------------------------------------------------------------------------------

1    enable  default       enable  disable    VLAN 0001                         
10   enable  default       enable  disable    VLAN 0010                         
20   enable  default       enable  disable    VLAN 0020  



<L2>sys
Enter system view, return user view with Ctrl+Z.
[L2]vlan batch 10 20
Info: This operation may take a few seconds. Please wait for a moment...done.

[L2]interface g0/0/1	
[L2-GigabitEthernet0/0/1]port link-type access 
[L2-GigabitEthernet0/0/1]port default vlan 10


[L2-GigabitEthernet0/0/2]port link-type access 
[L2-GigabitEthernet0/0/2]port default vlan 20
[L2-GigabitEthernet0/0/2]q
                                           

[L2]interface g0/0/3	
[L2-GigabitEthernet0/0/3]port link-type trunk 	
[L2-GigabitEthernet0/0/3]port trunk allow-pass vlan all
[L2-GigabitEthernet0/0/3]q
[L2]dis vlan
The total number of vlans is : 3
--------------------------------------------------------------------------------
U: Up;         D: Down;         TG: Tagged;         UT: Untagged;
MP: Vlan-mapping;               ST: Vlan-stacking;
#: ProtocolTransparent-vlan;    *: Management-vlan;
--------------------------------------------------------------------------------

VID  Type    Ports                                                          
--------------------------------------------------------------------------------
1    common  UT:GE0/0/3(U)      GE0/0/4(D)      GE0/0/5(D)      GE0/0/6(D)      
                GE0/0/7(D)      GE0/0/8(D)      GE0/0/9(D)      GE0/0/10(D)     
                GE0/0/11(D)     GE0/0/12(D)     GE0/0/13(D)     GE0/0/14(D)     
                GE0/0/15(D)     GE0/0/16(D)     GE0/0/17(D)     GE0/0/18(D)     
                GE0/0/19(D)     GE0/0/20(D)     GE0/0/21(D)     GE0/0/22(D)     
                GE0/0/23(D)     GE0/0/24(D)                                     

10   common  UT:GE0/0/1(U)                                                      

             TG:GE0/0/3(U)                                                      

20   common  UT:GE0/0/2(U)                                                      

             TG:GE0/0/3(U)                                                      


VID  Status  Property      MAC-LRN Statistics Description      
--------------------------------------------------------------------------------

1    enable  default       enable  disable    VLAN 0001                         
10   enable  default       enable  disable    VLAN 0010                         
20   enable  default       enable  disable    VLAN 0020                         

 将每一台pc的·dhcp打开,获取对应的ip地址,以下只演示pc1,可ping通vlan10和vlan20的主机,至此已实现全网可达。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值