将交换机的接口属性更改时,例如将access------>>trunk或者trunk------>>access,必须重置接口的默认配置。
[SW1]interface gi0/0/1
[SW1-GigabitEthernet0/0/1]undo port link-type access #取消accesss无效
Error:Too many parameters found at ‘^’ position.
[SW1]clear configuration interface gi0/0/1 #重置端口
[SW1]interface gi0/0/1
[SW1-GigabitEthernet0/0/1]dis this
interface GigabitEthernet0/0/1
shutdown
return
[SW1-GigabitEthernet0/0/1]undo shutdown #启用端口
通过接入层交换机配置VLAN接口,核心层交换机配置Trunk链路,实现不同VLAN的互相通信或者向外网通信。
system-view #进入系统视图
[Huawei]undo info-center enable #关闭消息中心
Info: Information center is disabled.
[Huawei]sysname SW1 #把交换机重命名为SW1
[SW1]vlan 10 #创建VLAN 10
[SW1-vlan10]quit
[SW1]vlan 20 #创建VLAN 20
[SW1-vlan20]quit
[SW1]vlan batch 10 20 #或者同时可以创建VLAN10和VLAN20
[SW1]vlan batch 30 to 40 #批量创建多个VLAN, VLAN30至VLAN 40,思科无此命令
[SW1]interface gi0/0/1
[SW1-GigabitEthernet0/0/1]port link-type access #接口的类型配置为access ,专门接PC主机
[SW1-GigabitEthernet0/0/1]port default vlan 10 #将接口gi0/0/1划分到VLAN10里面。
[SW1]interface gi0/0/2
[SW1-GigabitEthernet0/0/2]port link-type access
[SW1-GigabitEthernet0/0/2]port default vlan 10 #将接口gi0/0/2划分到VLAN10里面
[SW1]interface gi0/0/3
[SW1-GigabitEthernet0/0/3]port link-type access
[SW1-GigabitEthernet0/0/3]port default vlan 20 #将接口gi0/0/3划分到VLAN20里面
[SW3]vlan batch 10 20
[SW3-GigabitEthernet0/0/1]port link-type trunk #配置接口为trunk
[SW3-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[SW3-GigabitEthernet0/0/2]port link-type trunk
[SW3-GigabitEthernet0/0/2]port trunk allow-pass vlan all
[SW3]interface vlan 10
[SW3-Vlanif10]ip add 192.168.1.254 24
[SW3-Vlanif10]quit
[SW3]int vlan 20
[SW3-Vlanif20]ip add 192.168.20.254 24
[SW3-Vlanif20]quit
display ip interface brief
[SW1]interface gi0/0/4
[SW1-GigabitEthernet0/0/4]port link-type trunk
[SW1-GigabitEthernet0/0/4]port trunk allow-pass vlan all
[SW1-GigabitEthernet0/0/4]undo shutdown
Info: Interface GigabitEthernet0/0/4 is not shutdown.
[SW1-GigabitEthernet0/0/4]dis this
interface GigabitEthernet0/0/4
port link-type trunk
port trunk allow-pass vlan 2 to 4094
return
[SW2]interface gi0/0/1
[SW2-GigabitEthernet0/0/1]port link-type trunk
[SW2-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[SW2-GigabitEthernet0/0/1]dis this
interface GigabitEthernet0/0/1
port link-type trunk
port trunk allow-pass vlan 2 to 4094
return
单臂路由是通过一条主干Trunk线路创建模拟多个子接口绑定传输VLAN传输数据,节省连接线路成本。
system-view #进入系统视图
[Huawei]sysname SW1 #把交换机重命名为SW1
[SW1]undo info-center enable #关闭消息中心
[SW1]vlan batch 10 20 #批量创建VLAN10和VLAN20
[SW1]interface gi0/0/1
[SW1-GigabitEthernet0/0/1]port link-type access #接口的类型配置为access ,专门接PC主机
[SW1-GigabitEthernet0/0/1]port default vlan 10 #将接口gi0/0/1划分到VLAN10里面。
[SW1-GigabitEthernet0/0/1]dis this
interface GigabitEthernet0/0/1
port link-type access
port default vlan 10
return
[SW1]interface gi0/0/2
[SW1-GigabitEthernet0/0/2]port link-type access
[SW1-GigabitEthernet0/0/2]port default vlan 20
[SW1-GigabitEthernet0/0/2]dis this
interface GigabitEthernet0/0/2
port link-type access
port default vlan 20
return
[SW1]interface gi0/0/3
[SW1-GigabitEthernet0/0/3]port link-type trunk
[SW1-GigabitEthernet0/0/3]port trunk allow-pass vlan all
[SW1-GigabitEthernet0/0/3]dis this
interface GigabitEthernet0/0/3
port link-type trunk
port trunk allow-pass vlan 2 to 4094
return
[R1]interface e0/0/0.10 #进入逻辑子接口
[R1-Ethernet0/0/0.10]ip add 192.168.10.1 24 #配置IP地址
[R1-Ethernet0/0/0.10]dot1q termination vid 10 #指定对VLAN10 进行绑定
[R1-Ethernet0/0/0.10]arp broadcast enable #开启arp广播转发数据
[R1-Ethernet0/0/0.10]display this
interface Ethernet0/0/0.10
dot1q termination vid 10
ip address 192.168.10.1 255.255.255.0
arp broadcast enable