这一章我们主要介绍 |
在一系列IP相关的配置中,最基本和必需的是指定端口的IP地址,只有配了IP地址之后,才能使各个端口用IP协议与其它主机互相通信.
注意:以上的工作表并不是每一项都是必须的,请按照你的环境需要加以选择. |
一个IP标识了一个定位,使得IP数据包能被送出去.一些IP地址是预留的,它们不能作为主机,掩码或网络地址.表 1 列出了IP地址的范围,可以看出那些能被使用,那些是保留的.
包括以下内容:
| 类别 | 地址或范围 | 状态 | |
| A | 0.0.0.0 1.0.0.0 到 126.0.0.0 127.0.0.0 |
保 留 有 效 保 留 |
|
| B | 128.0.0.0 128.1.0.0 到 191.254.0.0 191.255.0.0 |
保 留 有 效 保 留 |
|
| C | 192.0.0.0 192.0.1.0 到 223.255.254.0 223.255.255.0 |
保 留 有 效 保 留 |
|
| D | 224.0.0.0 到 239.255.255.255 | 多 目 地 址 | |
| E | 240.0.0.0 到 255.255.255.254 255.255.255.255 |
保 留 广 播 |
一个端口有一个主IP地址. 指定一个端口的主IP 地址和网络掩码,在端口配置模式中完成:
| 功 能 | 命 令 |
| 给一个端口指定一个Primary IP地址 | ip address ip-address mask |
通过软件可以支持多个IP地址在每一个端口上.你可以无限制的指定多个secondary地址, Secondary IP地址可以用在各种环境下.
在端口配置模式下,指定多个地址:
| 功 能 | 命 令 |
| 给一个端口指定多个Secondary IP地址 | ip address ip-address mask secondary |
有关secondary IP 地址配置,请看"Creating a Network from Separates Subnets Example" 的举例说明.
你可能希望在串口(serial)或者是作IP 隧道技术的端口上,不用指定一个IP地址而能在上面跑IP协议.这可以由IP unnumbered Address来实现.限制如下:
在端口配置模式下,实现unnumbered配置:
| 功能 | 命令 |
| 在串口或作IP 隧道技术的端口上不指定额外的IP地址 | ip unnumbered type number |
在指定unnumbered 端口时,另外的那个端口不能也是unnumbered端口,并且这个端口必须是up的.(也就是说,该端口是工作正常的.)
有关unnumbered IP 地址配置,请看"Serial Interfaces Configuration Example" 的举例说明.
一个设备在IP环境中有两种地址,一个是本身地址,也就是链路层地址(即MAC 地址),另一个是网络层地址(即IP地址).
例如,以太网的设备互连,Cisco IOS软件首先要先确定48位的MAC地址.那么从IP地址到MAC地址的转换过程叫做地址解析(address resolution),而从MAC地址到IP地址的转换过程就叫反向地址解析(reverse address resolution).软件支持三种形式的地址解析: ARP,proxy ARP和Probe(类似ARP),反向地址解析: RARP.ARP,proxy ARP和RARP协议在RFC 826,1027和903分别作了定义,Probe是HP公司开发的用在IEEE-802.3网络中.
默认的,在端口上是标准的以太网ARP打包方式.你可以根据你的网络需要改成SNAP或HP Probe方式.
指定ARP打包方式,需完成:
| 功 能 | 命 令 |
| 在指定端口上选择三种ARP打包方式 | arp {arpa | probe |snap } |
Cisco IOS 软件保持一张主机名和相应地址的表,叫做 host name-to-address mapping.高层协议如 Telnet,都是用主机名来标识设备的.因此,路由器和其它网络设备也需要了解它们.
手工指定如下:
| 功 能 | 命 令 |
| 静态指定主机名和IP地对应 | ip host name address1 [adress2...address8] |
IP过滤表能够帮助控制网上包的传输.主要用在以下几个方面:
软件支持下面几种形式的IP过滤表:
在Global配置模式下,定义 标准的IP过滤表:
| 功 能 | 命 令 |
| 定义标准的IP过滤表 | access-list access-list-number {deny | permit } source [source-wildcard] |
| 用any来定义标准的IP过滤表 | access-list access-list-number {deny | permit } any |
标准的IP过滤表的表号 1-99.
在Global配置模式下,定义 扩展的IP过滤表:
| 功 能 | 命 令 |
| 定义扩展的IP过滤表 | access-list access-list-number {deny | permit } {protocol | protocol-keyword } {source source-wildcard | any } {destination destination-wildcard | any } [precedence precedence ] [tos tos] |
扩展的IP过滤表的表号
100-199.
协议关键字有icmp,igmp,tcp,udp.
在端口配置模式下, 把某个IP过滤表加到端口上:
| 功 能 | 命 令 |
| 把某个IP过滤表加到端口上 | ip access-list access-list-number {in | out } |
有关IP过滤表配置,请看"IP Access List Configuration Example" 的举例说明.
你可以配置IP通过X.25,SMDS,Frame Relay和DDR网络.详细内容请参阅广域网配置向导.
监控和维护你的网络,请完成以下工作:
清除缓存,表单和数据库
在 EXEC模式下:
| 功 能 | 命 令 |
| 清除IP ARP缓存和快速交换缓存 | clear arp-cache |
| 在主机和地址缓存中去掉一个或所有实体 | clear host {name | * } |
| 清除一个活动端口累计通过的包数 | clear ip accouting [checkpoint] |
| 在路由表中去掉一个或多个路由信息 | clear ip route {network [mask] | * } |
显示系统和网络的状态
在 EXEC模式下:
| 功 能 | 命 令 |
| 显示ARP表 | show arp |
| 显示名字缓存 | show hosts |
| 显示当前IP过滤表的内容 | show ip access-list [access-list-number | name ] |
| 显示当前活动端口累计通过的包数 | show ip accouting [checkpoint] |
| 显示IP ARP表 | show ip arp |
| 显示某一个端口状态 | show ip interface [type number ] |
| 显示目前的路由表 | show ip route [address [mask]|protocol ] |
| 测试网络是否通 | ping [protocol]{host |address} |
Creat a Network from Separates Subnets Example
在下面例子中,subnet 1和subnet 2被主干网分开.

Configuration for Router B
interface ethernet 2
ip address 192.5.10.1 255.255.255.0
ip address 131.108.3.1 255.255.255.0 secondary
Configuration for Router C
interface ethernet 1
ip address 192.5.10.2 255.255.255.0
ip address 131.108.3.2 255.255.255.0 secondary
Serial Interface Configuration Example
在下面的例子中,把Ethernet 0的地址赋予Serial 1. Serial 1是unnumbered.
interface ethernet 0
ip address 145.22.4.67 255.255.255.0
interface serial 1
ip unnumbered ethernet 0
IP Access List Configuration Example
该例表明在36.48.0.0这个网段上只允许B机(36.48.0.3)与A机通信,其它的36.0.0.0的网段如36.51.0.0可以与A机通信,而其它的如Internet用户均被过滤掉了.
Configuration for Router A
access-list 2 permit 36.48.0.3
access-list 2 deny 36.48.0.0 0.0.255.255
access-list 2 permit 36.0.0.0 0.255.255.255
!(Note:all other access denied)
interface ethernet 0
ip access-group 2 in
该例只允许在192.89.55.0这个网段上的主机访问路由器.
Configuration for Router
access-list12 permit 192.89.55.0
0.0.0.255
!
line vty 0 4
access-class 12 in
该例允许内部网的所有主机都能登录上Internet,并且A机作smtp-server,B机作Web Server,C机作域名服务器,FTP服务器和邮件服务器.

Configuration for Router
!Allow existing TCP connection
access-list 105 permit tcp any any established
!Allow ICMP messages
access-list 105 permit icmp any any
!Allow SMTP to one host
access-list 105 permit tcp any host 201.236.15.14 eq smtp
!Allow WWW to server (other services may be required)
access-list 105 permit tcp any host 201.222.11.5 eq www
!Allow DNS,FTP command and data,and smtpto another host
access-list 105 permit any host 201.222.11.7 eq domain
access-list 105 permit any host 201.222.11.7 eq 42
access-list 105 permit any host 201.222.11.7 eq ftp
access-list 105 permit any host 201.222.11.7 eq ftp-data
access-list 105 permit any host 201.222.11.7 eq smtp
!
interface serial 0
ip access-group 105 in
在例子中,目的地址是131.108.1.111.源地址是131.108.105.62.
Sandbox# ping
Protocol [ip]:
Target IP address: 131.108.1.111
Repeat count [5]:10
Datagram size [100]:64
Timeout in seconds [2]:
Extended commands [n]:
Type escape sequence to abort.Sending 5, 100-byte ICMP Echos to 131.108.1.111, timeout is
2 seconds:
!!!!!!!!!!
Success rate is 100 percent, round-trip min/avg/max = 4/4/4 ms