發布時間: 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