静态路由默认路由配置

题目:搭建如图所示网络后进行下列配置,实现网络互通:
1、对R1-R4、S1-S3进行基本配置,包括:banner信息、空闲一段时间后不重回
初始界面、控制台消息不打断输入、禁用DNS查询、console密码、enable密码、
telnet登录密码;
2、PC的IP地址配置如图所示,PC4和PC5需要DHCP自动获取IP地址,PC1
属于VLAN2,PC2属于VLAN3;
3、通过R1配置单臂路由实现VLAN2和VLAN3的跨VLAN通信。R1配置默
认路由(缺省路由);
4、R2-R4运行OSPF协议生成路由表。
配置完成后,从任意PC出发应该能够ping通网络中的所有其他设备或PC,且
从任意PC均能远程登录管理任意网络设备,请在配置完成后自行检查。

这里是配置参考:
R1:
banner motd ^CUnauthorized access is prohibited!^C
service password-encryption
enable secret cisco
enable password cisco
line console 0
exec-timeout 0 0
logging synchronous
Password 7 0133E350
line vty 0 4
password cisco
login
ip dhcp excluded-address 192.168.2.1 192.168.2.10
ip dhcp excluded-address 192.168.3.1 192.168.3.10
ip dhcp pool vlan2
network 192.168.2.0 255.255.255.0
default-router 192.168.2.1
ip dhcp pool vlan3
network 192.168.3.0 255.255.255.0
default-router 192.168.3.1
interface vlan2
ip address 192.168.2.1 255.255.255.0
interface vlan3
ip address 192.168.3.1 255.255.255.0
interface gigabitethernet0/1.2
encapsulation dot1Q 2
interface gigabitethernet0/1.3
encapsulation dot1Q 3
ip route 0.0.0.0 0.0.0.0 192.168.1.2
R2、R3、R4:
enable secret cisco
enable password cisco
line console 0
exec-timeout 0 0
logging synchronous
Password 7 0133E350
line vty 0 4
password cisco
login
router ospf 1
network 192.168.1.0 0.0.0.255 area 0
交换机:
enable secret cisco
enable password cisco
line console 0
exec-timeout 0 0
logging synchronous
Password 7 0133E350
line vty 0 4
password cisco
login
interface vlan2
switchport mode access
interface vlan3
switchport mode access
interface range gigabitethernet0/1-10
switchport mode access
spanning-tree portfast
PC配置IP地址如图所示
继续的配置如下:
R1:

interface gigabitethernet0/0
ip address 192.168.1.1 255.255.255.0
no shutdown
router ospf 1
network 192.168.1.0 0.0.0.255 area 0
ip nat inside source list 10 interface gigabitethernet0/0 overload
access-list 10 permit 192.168.2.0 0.0.0.255
access-list 10 permit 192.168.3.0 0.0.0.255
R2:
interface gigabitethernet0/0
ip address 192.168.1.2 255.255.255.0
no shutdown
interface gigabitethernet0/1
ip address 192.168.4.1 255.255.255.0
no shutdown
router ospf 1
network 192.168.1.0 0.0.0.255 area 0
network 192.168.4.0 0.0.0.255 area 0
ip nat inside source list 10 interface gigabitethernet0/0 overload
access-list 10 permit 192.168.4.0 0.0.0.255
R3:
interface gigabitethernet0/0
ip address 192.168.1.3 255.255.255.0
no shutdown
interface gigabitethernet0/1
ip address 192.168.5.1 255.255.255.0
no shutdown
router ospf 1
network 192.168.1.0 0.0.0.255 area 0
network 192.168.5.0 0.0.0.255 area 0
ip nat inside source list 10 interface gigabitethernet0/0 overload
access-list 10 permit 192.168.5.0 0.0.0.255

R4:
interface gigabitethernet0/0
ip address dhcp
no shutdown
interface gigabitethernet0/1
ip address 192.168.4.2 255.255.255.0
no shutdown
router ospf 1
network 192.168.4.0 0.0.0.255 area 0
ip nat inside source list 10 interface gigabitethernet0/0 overload
access-list 10 permit 192.168.4.0 0.0.0.255
所有的路由器开启NAT、OSPF后,PC就可以互访了。