单臂路由:
交换机和路由器之间仅有一条物理链路连接。在交换机上,把连接到路由器的端口配置为Trunk口,并允许Vlan的帧通过。在路由器上设置子接口,在逻辑上把一条物理链路分成多条逻辑链路。
一般步骤:
交换机:
1.创建vlan。
2.与主机相连的端口设置为access并允许相关vlan通过,与路由器相连的端口设置为trunk并允许所有vlan通过。
路由器:
1.创建vlan。
2.进入子接口(x.1、x.2、……);
启用IEEE 802.1q封装;
配置ip地址;
启用arp broadcast.
静态路由:
静态路由是一种路由的方式,路由项由手动配置,而非动态决定。与动态路由不同,静态路由是固定的,不会改变,即使网络状况已经改变或是重新被组态。一般来说,静态路由是由网络管理员逐项加入路由表。
命令:ip route-static <ip address> <subnet mask> <nexthop-address>
ip route-static 目标网段 子网掩码 下一跳端口地址
单臂路由与静态路由实验:
拓扑图:
PC1:
PC2:
PC3:
首先配置单臂路由、各个路由器和交换机:
配置LSW1:
<Huawei>system-view
[Huawei]sysname LSW1
[LSW1]vlan batch 10 20
[LSW1]interface Ethernet 0/0/1
[LSW1-Ethernet0/0/1]port link-type access
[LSW1-Ethernet0/0/1]port default vlan 10
[LSW1-Ethernet0/0/1]quit
[LSW1]interface Ethernet 0/0/2
[LSW1-Ethernet0/0/2]port link-type access
[LSW1-Ethernet0/0/2]port default vlan 20
[LSW1-Ethernet0/0/2]quit
[LSW1]interface GigabitEthernet 0/0/1
[LSW1-GigabitEthernet0/0/1]port link-type trunk
[LSW1-GigabitEthernet0/0/1]port trunk allow-pass vlan 10 20
[LSW1-GigabitEthernet0/0/1]quit
[LSW1]quit
配置R1:
<Huawei>system-view
[Huawei]sysname R1
[R1]interface GigabitEthernet 0/0/1.1
[R1-GigabitEthernet0/0/1.1]dot1q termination vid 10
[R1-GigabitEthernet0/0/1.1]ip address 192.168.10.254 24
[R1-GigabitEthernet0/0/1.1]arp broadcast enable
[R1-GigabitEthernet0/0/1.1]quit
[R1]interface GigabitEthernet 0/0/1.2
[R1-GigabitEthernet0/0/1.2]dot1q termination vid 20
[R1-GigabitEthernet0/0/1.2]ip address 192.168.20.254 24
[R1-GigabitEthernet0/0/1.2]arp broadcast enable
[R1-GigabitEthernet0/0/1.2]quit
[R1]interface GigabitEthernet 0/0/0
[R1-GigabitEthernet0/0/0]ip address 10.0.1.1 30
[R1-GigabitEthernet0/0/0]quit
[R1]quit
[R1-GigabitEthernet0/0/1.1]qu
配置S2:
<Huawei>system-view
[Huawei]sysname R2
[R2]interface GigabitEthernet 0/0/0
[R2-GigabitEthernet0/0/0]ip address 10.0.1.2 30
[R2-GigabitEthernet0/0/0]quit
[R2]interface Ethernet 0/0/1
[R2-Ethernet0/0/1]ip address 10.0.2.1 30
[R2-Ethernet0/0/1]quit
[R2]quit
接下来配置静态路由:
配置LSW1:
<LSW1>system-view
[LSW1]ip route-static 10.0.1.0 30 192.168.10.254
[LSW1]ip route-static 10.0.1.0 30 192.168.20.254
[LSW1]ip route-static 10.0.2.0 30 192.168.10.254
[LSW1]ip route-static 10.0.2.0 30 192.168.20.254
[LSW1]quit
<LSW1>save
The current configuration will be written to the device.
Are you sure to continue?[Y/N]y
Info: Please input the file name ( *.cfg, *.zip ) [vrpcfg.zip]:
Apr 5 2022 12:40:56-08:00 LSW1 %%01CFM/4/SAVE(l)[0]:The user chose Y when decid
ing whether to save the configuration to the device.
Now saving the current configuration to the slot 0.
Save the configuration successfully.
配置R1:
<R1>system-view
[R1]ip route-static 10.0.2.0 30 10.0.1.2
[R1]quit
<R1>save
The current configuration will be written to the device.
Are you sure to continue?[Y/N]y
Info: Please input the file name ( *.cfg, *.zip ) [vrpcfg.zip]:
Now saving the current configuration to the slot 17.
Save the configuration successfully.
配置R2:
<R2>system-view
[R2]ip route-static 192.168.10.0 24 10.0.1.1
[R2]ip route-static 192.168.20.0 24 10.0.1.1
[R2]quit
<R2>save
The current configuration will be written to the device.
Are you sure to continue?[Y/N]y
Info: Please input the file name ( *.cfg, *.zip ) [vrpcfg.zip]:
Now saving the current configuration to the slot 17.
Save the configuration successfully.