VLAN

 SW1配置

vlan batch 10 12 20
interface Vlanif10
 ip address 192.168.10.254 255.255.255.0
#
interface Vlanif12
 ip address 192.168.12.1 255.255.255.0
#
interface MEth0/0/1
#
interface GigabitEthernet0/0/1
 port link-type access
 port default vlan 10
#
interface GigabitEthernet0/0/2
 port link-type access
 port default vlan 20
#
interface GigabitEthernet0/0/3
 port link-type trunk
 port trunk allow-pass vlan 10 12 20
#

ospf 1 router-id 1.1.1.1
 area 0.0.0.0
  network 192.168.12.0 0.0.0.255
  network 192.168.10.0 0.0.0.255
#

SW2配置

vlan batch 10 12 20
interface Vlanif12
 ip address 192.168.12.2 255.255.255.0
#
interface Vlanif20
 ip address 192.168.20.254 255.255.255.0
#
interface MEth0/0/1
#
interface GigabitEthernet0/0/1
 port link-type access
 port default vlan 10
#
interface GigabitEthernet0/0/2
 port link-type access
 port default vlan 20
#
interface GigabitEthernet0/0/3
 port link-type trunk
 port trunk allow-pass vlan 10 12 20
#

ospf 1 router-id 2.2.2.2
 area 0.0.0.0
  network 192.168.20.0 0.0.0.255
  network 192.168.12.0 0.0.0.255

PC1测试

PC>ping 192.168.10.3

Ping 192.168.10.3: 32 data bytes, Press Ctrl_C to break
From 192.168.10.3: bytes=32 seq=1 ttl=128 time=47 ms
From 192.168.10.3: bytes=32 seq=2 ttl=128 time=62 ms
From 192.168.10.3: bytes=32 seq=3 ttl=128 time=47 ms
From 192.168.10.3: bytes=32 seq=4 ttl=128 time=62 ms
From 192.168.10.3: bytes=32 seq=5 ttl=128 time=47 ms

--- 192.168.10.3 ping statistics ---
  5 packet(s) transmitted
  5 packet(s) received
  0.00% packet loss
  round-trip min/avg/max = 47/53/62 ms

PC>ping 192.168.20.2

Ping 192.168.20.2: 32 data bytes, Press Ctrl_C to break
From 192.168.20.2: bytes=32 seq=1 ttl=126 time=125 ms
From 192.168.20.2: bytes=32 seq=2 ttl=126 time=78 ms
From 192.168.20.2: bytes=32 seq=3 ttl=126 time=62 ms
From 192.168.20.2: bytes=32 seq=4 ttl=126 time=78 ms
From 192.168.20.2: bytes=32 seq=5 ttl=126 time=78 ms

--- 192.168.20.2 ping statistics ---
  5 packet(s) transmitted
  5 packet(s) received
  0.00% packet loss
  round-trip min/avg/max = 62/84/125 ms

PC>ping 192.168.20.4

Ping 192.168.20.4: 32 data bytes, Press Ctrl_C to break
From 192.168.20.4: bytes=32 seq=1 ttl=126 time=78 ms
From 192.168.20.4: bytes=32 seq=2 ttl=126 time=63 ms
From 192.168.20.4: bytes=32 seq=3 ttl=126 time=47 ms
From 192.168.20.4: bytes=32 seq=4 ttl=126 time=63 ms
Request timeout!

--- 192.168.20.4 ping statistics ---
  5 packet(s) transmitted
  4 packet(s) received
  20.00% packet loss
  round-trip min/avg/max = 47/62/78 ms

PC>
原文地址:https://www.cnblogs.com/liujunjun/p/12923334.html