
1、回顾
2、静态路由配置
在路由器上添加路由条目语法:
Router(config)# ip route network mask {address | interface}
#network:目标网段 mask:目标网段的子网掩码 address:下一跳地址(下一个路由器的接口的IP地址) interface:发往下一跳路由器的本地接口举例:
Router(config)# ip route 192.168.2.0 255.255.255.0 192.168.7.2
Router(config)# ip route 192.168.2.0 255.255.255.0 f0/13、默认路由配置
在路由器上添加路由条目语法:
Router(config)# ip route 0.0.0.0 0.0.0.0 {address | interface}
#0.0.0.0 0.0.0.0 代表任意网络举例:
Router(config)# ip route 0.0.0.0 0.0.0.0 192.168.7.2
Router(config)# ip route 0.0.0.0 0.0.0.0 f0/14、查看路由条目
命令:
Router# show ip route
Codes: L - local, C - connected, S - static, 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
10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 10.10.10.0/24 is directly connected, FastEthernet0/1
L 10.10.10.10/32 is directly connected, FastEthernet0/1
172.16.0.0/24 is subnetted, 1 subnets
S 172.16.20.0/24 [1/0] via 10.10.10.100
192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.1.0/24 is directly connected, FastEthernet0/0
L 192.168.1.254/32 is directly connected, FastEthernet0/0
#(C代表直连路由,S代表静态路由)5、路由器上配置DHCP
命令:
Router(config)#ip dhcp pool woniu
#定义地址池
Router(dhcp-config)#network 192.168.1.0 255.255.255.0 #定义客户端网段
Router(dhcp-config)#default-router 192.168.1.254 #定义客户端网关
Router(dhcp-config)#dns-server 114.114.114.114 #定义客户端获取的DNS
Router(dhcp-config)#exit
Router(config)#ip dhcp excluded-address 192.168.1.1-192.168.1.10 #定义排除地址1、静态路由配置案例
实验拓扑

实验要求
实验步骤
实验脚本

//Router0
interface FastEthernet0/0
ip address 192.168.1.254 255.255.255.0
!
interface FastEthernet0/1
ip address 192.168.10.10 255.255.255.0
!
ip route 192.168.3.0 255.255.255.0 192.168.10.100
//Router1
interface FastEthernet0/0
ip address 192.168.3.254 255.255.255.0
!
interface FastEthernet0/1
ip address 192.168.10.100 255.255.255.0
!
ip route 192.168.1.0 255.255.255.0 192.168.10.10 2、默认路由配置案例
实验拓扑

实验要求
实验脚本

//Router0
interface FastEthernet0/0
ip address 192.168.1.254 255.255.255.0
!
interface FastEthernet0/1
ip address 192.168.2.254 255.255.255.0
!
interface Ethernet1/0
ip address 192.168.3.254 255.255.255.0
!
interface Ethernet1/1
ip address 20.10.10.10 255.255.255.0
!
ip route 0.0.0.0 0.0.0.0 20.10.10.100
//Router1
interface FastEthernet0/0
ip address 172.16.10.254 255.255.255.0
!
interface FastEthernet0/1
ip address 20.10.10.100 255.255.255.0
!
ip route 0.0.0.0 0.0.0.0 FastEthernet0/1 3、路由交换综合配置案例
实验拓扑
实验要求
实验脚本

//Switch0
interface Vlan1
ip address 192.168.1.100 255.255.255.0
!
ip default-gateway 192.168.1.254
!
line vty 0 4
login local
transport input telnet
//Router0
ip dhcp pool 1
network 192.168.1.0 255.255.255.0
default-router 192.168.1.254
dns-server 192.168.1.254
!
interface FastEthernet0/0
ip address 192.168.1.254 255.255.255.0
!
interface FastEthernet0/1
ip address 10.10.10.10 255.255.255.0
!
ip route 172.16.20.0 255.255.255.0 10.10.10.100
//Router1
hostname R1
!
enable secret 5 $1$mERr$/Q/mbs3O9oHsKR7rNG4e81
!
username pc0 secret 5 $1$mERr$/Q/mbs3O9oHsKR7rNG4e81
username pc1 secret 5 $1$mERr$H7PDxl7VYMqaD3id4jJVK/
!
ip domain-name pc0andpc1
!
interface FastEthernet0/0
ip address 172.16.20.254 255.255.255.0
!
interface FastEthernet0/1
ip address 10.10.10.100 255.255.255.0
!
ip route 0.0.0.0 0.0.0.0 10.10.10.10
!
line vty 0 4
login local
transport input ssh



配置脚本

//Router1
interface FastEthernet0/0
ip address 192.168.1.254 255.255.255.0
!
interface FastEthernet0/1
ip address 10.10.20.10 255.255.255.0
!
interface FastEthernet1/0
ip address 10.10.10.10 255.255.255.0
!
ip route 192.168.3.0 255.255.255.0 10.10.10.100
ip route 192.168.2.0 255.255.255.0 10.10.20.100
//Router0
interface FastEthernet0/0
ip address 10.10.20.100 255.255.255.0
!
interface FastEthernet0/1
ip address 10.10.30.10 255.255.255.0
!
ip route 192.168.1.0 255.255.255.0 10.10.20.10
ip route 192.168.2.0 255.255.255.0 10.10.30.100
!
//Router2
interface FastEthernet0/0
ip address 192.168.2.254 255.255.255.0
!
interface FastEthernet0/1
ip address 192.168.3.254 255.255.255.0
!
interface Ethernet1/0
ip address 10.10.10.100 255.255.255.0
!
interface Ethernet1/1
ip address 10.10.30.100 255.255.255.0
!
ip route 192.168.1.0 255.255.255.0 10.10.30.10