在交换机上创建vlan
[sw1]vlan 2
[sw1-vlan2]q
[sw1]vlan 3
[sw1-vlan3]q
将交换机上各个接口划分到对应vlan中
[sw1]interface Eth0/0/1
[sw1-Ethernet0/0/1]port link-type access 先修改接口模式为接入
[sw1-Ethernet0/0/1]port default vlan 2
批量接口划分
[sw1]port-group group-member Ethernet 0/0/3 to Ethernet 0/0/4
[sw1-port-group]port link-type access
[sw1-port-group]port default vlan 3
建立trunk干道
[sw1]interface Eth0/0/5
[sw1-Ethernet0/0/5]port link-type trunk 先将接口修改为trunk模式
[sw1-Ethernet0/0/5]port trunk allow-pass vlan 2 to 3
单臂路由--路由器子接口
[route]interface g0/0/0.1
[route-GigabitEthernet0/0/0.1]dot1q termination vid 2
[route-GigabitEthernet0/0/0.1]ip address 192.168.1.254 24
[route-GigabitEthernet0/0/0.1]arp broadcast enable
[route-GigabitEthernet0/0/0.1]q
[route]interface GigabitEthernet 0/0/0.2 创建子接口2号
[route-GigabitEthernet0/0/0.2]dot1q termination vid 3 定义其管理和识别vlan id
[route-GigabitEthernet0/0/0.2]ip address 192.168.2.254 24 配置ip地址
[route-GigabitEthernet0/0/0.2]arp broadcast enable
建立DHCP自动获取IP,给PC配置IP
[r1]dhcp enable 设备必须先开启DHCP服务
[r1]ip pool a 创建池塘
[r1-ip-pool-a]network 192.168.1.0 mask 255.255.255.0 池塘范围
[r1-ip-pool-a]gateway-list 192.168.1.1 网关ip地址
[r1-ip-pool-a]dns-list 192.168.2.20 114.114.114.114 DNS 服务器地址
[r1]interface Eth0/0/0 必须到路由器进行ip地址下发的接口上再开启一次服务
[r1-Ethernet0/0/0]dhcp select global
最后ipconfig