四、总体设置 在router#特权命令状态下,可以用setup对路由器进行总体设计,利用这个设计过程可以省略手工设置的烦琐。但它还不能完全代替手工设置,一些特殊的设置还必须通过手工输入的方式完成。 进入设置对话过程后,路由器首先会显示一些提示信息: --- System Configuration Dialog ---
At any point you may enter a question mark '?' for help. Use ctrl-c to abort configuration dialog at any prompt. Default settings are in square brackets '[]'. 这是告诉你在设置对话过程中的任何地方都可以键入“?”得到系统的帮助,按ctrl-c可以退出设置过程,缺省设置将显示在‘[]'中。然后路由器会问是否进入设置对话: Would you like to enter the initial configuration dialog? [yes]: 如果按y或回车,路由器就会进入设置对话过程。首先你可以看到各端口当前的状况: First, would you like to see the current interface summary? [yes]:
Any interface listed with OK? value "NO" does not have a valid configuration InterfaceIP-AddressOK?MethodStatusProtocol Ethernet0unassignedNOunsetupup Serial0unassignedNOunsetupup …………………………… 然后,路由器就开始全局参数的设置: Configuring global parameters: 1.设置路由器名: Enter host name [Router]: 2.设置进入特权状态的密文(secret),此密文在设置以后不会以明文方式显示: The enable secret is a one-way cryptographic secret used instead of the enable password when it exists. Enter enable secret: cisco 3.设置进入特权状态的密码(password),此密码只在没有密文时起作用,并且在设置以后会以明文方式显示: The enable password is used when there is no enable secret and when using older software and some boot images. Enter enable password: pass 4.设置虚拟终端访问时的密码: Enter virtual terminal password: cisco 5.询问是否要设置路由器支持的各种网络协议: Configure SNMP Network Management? [yes]: Configure DECnet? [no]: Configure AppleTalk? [no]: Configure IPX? [no]: Configure IP? [yes]: Configure IGRP routing? [yes]: Configure RIP routing? [no]: ……… 6.如果配置的是拨号访问服务器,系统还会设置异步口的参数: Configure Async lines? [yes]: 1)设置线路的最高速度: Async line speed [9600]: 2)是否使用硬件流控: Configure for HW flow control? [yes]: 3)是否设置modem: Configure for modems? [yes/no]: yes 4)是否使用默认的modem命令: Configure for default chat script? [yes]: 5)是否设置异步口的PPP参数: Configure for Dial-in IP SLIP/PPP access? [no]: yes 6)是否使用动态IP地址: Configure for Dynamic IP addresses? [yes]: 7)是否使用缺省IP地址: Configure Default IP addresses? [no]: yes 8)是否使用TCP头压缩: Configure for TCP Header Compression? [yes]: 9)是否在异步口上使用路由表更新: Configure for routing updates on async links? [no]: y 10)是否设置异步口上的其它协议。 接下来,系统会对每个接口进行参数的设置。 1.Configuring interface Ethernet0: 1)是否使用此接口: Is this interface in use? [yes]: 2)是否设置此接口的IP参数: Configure IP on this interface? [yes]: 3)设置接口的IP地址: IP address for this interface: 192.168.162.2 4)设置接口的IP子网掩码: Number of bits in subnet field [0]: Class C network is 192.168.162.0, 0 subnet bits; mask is /24 在设置完所有接口的参数后,系统会把整个设置对话过程的结果显示出来: The following configuration command script was created:
hostname Router enable secret 5 $1$W5Oh$p6J7tIgRMBOIKVXVG53Uh1 enable password pass ………… 请注意在enable secret后面显示的是乱码,而enable password后面显示的是设置的内容。就是说,secret密码的优先级比较高,在两个密码都设了的情况下,secret密码起作用。 显示结束后,系统会问是否使用这个设置: Use this configuration? [yes/no]: yes 如果回答yes,系统就会把设置的结果存入路由器的NVRAM中,然后结束设置对话过程,使路由器开始正常的工作。
广域网协议设置
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认证,每个路由器通过名字来识别,可以防止未经授权的访问。 任务命令 设置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.交换机类型如下表,国内交换机一般为basic-net3。 按区域分关键字 交换机类型 Australia basic-ts013 Australian TS013 switches Europe basic-1tr6 German 1TR6 ISDN switches basic-nwnet3 Norway NET3 switches (phase 1) basic-net3 NET3 ISDN switches (UK, Denmark, and other nations); covers the Euro-ISDN E-DSS1 signalling system primary-net5 NET5 switches (UK and Europe) vn2 French VN2 ISDN switches vn3 French VN3 ISDN switches Japan ntt Japanese NTT ISDN switches primary-ntt Japanese ISDN PRI switches North America basic-5ess AT&T basic rate switches basic-dms100 NT DMS-100 basic rate switches basic-ni1 National ISDN-1 switches primary-4ess AT&T 4ESS switch type for the U.S. (ISDN PRI only) primary-5ess AT&T 5ESS switch type for the U.S. (ISDN PRI only) primary-dms100 NT DMS-100 switch type for the U.S. (ISDN PRI only) New Zealand basic-nznet3 New Zealand Net3 switches
3.ISDN实现DDR(dial-on-demand routing)实例: 设置如下: Router1: hostname router1 user router2 password cisco ! isdn switch-type basic-net3 ! interface bri 0 ip address 192.200.10.1 255.255.255.0 encapsulation ppp dialer map ip 192.200.10.2 name router2 572 dialer load-threshold 80 ppp multilink dialer-group 1 ppp authentication chap ! dialer-list 1 protocol ip permit ! Router2: hostname router2 user router1 password cisco ! isdn switch-type basic-net3 ! interface bri 0 ip address 192.200.10.2 255.255.255.0 encapsulation ppp dialer map ip 192.200.10.1 name router1 571 dialer load-threshold 80 ppp multilink dialer-group 1 ppp authentication chap ! dialer-list 1 protocol ip permit !
router1# 00:03:50: %LINK-3-UPDOWN: Interface BRI0:1, changed state to up 00:03:50: BRI0:1:PPP callback Callback server starting to router2 572 00:03:50: BRI0:1: disconnecting call 00:03:50: %LINK-3-UPDOWN: Interface BRI0:1, changed state to down 00:03:50: BRI0:1: disconnecting call 00:03:50: BRI0:1: disconnecting call 00:03:51: %LINK-3-UPDOWN: Interface BRI0:2, changed state to up 00:03:52: callback to router2 already started 00:03:52: BRI0:2: disconnecting call 00:03:52: %LINK-3-UPDOWN: Interface BRI0:2, changed state to down 00:03:52: BRI0:2: disconnecting call 00:03:52: BRI0:2: disconnecting call 00:04:05: : Callback timer expired 00:04:05: BRI0:beginning callback to router2 572 00:04:05: BRI0: Attempting to dial 572 00:04:05: Freeing callback to router2 572 00:04:05: %LINK-3-UPDOWN: Interface BRI0:1, changed state to up 00:04:05: BRI0:1: No callback negotiated 00:04:05: %LINK-3-UPDOWN: Interface Virtual-Access1, changed state to up 00:04:05: dialer Protocol up for Vi1 00:04:06: %LINEPROTO-5-UPDOWN: Line protocol on Interface BRI0:1, changed state to up 00:04:06: %LINEPROTO-5-UPDOWN: Line protocol on Interface Virtual-Access1, chang ed state to up 00:04:11: %ISDN-6-CONNECT: Interface BRI0:1 is now connected to 572 #router1
任务命令 指定接口通过PPP/IPCP地址协商获得IP地址ip address negotiated 指定内部和外部端口ip nat {inside | outside} 使用ppp/pap作认证ppp authentication pap callin 指定接口属于拨号组1dialer-group 1 定义拨号组1允许所有IP协议dialer-list 1 protocol ip permit 设定拨号,号码为2633dialer string 2633 设定登录263的用户名和口令ppp pap sent-username 263 password 263 设定默认路由ip route 0.0.0.0 0.0.0.0 bri 0 设定符合访问列表2的所有源地址被翻译为bri 0所拥有的地址ip nat inside source list 2 interface bri 0 overload 设定访问列表2,允许所有协议access-list 2 permit any
具体配置如下: hostname Cisco2503 ! isdn switch-type basic-net3 ! ip subnet-zero no ip domain-lookup ip routing ! interface Ethernet 0 ip address 10.0.0.1 255.255.255.0 ip nat inside no shutdown ! interface Serial 0 shutdown no description no ip address ! interface Serial 1 shutdown no description no ip address ! interface bri 0 ip address negotiated ip nat outside encapsulation ppp ppp authentication pap callin ppp multilink dialer-group 1 dialer hold-queue 10 dialer string 2633 dialer idle-timeout 120 ppp pap sent-username 263 password 263 no cdp enable no ip split-horizon no shutdown ! ip classless ! ! Static Routes ! ip route 0.0.0.0 0.0.0.0 bri 0 ! ! Access Control List 2 ! access-list 2 permit any ! dialer-list 1 protocol ip permit ! ! Dynamic NAT ! ip nat inside source list 2 interface bri 0 overload snmp-server community public ro ! line console 0 exec-timeout 0 0 ! line vty 0 4 ! end 路由协议配置
RIP协议 RIP(Routing information Protocol)是应用较早、使用较普遍的内部网关协议(Interior Gateway Protocol,简称IGP),适用于小型同类网络,是典型的距离向量(distance-vector)协议。文档见RFC1058、 RFC1723。
router rip version 2 network 192.200.10.0 network 192.20.10.0 ! 相关调试命令: show ip protocol show ip route IGRP协议 IGRP (Interior Gateway Routing Protocol)是一种动态距离向量路由协议,它由Cisco公司八十年代中期设计。使用组合用户配置尺度,包括延迟、带宽、可靠性和负载。
交换机间链路(ISL)协议 ISL(Interior Switching Link)协议用于实现交换机间的VLAN中继。它是一个信息包标记协议,在支持ISL接口上发送的帧由一个标准以太网帧及相关的VLAN信息组成。如下图所示,在支持ISL的接口上可以传送来自不同VLAN的数据。 虚拟局域网(VLAN)路由实例 3.1. 例一: 设备选用Catalyst5500交换机1台,安装WS-X5530-E3管理引擎,多块WS-X5225R及WS-X5302路由交换模块, WS-X5302被直接插入交换机,通过二个通道与系统背板上的VLAN 相连,从用户角度看认为它是1个1接口的模块,此接口支持ISL。在交换机内划有3个虚拟网,分别名为default、qbw、rgw,通过WS- X5302实现虚拟网间路由。 以下加重下横线部分,如set system name 5500C为需设置的命令。
设置如下: Catalyst 5500配置:
begin set password $1$FMFQ$HfZR5DUszVHIRhrz4h6V70 set enablepass $1$FMFQ$HfZR5DUszVHIRhrz4h6V70 set prompt Console> set length 24 default set logout 20 set banner motd ^C^C ! #system set system baud 9600 set system modem disable set system name 5500C set system location set system contact ! #ip set interface sc0 1 10.230.4.240 255.255.255.0 10.230.4.255
set interface sc0 up set interface sl0 0.0.0.0 0.0.0.0 set interface sl0 up set arp agingtime 1200 set ip redirect enable set ip unreachable enable set ip fragmentation enable set ip route 0.0.0.0 10.230.4.15 1 set ip alias default 0.0.0.0 ! #Command alias ! #vtp set vtp domain hne set vtp mode server set vtp v2 disable set vtp pruning disable set vtp pruneeligible 2-1000 clear vtp pruneeligible 1001-1005 set vlan 1 name default type ethernet mtu 1500 said 100001 state active set vlan 777 name rgw type ethernet mtu 1500 said 100777 state active set vlan 888 name qbw type ethernet mtu 1500 said 100888 state active set vlan 1002 name fddi-default type fddi mtu 1500 said 101002 state active set vlan 1004 name fddinet-default type fddinet mtu 1500 said 101004 state active bridge 0x0 stp ieee set vlan 1005 name trnet-default type trbrf mtu 1500 said 101005 state active bridge 0x0 stp ibm set vlan 1003 name token-ring-default type trcrf mtu 1500 said 101003 state active parent 0 ring 0x0 mode srb aremaxhop 7 stemaxhop 7 ! #set boot command set boot config-register 0x102 set boot system flash bootflash:cat5000-sup3.4-3-1a.bin ! #module 1 : 2-port 1000BaseLX Supervisor set module name 1 set vlan 1 1/1-2 set port enable 1/1-2 ! #module 2 : empty ! #module 3 : 24-port 10/100BaseTX Ethernet set module name 3 set module enable 3 set vlan 1 3/1-22 set vlan 777 3/23 set vlan 888 3/24 set trunk 3/1 on isl 1-1005 #module 4 empty ! #module 5 empty ! #module 6 : 1-port Route Switch set module name 6 set port level 6/1 normal set port trap 6/1 disable set port name 6/1 set cdp enable 6/1 set cdp interval 6/1 60 set trunk 6/1 on isl 1-1005 ! #module 7 : 24-port 10/100BaseTX Ethernet set module name 7 set module enable 7 set vlan 1 7/1-22 set vlan 888 7/23-24 set trunk 7/1 on isl 1-1005 set trunk 7/2 on isl 1-1005 ! #module 8 empty ! #module 9 empty ! #module 10 : 12-port 100BaseFX MM Ethernet set module name 10 set module enable 10 set vlan 1 10/1-12 set port channel 10/1-4 off set port channel 10/5-8 off set port channel 10/9-12 off set port channel 10/1-2 on set port channel 10/3-4 on set port channel 10/5-6 on set port channel 10/7-8 on set port channel 10/9-10 on set port channel 10/11-12 on #module 11 empty ! #module 12 empty ! #module 13 empty ! #switch port analyzer !set span 1 1/1 both inpkts disable set span disable ! #cam set cam agingtime 1-2,777,888,1003,1005 300 end 5500C> (enable)
WS-X5302路由模块设置:
Router#wri t Building configuration...
Current configuration: ! version 11.2 no service password-encryption no service udp-small-servers no service tcp-small-servers ! hostname Router ! enable secret 5 $1$w1kK$AJK69fGOD7BqKhKcSNBf6. ! ip subnet-zero ! interface Vlan1 ip address 10.230.2.56 255.255.255.0 ! interface Vlan777 ip address 10.230.3.56 255.255.255.0 ! interface Vlan888 ip address 10.230.4.56 255.255.255.0 ! no ip classless ! line con 0 line aux 0 line vty 0 4 password router login ! end Router#
Current configuration: ! version 11.2 no service password-encryption no service udp-small-servers no service tcp-small-servers ! hostname Router ! enable secret 5 $1$w1kK$AJK69fGOD7BqKhKcSNBf6. ! ip subnet-zero ! interface FastEthernet1/0 ! interface FastEthernet1/0.1 encapsulation isl 1 ip address 10.230.2.56 255.255.255.0 ! interface FastEthernet1/0.2 encapsulation isl 777 ip address 10.230.3.56 255.255.255.0 ! interface FastEthernet1/0.3 encapsulation isl 888 ip address 10.230.4.56 255.255.255.0 ! no ip classless ! line con 0 line aux 0 line vty 0 4 password router login ! end Router#
安全性管理
对路由器的安全性管理主要包括:建立口令以保护访问路由器的安全,使用正确的访问表以管理通过路由器的可接受数据流等。 1、口令管理 下面显示了设置控制从终端进行访问的口令的命令。 命令 操作效果 Line console 0 为控制台终端建立一个口令 Line vty 0 4 telnet连接建立一个口令 Enable-password 为特权exec模式建立一个口令 Enable-secret 使用MD5加密方法建立密码口令 Service password-encryption 保护口令,避免其通过idsplay命令将口令显示出来 2、报文过滤 cisco的防火墙功能主要是通过报文的过滤实现的。 它可以实现对多种数据流的控制,如限制流入、以及流出等。通过对访问列表的编写,我们可以实现对特定网络或主机的数据流限制。 Accsess-list 的编号有特定的范围:
<1-99> IP standard access list <100-199> IP extended access list <1100-1199> Extended 48-bit MAC address access list <200-299> Protocol type-code access list <700-799> 48-bit MAC address access list 例如我们可以定义如下的访问表来实现允许任何主机到主机160..10.2.101的报文: Accsess-list 101 permit ip any host 160.10.2.101 而下面的语句允许使用客户源端口(小于1024的端口留给服务器用)方式的主机发往160.10.2.100的udp报文通过,且报文的目的端口必须为dns端口(53)。其中gt为great than。 Accsess-list 101 permit udp any gt 1023 host 160.10.2.100 eq 53 建立好访问列表以后,要想让它进行报文过滤,必须将它应用到端口上。在进入要控制的端口后,用如下的命令应用此访问表: router(config-if)#ip access-group 101 in 其中的in表示对向里(针对此端口来说)的数据进行过滤。要注意的是,一个端口只能有一个向里和向外的列表,如果有几个,则只有第一个起作用。