使用vlan间路由及OSPF进行通信

拓扑结构:

使用vlan间路由及OSPF进行通信_第1张图片

效果:不同vlan的设备可以相互进行通信,且都可以对服务器进行访问,对路由器可以进行ssh登录

将路由器与交换机的端口设置为trunk模式:

Swicth0

创建vlan 

vlan 10,20,30

interface GigabitEthernet0/1

switchport mode trunk

将所属端口所属的vlan划分好:

interface FastEthernet0/3

switchport access vlan 10

switchport mode access

interface FastEthernet0/4

switchport access vlan 20

switchport mode access

interface FastEthernet0/5

switchport access vlan 30

switchport mode access

switch1

创建vlan 

vlan 30,40,50

将路由器与交换机的端口设置为trunk模式:

interface GigabitEthernet0/2

switchport mode trunk

将所属端口所属的vlan划分好:

interface FastEthernet0/3

switchport access vlan 30

switchport mode access

interface FastEthernet0/4

switchport access vlan 40

switchport mode access

interface FastEthernet0/5

switchport access vlan 50

switchport mode access

路由器R1:

开启端口GigabitEthernet0/1和端口GigabitEthernet0/2作为子接口的载体

interface GigabitEthernet0/1.10

encapsulation dot1Q 10

ip address 192.168.1.1 255.255.255.0

interface GigabitEthernet0/1.20

encapsulation dot1Q 20

ip address 192.168.2.1 255.255.255.0

interface GigabitEthernet0/1.30

encapsulation dot1Q 30

ip address 192.168.3.1 255.255.255.0

interface GigabitEthernet0/2.30

encapsulation dot1Q 40

ip address 192.168.4.1 255.255.255.0

interface GigabitEthernet0/2.50

encapsulation dot1Q 50

ip address 192.168.5.1 255.255.255.0

interface GigabitEthernet0/2.60

encapsulation dot1Q 60

ip address 192.168.6.1 255.255.255.0

为了各网段间可以进行通信,使用OSPF路由进行通告:

router ospf 1

router-id 1.1.1.1

log-adjacency-changes

network 192.168.1.0 0.0.0.255 area 0

network 192.168.2.0 0.0.0.255 area 0

network 192.168.3.0 0.0.0.255 area 0

network 192.168.4.0 0.0.0.255 area 0

network 192.168.5.0 0.0.0.255 area 0

network 192.168.10.0 0.0.0.255 area 0

network 192.168.11.0 0.0.0.255 area 0

network 192.168.12.0 0.0.0.255 area 0

default-information originate

配置ssh远程登陆:

创建用来登陆的账户:

username zj password 0 123

ip domain-name zj.com

crypto key generate rsa

1024

line vty 0 4

login local

transport input ssh

配置完毕,进行测试:

使用vlan间路由及OSPF进行通信_第2张图片

效果达成!

你可能感兴趣的:(Cisco,网络实验,智能路由器,网络)