终端直连三层网关设备进行通信
1、配置思路 :此场景配置简单,只需将连接 PC 的接口加入 VLAN,然后创建 VLANIF,并配置 IP 地址为对应用户的网关即可。
2、创建 vlan<SW1> system-view //进入系统模式
[SW1] vlan batch 10 20 //批量新建 vlan 10 和 20
[Huawei]dis vlan //查看建立vlan
3、创建 vlanif 三层接口作为 PC 电脑的网关 IP 地址
[SW1] interface Vlanif 10 //进入三层 vlanif10 接口
[SW1-Vlanif10] ip address 10.1.1.1 255.255.255.0
//此 IP 地址为 PC1 对应网关地址
[SW1-Vlanif10] quit //退出 vlanif2 接口
[SW1] interface Vlanif 20
[SW1-Vlanif20] ip address 10.1.2.1 255.255.255.0
//此 IP 地址为 PC2 对应网关地址[SW1-Vlanif20] quit
4、接口加入相应 vlan
[SW1] interface GigabitEthernet 0/0/1
[SW1-GigabitEthernet0/0/1] port link-type access //链路类型为 access
[SW1-GigabitEthernet0/0/1] port default vlan 10
//将 PC1 划分到 VLAN 10 中
[SW1-GigabitEthernet0/0/1] quit
[SW1] interface GigabitEthernet 0/0/2
[SW1-GigabitEthernet0/0/2] port link-type access //链路类型为 access
[SW1-GigabitEthernet0/0/2] port default vlan 20
//将 PC2 划分到 VLAN 10 中
[SW1-GigabitEthernet0/0/2] quit
[Huawei]quit
<Huawei>save
5、验证一下用PC2ping一下PC1的地址看看