分了二个子网,起到了节约地址的作用。 4. 使用网络地址翻译(NAT)
NAT(Network Address Translation)起到将内部私有地址翻译成外部合法的全局地址的功能,它使得不具有合法IP地址的用户可以通过NAT访问到外部Internet.
当建立内部网的时候,建议使用以下地址组用于主机,这些地址是由Network Working Group(RFC 1918)保留用于私有网络地址分配的. ?; Class A:10.1.1.1 to 10.254.254.254 ?; Class B:172.16.1.1 to 172.31.254.254 ?; Class C:192.168.1.1 to 192.168.254.254 命令描述如下: 任务 命令
定义一个标准访问列表 access-list access-list-number permit source [source-wildcard]
定义一个全局地址池 ip nat pool name start-ip end-ip {netmask netmask | prefix-length prefix-length} [type rotary]
建立动态地址翻译 ip nat inside source {list {access-list-number | name} pool name [overload] | static local-ip global-ip} 指定内部和外部端口 ip nat {inside | outside} 如下图所示,
路由器的Ethernet 0端口为inside端口,即此端口连接内部网络,并且此端口所连接的网络应该被翻译,Serial 0端口为outside端口,其拥有合法IP地址(由NIC或服务提供商所分配的合法的IP地址),来自网络10.1.1.0/24的主机将从IP地址池 c2501中选择一个地址作为自己的合法地址,经由Serial 0口访问Internet。命令ip nat inside source list 2 pool c2501 overload中的参数overload,将允许多个内部地址使用相同的全局地址(一个合法IP地址,它是由NIC或服务提供商所分配的地址)。命令 ip nat pool c2501 202.96.38.1 202.96.38.62 netmask 255.255.255.192定义了全局地址的范围。 设置如下:
ip nat pool c2501 202.96.38.1 202.96.38.62 netmask 255.255.255.192 interface Ethernet 0
ip address 10.1.1.1 255.255.255.0 ip nat inside !
interface Serial 0
ip address 202.200.10.5 255.255.255.252 ip nat outside !
ip route 0.0.0.0 0.0.0.0 Serial 0 access-list 2 permit 10.0.0.0 0.0.0.255 ! Dynamic NAT !
ip nat inside source list 2 pool c2501 overload line console 0 exec-timeout 0 0 !
line vty 0 4 end
六、配置静态路由
通过配置静态路由,用户可以人为地指定对某一网络访问时所要经过的路径,在网络结构比较简单,且一般到达某一网络所经过的路径唯一的情况下采用静态路由。 任务 命令
建立静态路由 ip route prefix mask {address | interface} [distance] [tag tag] [permanent]
Prefix :所要到达的目的网络 mask :子网掩码
address :下一个跳的IP地址,即相邻路由器的端口地址。 interface :本地网络接口 distance :管理距离(可选) tag tag :tag值(可选)
permanent :指定此路由即使该端口关掉也不被移掉。
以下在Router1上设置了访问192.1.0.64/26这个网下一跳地址为192.200.10.6,即当有目的地址属于 192.1.0.64/26的网络范围的数据报,应将其路由到地址为192.200.10.6的相邻路由器。在Router3上设置了访问 192.1.0.128/26及192.200.10.4/30这二个网下一跳地址为192.1.0.65。由于在Router1上端口Serial 0地址为192.200.10.5,
192.200.10.4/30这个网属于直连的网,已经存在访问192.200.10.4/30的路径,所以不需要在Router1上添加静态路由。 Router1:
ip route 192.1.0.64 255.255.255.192 192.200.10.6 Router3:
ip route 192.1.0.128 255.255.255.192 192.1.0.65 ip route 192.200.10.4 255.255.255.252 192.1.0.65
同时由于路由器Router3除了与路由器Router2相连外,不再与其他路由器相连,所以也可以为它赋予一条默认路由以代替以上的二条静态路由, ip route 0.0.0.0 0.0.0.0 192.1.0.65
即只要没有在路由表里找到去特定目的地址的路径,则数据均被路由到地址为192.1.0.65的相邻路由器。
第二章:广域网协议设置 一、 HDLC
HDLC是CISCO路由器使用的缺省协议,一台新路由器在未指定封装协议时默认使用HDLC封装。 1. 有关命令 端口设置 任务 命令
设置HDLC封装 encapsulation hdlc 设置DCE端线路速度 clockrate speed 复位一个硬件接口 clear interface serial unit 显示接口状态 show interfaces serial [unit] 1 注:1.以下给出一个显示Cisco同步串口状态的例子. Router#show interface serial 0
Serial 0 is up, line protocol is up Hardware is MCI Serial
Internet address is 150.136.190.203, subnet mask is 255.255.255.0 MTU 1500 bytes, BW 1544 Kbit, DLY 20000 usec, rely 255/255, load 1/255 Encapsulation HDLC, loopback not set, keepalive set (10 sec) Last input 0:00:07, output 0:00:00, output hang never Output queue 0/40, 0 drops; input queue 0/75, 0 drops Five minute input rate 0 bits/sec, 0 packets/sec Five minute output rate 0 bits/sec, 0 packets/sec 16263 packets input, 1347238 bytes, 0 no buffer Received 13983 broadcasts, 0 runts, 0 giants
2 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 2 abort 22146 packets output, 2383680 bytes, 0 underruns 0 output errors, 0 collisions, 2 interface resets, 0 restarts 1 carrier transitions 2. 举例
设置如下: Router1: interface Serial0
ip address 192.200.10.1 255.255.255.0 clockrate 1000000 Router2: interface Serial0
ip address 192.200.10.2 255.255.255.0 !
3. 举例使用E1线路实现多个64K专线连接. 相关命令: 任务 命令
进入controller配置模式 controller {t1 | e1} number 选择帧类型 framing {crc4 | no-crc4}
选择line-code类型 linecode {ami | b8zs | hdb3}
建立逻辑通道组与时隙的映射 channel-group number timeslots range1 显示controllers接口状态 show controllers e1 [slot/port]2
注: 1. 当链路为T1时,channel-group编号为0-23, Timeslot范围1-24; 当链路为E1时, channel-group编号为0-30, Timeslot范围1-31.
2.使用show controllers e1观察controller状态,以下为帧类型为crc4时controllers正常的状态.
Router# show controllers e1 e1 0/0 is up.
Applique type is Channelized E1 - unbalanced
Framing is CRC4, Line Code is HDB3 No alarms detected. Data in current interval (725 seconds elapsed):
0 Line Code Violations, 0 Path Code Violations
0 Slip Secs, 0 Fr Loss Secs, 0 Line Err Secs, 0 Degraded Mins
0 Errored Secs, 0 Bursty Err Secs, 0 Severely Err Secs, 0 Unavail Secs Total Data (last 24 hours) 0 Line Code Violations, 0 Path Code Violations, 0 Slip Secs, 0 Fr Loss Secs, 0 Line Err Secs, 0 Degraded Mins,
0 Errored Secs, 0 Bursty Err Secs, 0 Severely Err Secs, 0 Unavail Secs
以下例子为E1连接3条64K专线, 帧类型为NO-CRC4,非平衡链路,路由器具体设置如下: shanxi#wri t
Building configuration... Current configuration: !
version 11.2
no service udp-small-servers no service tcp-small-servers !
hostname shanxi !
enable secret 5 $1$XN08$Ttr8nfLoP9.2RgZhcBzkk/ enable password shanxi ! !
ip subnet-zero !
controller E1 0 framing NO-CRC4
channel-group 0 timeslots 1 channel-group 1 timeslots 2 channel-group 2 timeslots 3 !
interface Ethernet0
ip address 133.118.40.1 255.255.0.0 media-type 10BaseT !
interface Ethernet1 no ip address shutdown !
interface Serial0:0
ip address 202.119.96.1 255.255.255.252 no ip mroute-cache !
interface Serial0:1
ip address 202.119.96.5 255.255.255.252 no ip mroute-cache
!
interface Serial0:2
ip address 202.119.96.9 255.255.255.252 no ip mroute-cache !
no ip classless
ip route 133.210.40.0 255.255.255.0 Serial0:0 ip route 133.210.41.0 255.255.255.0 Serial0:1 ip route 133.210.42.0 255.255.255.0 Serial0:2 !
line con 0 line aux 0 line vty 0 4 password shanxi login ! end 二、PPP
PPP(Point-to-Point Protocol)是SLIP(Serial Line IP protocol)的继承者,它提供了跨过同步和异步电路实现路由器到路由器(router-to-router)和主机到网络(host-to- network)的连接。
CHAP(Challenge Handshake Authentication Protocol)和PAP(Password
Authentication Protocol) (PAP)通常被用于在PPP封装的串行线路上提供安全性认证。使用CHAP和PAP认证,每个路由器通过名字来识别,可以防止未经授权的访问。 CHAP和PAP在RFC 1334上有详细的说明。 1. 有关命令 端口设置 任务 命令
设置PPP封装 encapsulation ppp1
设置认证方法 ppp authentication {chap | chap pap | pap chap | pap} [if-needed] [list-name | default] [callin]
指定口令 username name password secret 设置DCE端线路速度 clockrate speed
注:1、要使用CHAP/PAP必须使用PPP封装。在与非Cisco路由器连接时,一般采用PPP封装,其它厂家路由器一般不支持Cisco的HDLC封装协议。 2. 举例
路由器Router1和Router2的S0口均封装PPP协议,采用CHAP做认证,在Router1中应建立一个用户,以对端路由器主机名作为用户名,即用户名应为router2。同时在Router2中应建立一个用户,以对端路由器主机名作为用户名,即用户名应为router1。所建的这两用户的 password必须相同。 设置如下: Router1:
hostname router1
username router2 password xxx