发布时间: 2018-01-25 16:27:55
如图,两台交换机为三层交换机,实现路由器能访问所有pc,且所有pc能互访。
1. 创建vlan,交换机上配置接口类型,access和trunk
Sw1:
vlan batch 10 20 30 40 50
#
interface GigabitEthernet0/0/1
port link-type access
port default vlan 10
#
interface GigabitEthernet0/0/2
port link-type access
port default vlan 10
#
interface GigabitEthernet0/0/3
port link-type trunk
port trunk allow-pass vlan 2 to 4094
#
interface GigabitEthernet0/0/4
port link-type access
port default vlan 50
sw2:
vlan batch 10 20 30 40 50
#
interface GigabitEthernet0/0/1
port link-type access
port default vlan 20
#
interface GigabitEthernet0/0/2
port link-type access
port default vlan 30
#
interface GigabitEthernet0/0/3
port link-type trunk
port trunk allow-pass vlan 2 to 4094
2. Sw上配置vlanif地址,下发给相关接口
Sw1:
interface Vlanif10
ip address 10.1.1.254 255.255.255.0
#
interface Vlanif40
ip address 10.2.2.1 255.255.255.0
#
interface Vlanif50
ip address 10.2.3.1 255.255.255.0
sw2:
interface Vlanif20
ip address 10.1.2.254 255.255.255.0
#
interface Vlanif30
ip address 10.1.3.254 255.255.255.0
#
interface Vlanif40
ip address 10.2.2.2 255.255.255.0
3. 路由器上配置ip地址实现和sw1直连能通信
R1:
interface GigabitEthernet0/0/0
ip address 10.2.3.10 255.255.255.0
4. 在路由器和交换机上配置路由协议实现路由通信,这里采用ospf
R1:
ospf 1
area 0.0.0.0
network 10.2.3.0 0.0.0.255
sw1:
ospf 1
area 0.0.0.0
network 10.1.1.0 0.0.0.255
network 10.2.2.0 0.0.0.255
network 10.2.3.0 0.0.0.255
sw2:
ospf 1
area 0.0.0.0
network 10.2.2.0 0.0.0.255
network 10.1.2.0 0.0.0.255
network 10.1.3.0 0.0.0.255
5. 最终测试:
[r1]ping -c 1 10.1.1.1
PING 10.1.1.1: 56 data bytes, press CTRL_C to break
Reply from 10.1.1.1: bytes=56 Sequence=1 ttl=127 time=50 ms
--- 10.1.1.1 ping statistics ---
1 packet(s) transmitted
1 packet(s) received
0.00% packet loss
round-trip min/avg/max = 50/50/50 ms
[r1]ping -c 1 10.1.2.3
PING 10.1.2.3: 56 data bytes, press CTRL_C to break
Reply from 10.1.2.3: bytes=56 Sequence=1 ttl=126 time=70 ms
--- 10.1.2.3 ping statistics ---
1 packet(s) transmitted
1 packet(s) received
0.00% packet loss
round-trip min/avg/max = 70/70/70 ms
[r1]ping -c 1 10.1.3.4
PING 10.1.3.4: 56 data bytes, press CTRL_C to break
Reply from 10.1.3.4: bytes=56 Sequence=1 ttl=126 time=60 ms
--- 10.1.3.4 ping statistics ---
1 packet(s) transmitted
1 packet(s) received
0.00% packet loss
round-trip min/avg/max = 60/60/60 ms