计网中一个较为入门的实验,使用Cisco Packet Tracer工具配置静态路由,详细过程用csdn记录一下。
先建立简单的拓扑
   为方便配置IP和建立路由表,采用左零右一的方式配置。
配置两台PC的IP,以PC0为例
 单击PC0,进入Desktop中的IP Configuration模式。  设置,IP Address为10.0.0.1,子网掩码会自动生成(255.0.0.0,当然设置为255.255.255.0也没有问题,因为此处的网段仅采用了点分式的第一段(前八位)进行配置)。此处设置为10.0.0.1也是人为设置的,理论上设置为多少都可以,此处以10.0.0.1为例,故PC0与路由器Router0的gi0/0/0构成10.0.0.0网段。设置PC0的Default Gateway(默认网关)为10.0.0.2。  配置PC1的IP为20.0.0.1,此处略,与上同。
下面配置两个Router接口处的IP地址
先配置左边的Router0
单击Router0进入CLI命令行模式。  输入en,或enable,进入#模式,之后开始配置两侧接口的IP地址,先输入conf或configure,进入config模式(输入conf会自动补全,按TAB键可以手动补全)。  使用interface指令,先配置左侧与10网段相连的接口,即gi0/0/0。  由于左侧为10网段,因此ip地址的格式必须是10.0.0.X,段内前缀必须相同,后缀必须不同,由于PC0已配置其IP为10.0.0.1,故router0的gi0/0/0接口的IP只能配为10.0.0.1以外的IP,如10.0.0.2,此处配置为10.0.0.2。  使用ip addr 10.0.0.2 255.255.255.0配置这个接口的IP,ip addr后面接两个点分十进制地址,分别是IP地址和子网掩码。 最后输入no shut指令激活,gi0/0/0接口即配置成功,使用ex推出config-if。  可以看到,此时PC0和Router0之间就接通了。  转而配置Router0的右侧gi0/0/1接口,设置其ip为30.0.0.1。  使用文本框标记我们前面人为指定的网段。
再配置右边的Router1
同样先进入CLI模式,只不过Router1的gi0/0/0(左0右1,因此这个接口在30网段内,由于30.0.0.1已被占用,设置它为30.0.0.2,而右边在20网段内,设置为20.0.0.2(同样是因为20.0.0.1已被PC1占用)) 此处快速过一下: 
这样,整个拓扑中的IP地址就配好了。
但是,IP配好就结束了吗?这样就能工作了吗?

设置路由表
为了说明此时的拓扑仍然是“有缺陷的”,我们用PC0来ping一下PC1。  打开PC0的Command Prompt进入命令行模式。  ping一下PC1的IP地址。 可以看到,结果为unreachable,而10.0.0.2可以ping通,说明网段内可以正常通信,但网段外不可达。  原因在于当前的路由表为空,还需要配置一下路由表,即由目的网段和下一跳地址组成的二元组。
先配置Router0的路由表
进入CLI的config模式。  使用ip route命令更新路由表,第一个参数为目标网段,显然我们的目的地是20网段,第二个参数为子网掩码,没什么好说的,第三个参数为下一跳地址,即想要去目的网段,当前报文需要先到哪。应该先到Rounter1的左侧接口,即IP地址为30.0.0.2的目的地。
再配置Rounter1的路由表
只配置了Rounter0还没完,因为这样报文虽然能达到20.0.0.1,但是反馈信息从20.0.0.1出发,无法到达10.0.0.1,故Rounter1的路由表也需要配置。  
再ping,通了
 至此,静态路由的实验便完成了,这应该是计网中网络层最入门的实验。
|