目录
1、access、trunk
2、配置终结子接口
3、DHCP接口地址池、DNS
4、静态默认路由、接口IP
5、ACL、NAT 使内网用户可以访问外网
6、VLANIF
某公司拥有多个部门且位于不同网段,各部门均有访问Internet的需求。现要求用户通过二层交换机和路由器访问外部网络,且要求路由器作为用户的网关。(单臂路由)
二层交换机指的是仅能够进行二层转发,不能进行三层转发的交换机。也就是说仅支持二层特性,不支持路由等三层特性的交换机。二层交换机一般部署在接入层,不能作为用户的网关。
1、access、trunk
<HUAWEI> system-view
[HUAWEI] sysname Switch
[Switch] vlan batch 2 3
[Switch] interface gigabitethernet 0/0/2
[Switch-GigabitEthernet0/0/2] port link-type access //配置接口接入类型为access
[Switch-GigabitEthernet0/0/2] port default vlan 2 //配置接口加入VLAN 2
[Switch-GigabitEthernet0/0/2] quit
[Switch] interface gigabitethernet 0/0/3
[Switch-GigabitEthernet0/0/3] port link-type access
[Switch-GigabitEthernet0/0/3] port default vlan 3
[Switch-GigabitEthernet0/0/3] quit
[Switch] interface gigabitethernet 0/0/1
[Switch-GigabitEthernet0/0/1] port link-type trunk
[Switch-GigabitEthernet0/0/1] port trunk allow-pass vlan 2 3 //配置接口以trunk方式透传VLAN 2和VLAN 3
[Switch-GigabitEthernet0/0/1] quit
2、配置终结子接口
<Huawei> system-view
[Huawei] sysname Router
[Router] vlan batch 2 3
[Router] interface gigabitethernet 0/0/1.1
[Router-GigabitEthernet0/0/1.1] dot1q termination vid 2
[Router-GigabitEthernet0/0/1.1] ip address 192.168.1.1 24
[Router-GigabitEthernet0/0/1.1] arp broadcast enable //缺省状态下,AR路由器终结子接口的ARP广播功能在V200R003C01之前版本处于未使能状态,在V200R003C01及之后版本处于使能状态
[Router-GigabitEthernet0/0/1.1] quit
[Router] interface gigabitethernet 0/0/1.2
[Router-GigabitEthernet0/0/1.2] dot1q termination vid 3
[Router-GigabitEthernet0/0/1.2] ip address 192.168.2.1 24
[Router-GigabitEthernet0/0/1.2] arp broadcast enable
[Router-GigabitEthernet0/0/1.2] quit
3、DHCP接口地址池、DNS
[Router] dhcp enable
[Router] interface gigabitethernet 0/0/1.1
[Router-GigabitEthernet0/0/1.1] dhcp select interface //DHCP使用接口地址池的方式为内网用户分配IP地址
[Router-GigabitEthernet0/0/1.1] dhcp server dns-list 114.114.114.114 223.5.5.5 //配置的DNS-List 114.114.114.114是公用的DNS服务器地址,是不区分运营商的。在实际应用中,请根据运营商分配的DNS进行配置
[Router-GigabitEthernet0/0/1.1] quit
[Router] interface gigabitethernet 0/0/1.2
[Router-GigabitEthernet0/0/1.2] dhcp select interface
[Router-GigabitEthernet0/0/1.2] dhcp server dns-list 114.114.114.114 223.5.5.5
[Router-GigabitEthernet0/0/1.2] quit
4、静态默认路由、接口IP
[Router] interface gigabitethernet 0/0/2
[Router-GigabitEthernet0/0/2] ip address 203.0.113.2 255.255.255.0 //配置连接公网的接口GE0/0/2的IP地址203.0.113.2
[Router-GigabitEthernet0/0/2] quit
[Router] ip route-static 0.0.0.0 0.0.0.0 203.0.113.1 //配置静态缺省路由的下一跳指向公网提供的IP地址203.0.113.1
5、ACL、NAT 使内网用户可以访问外网
[Router] acl number 2001
[Router-acl-basic-2001] rule 5 permit source 192.168.0.0 0.0.255.255 //NAT转换只对源IP地址是192.168.0.0/16网段的生效,并在接口GE0/0/2的出方向进行转换
[Router-acl-basic-2001] quit
[Router] interface gigabitethernet 0/0/2
[Router-GigabitEthernet0/0/2] nat outbound 2001
[Router-GigabitEthernet0/0/2] quit
6、VLANIF
<Huawei> system-view
[Huawei] sysname Router
[Router] vlan batch 2 3
[Router] interface gigabitethernet 0/0/1
[Router-GigabitEthernet0/0/1] portswitch //将以太网接口从三层模式切换到二层模式。如果接口已经是二层模式,跳过该步骤
[Router-GigabitEthernet0/0/1] port link-type trunk
[Router-GigabitEthernet0/0/1] port trunk allow-pass vlan 2 3
[Router-GigabitEthernet0/0/1] quit
[Router] interface vlanif 2
[Router-vlanif2] ip address 192.168.1.1 24 //配置VLANIF2的IP地址作为PC1的网关
[Router-vlanif2] quit
[Router] interface vlanif 3
[Router-vlanif3] ip address 192.168.2.1 24 //配置VLANIF3的IP地址作为PC2的网关
[Router-vlanif3] quit