交换机路由器配置

之前一直打算写博客,总是没有开好头,最近总算有了一个方向,于是决定把以前有的资料整理一下,一是形成习惯,二是做个备份。此次更新是第一次更新,内容包括计算机网络管理的基础内容。

交换机路由器配置,通过配置实现两边路由器到pc连通,同时,通过配置静态路由实现左边与右边区域互相通信。网络拓扑图如下:

交换机路由器配置_第1张图片

      pc0、pc2属于vlan1,pc1、pc3属于vlan2,首先通过基础配置,实现同一vlan间相互通信,再在三层交换机配置ip routing,实现vlan1和vlan2通信,再在三层交换机和路由器上配置路由表(ospf、rip、静态路由其中一种),实现pc到路由器的通信,右边区域同理,最后在R0和R1上配置静态路由,实现两个区域的通信。

代码:

##基础配置

#ms0

en
conf t
vlan 10
vlan 20
int vlan 10
ip add 192.168.10.1 255.255.255.0
int vlan 20
ip add 192.168.20.1 255.255.255.0
exit
vtp mode server
vtp domain abin
vtp password 123
int f0/1
switchport trunk encapsulation dot1q
swi mo tr
int f0/2
switchport trunk encapsulation dot1q
swi mo tr
exit
ip routing
int f0/3
no switchport
ip add 172.168.10.1 255.255.255.0
no shut
exit
router ospf 1
network 192.168.10.0 0.0.0.255 area 1
network 192.168.20.0 0.0.0.255 area 1
network 172.168.10.0 0.0.0.255 area 1
exit
ip route 0.0.0.0 0.0.0.0 172.168.10.2

#s0

en
conf t
vtp mode client
vtp domain abin
vtp password 123
int f0/1
sw mo ac
sw ac v 10
int f0/2
sw mo ac
sw ac v 20
int f0/3
sw mo tr

#s1

en
conf t
vtp mode client
vtp domain abin
vtp password 123
int f0/1
sw mo ac
sw ac v 10
int f0/2
sw mo ac
sw ac v 20
int f0/3
sw mo tr

#r0

en
conf t
int f0/0
ip add 172.168.10.2 255.255.255.0
no shut
int s0/0/0
ip add 10.1.1.1 255.255.255.0
no shut
exit
router ospf 1
network 172.168.10.0 0.0.0.255 area 1
exit
ip route 0.0.0.0 0.0.0.0 10.1.1.2

#ms1

en
conf t
vlan 30
vlan 40
int vlan 30
ip add 192.168.30.1 255.255.255.0
int vlan 40
ip add 192.168.40.1 255.255.255.0
exit
vtp mode server
vtp domain abin
vtp password 123
int f0/1
switchport trunk encapsulation dot1q
swi mo tr
int f0/2
switchport trunk encapsulation dot1q
swi mo tr
exit
ip routing
int f0/3
no switchport
ip add 172.168.20.1 255.255.255.0
no shut
exit
router ospf 1
network 192.168.30.0 0.0.0.255 area 1
network 192.168.40.0 0.0.0.255 area 1
network 172.168.20.0 0.0.0.255 area 1
exit
ip route 0.0.0.0 0.0.0.0 172.168.20.2

#s2

en
conf t
vtp mode client
vtp domain abin
vtp password 123
int f0/1
sw mo ac
sw ac v 30
int f0/2
sw mo ac
sw ac v 40
int f0/3
sw mo tr

#s3

en
conf t
vtp mode client
vtp domain abin
vtp password 123
int f0/1
sw mo ac
sw ac v 30
int f0/2
sw mo ac
sw ac v 40
int f0/3
sw mo tr

#r1

en
conf t
int f0/0
ip add 172.168.20.2 255.255.255.0
no shut
int s0/0/0
ip add 10.1.1.2 255.255.255.0
no shut
exit
router ospf 1
network 172.168.20.0 0.0.0.255 area 1
exit
ip route 0.0.0.0 0.0.0.0 10.1.1.1

结果检测:

使用ping命令通过pc0向pc6发送icmp数据包:

 

你可能感兴趣的:(交换机路由器配置)