网络地址 | 子网掩码 | 网关 |
---|---|---|
192.168.1.0 | 255.255.255.0 | 192.168.1.学号后两位(我的学号是1) |
192.168.2.0 | 255.255.255.0 | 192.168.1.学号后两位(我的学号是1) |
192.168.3.0 | 255.255.255.0 | 192.168.1.学号后两位(我的学号是1) |
192.168.4.0 | 255.255.255.0 | 192.168.1.学号后两位(我的学号是1) |
192.168.5.0 | 255.255.255.0 | 192.168.1.学号后两位(我的学号是1) |
192.168.6.0 | 255.255.255.0 | 192.168.1.学号后两位(我的学号是1) |
这里使用的动态获取(dhcp)地址,你也可以自己配置主机的ip等。自己配置的时候配置命令时要注意:下面的命令要去掉。
Router(config-subif)#ip dhcp pool test1
Router(dhcp-config)#network 10.0.0.0 255.0.0.0
Router(dhcp-config)#default-router 10.0.0.50
Switch0的配置:(要做一下vlan划分)
Switch>en
Switch#vlan database
Switch(vlan)#vlan 100
Switch(vlan)#vlan 200
Switch(vlan)#exit
Switch#conf t
Switch(config)#int range f0/1-f0/10
Switch(config-if-range)#switchport access vlan 100
Switch(config-if-range)#int range f0/11-f0/20
Switch(config-if-range)#switchport access vlan 200
Switch(config-if-range)#int f0/24
Switch(config-if)#switchport mode trunk
路由器的配置:
Router0:
Router>en
Router#conf t
Router(config)#int f0/0
Router(config-if)#no sh
Router(config-if)#int f0/0.1
Router(config-subif)#encap dot1q 100
Router(config-subif)#ip add 192.168.1.1 255.255.255.0
Router(config-subif)#ip dhcp pool test1
Router(dhcp-config)#network 192.168.1.0 255.255.255.0
Router(dhcp-config)#default-router 192.168.1.1
Router(dhcp-config)#int f0/0.2
Router(config-subif)#encap dot1q 200
Router(config-subif)#ip add 192.168.2.1 255.255.255.0
Router(config-subif)#ip dhcp pool test2
Router(dhcp-config)#network 192.168.2.0 255.255.255.0
Router(dhcp-config)#default-router 192.168.2.1
Router(dhcp-config)#int s1/0
Router(config-if)#no sh
Router(config-if)#clock rate 9600
Router(config-if)#ip add 192.168.3.1 255.255.255.0
配置完基本的,在你没有用rip协议或者时ospf协会之前可以看一下路由器所连的网段。
Router#sh ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is not set
C 192.168.1.0/24 is directly connected, FastEthernet0/0.1
C 192.168.2.0/24 is directly connected, FastEthernet0/0.2
C 192.168.3.0/24 is directly connected, Serial1/0
其他的路由器类似。
接着配置用rip协议或者是ospf协议:
这是用rip协议配置的:
Router(config)#router rip
Router(config-router)#network 192.168.1.0
Router(config-router)#network 192.168.2.0
Router(config-router)#network 192.168.3.0
或者用ospf协议配置:
Router(config)#router ospf 100
Router(config-router)#network 192.168.1.0 0.0.0.255 area 0
Router(config-router)#network 192.168.2.0 0.0.0.255 area 0
Router(config-router)#network 192.168.3.0 0.0.0.255 area 0
Router1:
Router>en
Router#conf t
Router(config)#int s1/0
Router(config-if)#no sh
Router(config-if)#ip add 192.168.3.2 255.255.255.0
Router(config-if)#int f0/0
Router(config-if)#no sh
Router(config-if)#ip add 192.168.4.1 255.255.255.0
Router(config-if)#ip dhcp pool test3
Router(dhcp-config)#network 192.168.4.0 255.255.255.0
Router(dhcp-config)#default-router 192.168.4.1
Router(config)#int s1/1
Router(config-if)#no sh
Router(config-if)#clock rate 9600
Router(config-if)#ip add 192.168.5.1 255.255.255.0
Router(dhcp-config)#route rip
Router(config-router)#network 192.168.3.0
Router(config-router)#network 192.168.4.0
Router(config-router)#network 192.168.5.0
Router(config-router)#end
Router(config)#router ospf 100
Router(config-router)#network 192.168.3.0 0.0.0.255 area 0
Router(config-router)#network 192.168.4.0 0.0.0.255 area 0
Router(config-router)#network 192.168.5.0 0.0.0.255 area 0
Router2:
Router>en
Router#conf t
Router(config)#int s1/0
Router(config-if)#no sh
Router(config-if)#ip add 192.168.5.2 255.255.255.0
Router(config-if)#int f0/0
Router(config-if)#no sh
Router(config-if)#ip add 192.168.6.1 255.255.255.0
Router(config-if)#ip dhcp pool test4
Router(dhcp-config)#network 192.168.6.0 255.255.255.0
Router(dhcp-config)#default-router 192.168.6.1
Router(dhcp-config)#router rip
Router(config-router)#network 192.168.5.0
Router(config-router)#network 192.168.6.0
Router(config-router)#end
Router(config)#router ospf 100
Router(config-router)#network 192.168.5.0 0.0.0.255 area 0
Router(config-router)#network 192.168.6.0 0.0.0.255 area 0