2010年9月15日星期三

在Linux上配置XeLaTeX的中文环境

参考链接: http://forum.ubuntu.org.cn/viewtopic.php?f=35&t=168940

我的环境:

  • Ubuntu 10.04 LTS
  • XeLaTeX
配置zhspacing宏包的步骤:
  1. 在这里 -> http://code.google.com/p/zhspacing/ 下载zhspacing宏包,解压到/var/lib/texmf/tex/zhspacing目录下(貌似需要root权限);
  2. 修改zhfont.sty中“SimSun”附近若干行(貌似也需要root权限),使符合你电脑中的字体(以免编译时无法找到字体,可以使用fc-list命令查看当前字体列表);
  3. 有人说这时需要在这个目录下以root身份执行一次mktexlsr,我并没有执行它,后面的步骤没有出问题;在使用xecjk宏包时我特意没有执行这个命令,依然没有出问题。
  4. 在Texmaker的“选项”菜单的“配置Texmaker”中设置自定义快速构建命令为“xelatex -interaction=nonstopmode %.tex|okular %.pdf“,请确认选中了“用户自定义命令”;
  5. 使用以下文本测试(我去除了原帖中涉及字体的几行,避免因为没有安装这几个字体而编译失败),使用F1键可以自动编译并查看:
\documentclass[11pt,a4paper]{article}
%----------
\usepackage{fontspec,xltxtra,xunicode} % 这里使用 xetex 相应的宏包
\usepackage{zhfont} % 这里调用 zhfont.sty
\zhspacing
%----------
\begin{document}
Cowards die many times before their deaths.\\
懦夫在未死之前,已身历多次死亡的恐怖了。
\end{document}
配置xecjk宏包的步骤(太简单了):

  1. 在这里 -> http://forum.ubuntu.org.cn/viewtopic.php?f=35&t=168940&start=65 下载xecjk,将解压后tex目录里的xelatex目录里的xecjk目录移动到/var/lib/texmf/tex/xecjk;
-- 或者 --
  1. sudo apt-get install xecjk
  2. 在Texmaker的“选项”菜单的“配置Texmaker”中设置自定义快速构建命令为“xelatex -interaction=nonstopmode %.tex|okular %.pdf“,请确认选中了“用户自定义命令”(之前做过这一步的可以不做的);
  3. 使用以下文本测试(记得改成你有的字体,字体列表可以用fc-list命令查看):
\documentclass[11pt,a4paper]{article}
%----------
\usepackage[slantfont,boldfont]{xeCJK}
\setCJKmainfont{微软雅黑} % 设置缺省中文字体
\setCJKmonofont{SimSun} % 设置代码或数学公式出现的中文字体
%----------
\begin{document}
Cowards die many times before their deaths.\\
懦夫在未死之前,已身历多次死亡的恐怖了。
\end{document}

    配置交换机上的VLAN

    西安交通大学实验报告

    课程:网络技术实验
    完成时间:2010年5月21日
    实验名称:配置交换机上的VLAN

    实验内容

        使用Boson NetSim软件模拟出两台交换机的环境,并配置VLAN。

        使用Boson NetSim Designer软件设计一个含有两个交换机、一个PC机和一个路由器的网络环境,如图所示:


        网络规划如下:
        网络为192.168.0.0/24。
        Router1:192.168.0.1。
        PC1:192.168.0.2。
    在两台1900系列交换机上配置VLAN

        将Router1连接到交换机Switch1上的端口以及PC1连接到交换机Switch2上的端口设置到VLAN2(#后为注释,下同):
    #conf t
    Enter configuration commands, one per line.  End with CNTL/Z.
    (config)#vlan 2 name vlan2
    (config)#interface e0/1
    (config-if)#vlan-membership static 2
    (config-if)#exit
    (config)#exit
    #show vlan

    VLAN Name             Status     Ports
    --------------------------------------
    1    default          Enabled    2-12, AUI, A, B
    2    vlan2            Enabled    1
    1002 fddi-default     Suspended
    1003 token-ring-defau Suspended
    1004 fddinet-default  Suspended
    1005 trnet-default    Suspended
    --------------------------------------

    VLAN Type           SAID   MTU    Parent RingNo BridgeNo Stp  Trans1 Trans2
    --------------------------------------------------------------
    1    Ethernet       100001 1500   0      0      0        Unkn 1002   1003
    2    Ethernet       100002 1500   0      1      1        Unkn 0      0
    1002 FDDI           101002 1500   0      0      0        Unkn 1      1003
    1003 Token-Ring     101003 1500   1005   1      0        Unkn 1      1002
    1004 FDDI-Net       101004 1500   0      0      1        IEEE 0      0
    1005 Token-Ring-Net 101005 1500   0      0      1        IEEE 0      0
    ---------------------------------------------------------------
        此时PC1无法ping通Router1,因为两台交换机没有联合子网信息。然后在两台交换机直接相连的端口上设置Trunk:
    (config)#interface fe0/26
    (config-if)#trunk on
    (config-if)#^Z
    %SYS-5-CONFIG_I: Configured from console by console

    #show trunk a
    DISL state: on, Trunking: on, Encapsulation type: ISL
        然后PC1与Router1联通。

    在两台2950系列交换机上配置VLAN
        将Router1连接到交换机Switch1上的端口以及PC1连接到交换机Switch2上的端口设置到VLAN2:

    Switch#vlan database
    Switch(vlan)#vlan 2 name vlan2
    VLAN 2 added:
        Name:vlan2
    Switch(vlan)#exit
    APPLY completed.
    Exiting....
    Switch#conf t
    Enter configuration commands, one per line.  End with CNTL/Z.
    Switch(config)#interface fe0/1
    Switch(config-if)#switch mode access
    Switch(config-if)#switchport access vlan 2
    Switch(config-if)#^Z
    %SYS-5-CONFIG_I: Configured from console by console

    Switch#show vlan

    VLAN Name                             Status    Ports
    ---- -------------------------------- --------- -----
    1    default                          active    Fa0/2, Fa0/3, Fa0/4, Fa0/5
                                                    Fa0/6, Fa0/7, Fa0/8, Fa0/9
                                                    Fa0/10, Fa0/11, Fa0/12
    2    vlan2                            active    Gi0/-11
    1002 fddi-default                     active
    1003 token-ring-default               active
    1004 fddinet-default                  active
    1005 trnet-default                    active

    VLAN Type  SAID       MTU   Parent RingNo BrdgNo Stp  Brdg Trans1 T2
    ---- ----- ---------- ----- ------ ------ ------ ---- ---- ------
    1    enet  100001     1500  -      -      -      -    -    0      0
    2    enet  100002     1500  -      -      -      -    -    0      0
    1002 fddi  101002     1500  -      -      -      -    -    0      0
    1003 tr    101003     1500  -      -      -      -    -    0      0
    1004 fdnet 101004     1500  -      -      -      ieee -    0      0
    1005 trnet 101005     1500  -      -      -      ibm  -    0      0
        此时PC1无法ping通Router1,因为两台交换机没有联合子网信息。然后在两台交换机直接相连的端口上设置Trunk:
    Switch#conf t
    Enter configuration commands, one per line.  End with CNTL/Z.
    Switch(config)#interface fe0/2
    Switch(config-if)#switchport mode trunk
    Switch(config-if)#^Z
    %SYS-5-CONFIG_I: Configured from console by console

    Switch#show interface fe0/2 switchport
    Name: Fa0/2
    Switchport:     Enabled
    Administrative mode: trunk
    Operational mode: trunk
    Administrative Trunking Encapsulation: dot1q
    Negotiation of Trunking: On
    Access Mode VLAN: 1 (default)
    Trunking Native Mode VLAN: 1 (default)
    Trunking VLANs Enabled: ALL
    Pruning VLANs Enabled: 2-1001

    Protected: false

    Voice vlan: none (Inactive)
    Appliance trust: none
        然后PC1与Router1联通。

    (完)

    配置交换机

    西安交通大学实验报告

    课程:网络技术实验
    完成时间:2010年5月20日
    实验名称:配置交换机

    实验内容

        使用Boson NetSim软件模拟出交换机的环境,并配置VLAN。

        使用Boson NetSim Designer软件设计一个含有一个交换机和两个PC机的网络环境,两个PC机器分别连接到交换机(1912)上,交换机连接到2611型路由器上(使用Ethernet接口),如图所示:



        网络规划如下:
        网络为192.168.0.0/24。
        Router1:192.168.0.1。
        PC1:192.168.0.2。
        PC2:192.168.0.3。
        给交换机命名:
    >enable
    #conf t
    Enter configuration commands, one per line.  End with CNTL/Z.
    (config)#hostname switch
    switch(config)#end
    switch#exit
        分别在PC1、PC2、Router1上配置IP地址,并确认网络联通。

    配置VLAN

        将PC2划分到VLAN2子网中:
    switch#conf t
    Enter configuration commands, one per line.  End with CNTL/Z.
    switch(config)#vlan 2 name vlan2
    switch(config)#interface e0/2
    switch(config-if)#vlan-membership static 2
    switch(config-if)#exit
    switch(config)#exit
    switch#show vlan-membership
       Port  VLAN    Membership Type     Port  VLAN    Membership Type
       -----------------------------     -----------------------------
       1        1       Static
       2        2       Static
       3        1       Static
        此时在PC1上无法ping通PC2:
    C:>ping 192.168.0.3
    Pinging 192.168.0.3 with 32 bytes of data:

    Request timed out.

    (完)

    IGRP&EIGRP协议的配置

    西安交通大学实验报告

    课程:网络技术实验
    完成时间:2010年5月17日
    实验名称:IGRP&EIGRP协议的配置

    实验内容

        使用Boson NetSim软件模拟出路由器的环境,并分别运用IGRP协议和EIGRP协议配置动态路由。
        IGRP(Interior Gateway Routing Protocol, 内部网关路由协议)是八十年代中期由Cisco公司开发的路由协议, Cisco创建IGRP的主要目的是为AS内的路由提供一种健壮的协议。IGRP是一种动态距离向量型路由协议,距离向量路由协议要求每个路由器以规则的时间间隔向其相邻的路由器发送其路由表的全部或部分。随着路由信息在网络上扩散, 路由器就可以计算到所有节点的距离。默认情况下,每90秒IGRP会广播给同网内的所有路由器进行路由更新,如果3个周期(270秒)后没有任何回报,即不能进行路由,则在7个周期后(630秒)后,Cisco IOS 会自行清除路由。

        Enhanced IGRP是Cisco公司开发的IGRP的增强的版本,它属于动态内部网关路由协议,仍然使用矢量-距离算法,但它的实现比IGRP已经有很大改进,其收敛特性和操作效率比IGRP有显著的提高。由于没有区域的概念,EIGRP适用于网络规模相对较小的网络,这也是矢量-距离路由算法(RIP等协议使用的算法)的局限。
        使用Boson NetSim Designer软件设计一个含有三个路由器和两个PC机的网络环境,两个PC机器分别连接到两个路由器(1750)上,这两个1750型路由器连接到同一个2611型路由器上(使用串口)。

        网络规划如下:
        PC1与Router1相连,网络为192.168.0.0/24,PC1:192.168.0.2,Router1:192.168.0.1。
        PC2与Router2相连,网络为192.168.1.0/24,PC2:192.168.1.2,Router2:192.168.1.1。
        Router1与Router3相连,网络为192.168.2.0/24,Router1:192.168.2.1,Router3:192.168.2.3。
        Router2与Router3相连,网络为192.168.3.0/24,Router2:192.168.3.2,Router3:192.168.3.3。

    配置IGRP协议

        在三个路由器上分别配置IGRP协议:

        router igrp AS: AS为自治域(autonomous system)的编号,在三个路由器上保持相同。本例中均取0。
        network network_address:network_address为网络地址,每个路由器上需执行两次,将所在的两个网络加入IGRP。

        配置完成后检查Router3的路由表:
    Router#show ip route

    C    192.168.2.0 is directly connected, Serial0
    C    192.168.3.0 is directly connected, Serial1
    I    192.168.1.0 [100/651] via 192.168.3.1, 00:08:27, Serial1
    I    192.168.0.0 [100/651] via 192.168.2.1, 00:01:15, Serial0
        可以看到已经连接成功。PC1也可以连接到PC2:
    C:>ping 192.168.1.2

    Ping statistics for 192.168.1.2:     Packets: Sent = 5, Received = 5, Lost = 0 (0% loss)
    配置EIGRP协议

        类似上例,将命令中的igrp修改为eigrp重新配置,然后在Router3上检查路由表:
    Router#show ip route

    C    192.168.2.0 is directly connected, Serial0
    C    192.168.3.0 is directly connected, Serial1
    D    192.168.0.0 [90/1628160] via 192.168.2.1, 00:00:12, Serial0
    D    192.168.1.0 [90/1628160] via 192.168.3.1, 00:00:12, Serial1

    (完)

    配置网络地址转换

    西安交通大学实验报告

    课程:网络技术实验
    完成时间:2010年5月19日
    实验名称:配置网络地址转换

    实验内容

        使用Boson NetSim软件模拟出路由器的环境,并配置网络地址转换。

    (#后为注释,下同)

    # 静态NAT
    # 打开Router2的telnet服务:
    enable
    conf t
    line vty 0 4
    login
    password xq
    exit

    # 在Router1上通过telnet服务访问Router2:
    telnet 192.16.10.1
    enable

    # Router3
    conf t
    ip nat inside source static 192.200.10.1 202.117.35.1
    interface s0
    ip nat inside
    exit
    interface s1
    ip nat outside
    exit

    # Router1
    show interfaces # 查看IP地址
    telnet 192.16.10.1 # Router2
    show users # 使用了外网IP
    # Router3
    show ip nat translations # 查看转换表

    (完)
    笔记:
    # 静态NAT
    # 打开Router2的telnet服务:
    enable
    conf t
    line vty 0 4
    login
    password xq
    exit

    # 在Router1上通过telnet服务访问Router2:
    telnet 192.16.10.1
    enable

    # Router3
    conf t
    ip nat inside source static 192.200.10.1 202.117.35.1
    interface s0
    ip nat inside
    exit
    interface s1
    ip nat outside
    exit

    # Router1
    show interfaces # 查看IP地址
    telnet 192.16.10.1 # Router2
    show users # 使用了外网IP

    # Router3
    show ip nat translations # 查看转换表


    # 动态NAT
    # Router3
    ip nat pool pool1 202.117.58.50 202.117.58.100 netmask 255.255.255.0
    ip nat inside source list 1 pool pool1
    access-list 1 permit 192.200.10.0 0.0.0.255
    interface s0
    ip nat inside
    exit
    interface s1
    ip nat outside
    exit

    # Router1
    telnet 192.16.10.1 # Router2
    show users

    在路由器上配置ACL笔记

    # 配置标准ACL

    # Router2
    conf t
    access-list 1 deny host 192.20.10.87 
    access-list 1 permit any
    interface s0
    ip access-group 1 in
    exit
    # 从PC1上无法ping通PC2
    # 从Router1上可以ping通PC2
    # PC1修改IP之后可以ping通
    # 去除ACL配置:
    no access-list 1
    interface s0
    no ip access-group 1 in

    # 配置可扩展ACL
    # 开启Router3上的telnet服务
    conf t
    access-list 101 permit tcp 192.200.10.0 0.0.0.255 any eq telnet
    access-list 102 permit ip 192.16.10.0 0.0.0.255 any log # 记录日志
    interface s0
    ip access-group 101 in
    exit
    interface s1
    ip access-group 102 in
    exit
    # Router1无法ping通Router3,只能使用telnet协议

    # 开启虚拟终端
    line vty 0 4
    login
    password xq # telnet登陆的密码

    # telnet连接后在Router1上执行
    disconnect 1 # 断开连接
    # Ctrl+Shift+6 x 回车 可以退出

    IGRP&EIGRP协议的配置

    西安交通大学实验报告

    课程:网络技术实验
    完成时间:2010年5月17日
    实验名称:IGRP&EIGRP协议的配置

    实验内容

        使用Boson NetSim软件模拟出路由器的环境,并分别运用IGRP协议和EIGRP协议配置动态路由。
        IGRP(Interior Gateway Routing Protocol, 内部网关路由协议)是八十年代中期由Cisco公司开发的路由协议, Cisco创建IGRP的主要目的是为AS内的路由提供一种健壮的协议。IGRP是一种动态距离向量型路由协议,距离向量路由协议要求每个路由器以规则的时间间隔向其相邻的路由器发送其路由表的全部或部分。随着路由信息在网络上扩散, 路由器就可以计算到所有节点的距离。默认情况下,每90秒IGRP会广播给同网内的所有路由器进行路由更新,如果3个周期(270秒)后没有任何回报,即不能进行路由,则在7个周期后(630秒)后,Cisco IOS 会自行清除路由。

        Enhanced IGRP是Cisco公司开发的IGRP的增强的版本,它属于动态内部网关路由协议,仍然使用矢量-距离算法,但它的实现比IGRP已经有很大改进,其收敛特性和操作效率比IGRP有显著的提高。由于没有区域的概念,EIGRP适用于网络规模相对较小的网络,这也是矢量-距离路由算法(RIP等协议使用的算法)的局限。
        使用Boson NetSim Designer软件设计一个含有三个路由器和两个PC机的网络环境,两个PC机器分别连接到两个路由器(1750)上,这两个1750型路由器连接到同一个2611型路由器上(使用串口)。

        网络规划如下:
        PC1与Router1相连,网络为192.168.0.0/24,PC1:192.168.0.2,Router1:192.168.0.1。
        PC2与Router2相连,网络为192.168.1.0/24,PC2:192.168.1.2,Router2:192.168.1.1。
        Router1与Router3相连,网络为192.168.2.0/24,Router1:192.168.2.1,Router3:192.168.2.3。
        Router2与Router3相连,网络为192.168.3.0/24,Router2:192.168.3.2,Router3:192.168.3.3。

    配置IGRP协议

        在三个路由器上分别配置IGRP协议:

        router igrp AS: AS为自治域(autonomous system)的编号,在三个路由器上保持相同。本例中均取0。
        network network_address:network_address为网络地址,每个路由器上需执行两次,将所在的两个网络加入IGRP。

        配置完成后检查Router3的路由表:
    Router#show ip route

    C    192.168.2.0 is directly connected, Serial0
    C    192.168.3.0 is directly connected, Serial1
    I    192.168.1.0 [100/651] via 192.168.3.1, 00:08:27, Serial1
    I    192.168.0.0 [100/651] via 192.168.2.1, 00:01:15, Serial0
        可以看到已经连接成功。PC1也可以连接到PC2:
    C:>ping 192.168.1.2

    Ping statistics for 192.168.1.2:     Packets: Sent = 5, Received = 5, Lost = 0 (0% loss)
    配置EIGRP协议

        类似上例,将命令中的igrp修改为eigrp重新配置,然后在Router3上检查路由表:
    Router#show ip route

    C    192.168.2.0 is directly connected, Serial0
    C    192.168.3.0 is directly connected, Serial1
    D    192.168.0.0 [90/1628160] via 192.168.2.1, 00:00:12, Serial0
    D    192.168.1.0 [90/1628160] via 192.168.3.1, 00:00:12, Serial1

    (完)

    RIP&OSPF协议的配置

    西安交通大学实验报告

    课程:网络技术实验
    完成时间:2010年5月14日
    实验名称:RIP&OSPF协议的配置

    实验内容

        使用Boson NetSim软件模拟出路由器的环境,并分别运用RIP协议和OSPF协议配置动态路由。

        RIP(Routing information Protocol)是应用较早、使用较普遍的内部网关协议(Interior Gateway Protocol,简称IGP),适用于小型同类网络,是典型的距离向量(distance-vector)协议。RIP通过广播UDP报文来交换路由信息,每30秒发送一次路由信息更新。RIP使用跳跃计数(hop count)作为尺度来衡量路由距离,跳跃计数是一个包到达目标所必须经过的路由器的数目。

        OSPF(Open Shortest Path First)是一个内部网关协议(Interior Gateway Protocol,简称IGP),用于在单一自治系统(autonomous system,AS)内决策路由。与RIP相对,OSPF是链路状态路有协议,而RIP是距离向量路由协议。OSPF通过路由器之间通告网络接口的状态来建立链路状态数据库,生成最短路径树(最小生成树),每个OSPF路由器使用这些最短路径构造路由表。

        使用Boson NetSim Designer软件设计一个含有三个路由器和两个PC机的网络环境,两个PC机器分别连接到两个路由器(1750)上,这两个1750型路由器连接到同一个2611型路由器上(使用串口)。

        网络规划如下:
        PC1与Router1相连,网络为192.168.0.0/24,PC1:192.168.0.2,Router1:192.168.0.1。
        PC2与Router2相连,网络为192.168.1.0/24,PC2:192.168.1.2,Router2:192.168.1.1。
        Router1与Router3相连,网络为192.168.2.0/24,Router1:192.168.2.1,Router3:192.168.2.3。
        Router2与Router3相连,网络为192.168.3.0/24,Router2:192.168.3.2,Router3:192.168.3.3。

    RIP协议的配置

        在Router1上配置RIP协议:
    Router#conf t
    Enter configuration commands, one per line.  End with CNTL/Z.
    Router(config)#router rip
    Router(config-router)#network 192.168.0.0
    Router(config-router)#network 192.168.2.0
    Router(config-router)#exit
        在Router2上配置RIP协议:
    Router#conf t
    Enter configuration commands, one per line.  End with CNTL/Z.
    Router(config)#router rip
    Router(config-router)#network 192.168.1.0
    Router(config-router)#network 192.168.3.0
    Router(config-router)#exit
        在Router3上配置RIP协议:
    Router#conf t
    Enter configuration commands, one per line.  End with CNTL/Z.
    Router(config)#router rip
    Router(config-router)#network 192.168.2.0
    Router(config-router)#network 192.168.3.0
    Router(config-router)#exit
        此时检查Router3的路由表:
    Router#show ip route

    C    192.168.2.0 is directly connected, Serial0
    C    192.168.3.0 is directly connected, Serial1
    R    192.168.0.0 [120/1] via 192.168.2.1, 00:04:27, Serial0
    R    192.168.1.0 [120/1] via 192.168.3.2, 00:09:12, Serial1

        可以看出三个路由器已经通过RIP协议自动配置好了转发路由表。PC1(192.168.0.2)也可以成功连接到PC2(192.168.1.1):
    C:>tracert 192.168.1.2

    "Type escape sequence to abort."
    Tracing the route to 192.168.1.2

     1 192.168.0.1 0 msec 16 msec 0 msec
     2 192.168.2.3 20 msec 16 msec 16 msec
     3 192.168.3.2 20 msec 16 msec 16 msec
     4 192.168.1.2 20 msec 16 msec *

    OSPF协议的配置

        首先分别在三个路由器上执行以下指令以取消RIP协议的配置并清空路由表:
    conf t
    no router rip
    exit
    clear ip route *
        在Router1上执行以下指令(#后为注释,下同):
    Router#conf t
    Enter configuration commands, one per line.  End with CNTL/Z.
    Router(config)#router ospf 1
    Router(config-router)#network 192.168.0.0 0.0.0.255 area 1
    Router(config-router)#network 192.168.2.0 0.0.0.255 area 1
        分别在Router2和Router3上执行类似指令。

        router ospf process-id:指定使用OSPF协议,process是1~65535范围内的算法进程号。
        network address wildcard-mask area area-id:address和wildcard-mask共同指定一个网络。wildcard-mask是子网掩码的反码(本例中为0.0.0.255)。

        此时在Router3上检查路由表,可以看到网络已经连通:
    Router#show ip route

    C    192.168.2.0 is directly connected, Serial0
    C    192.168.3.0 is directly connected, Serial1
    O    192.168.0.0 [110/64] via 192.168.2.1, 00:00:16, Serial0
    O    192.168.1.0 [110/64] via 192.168.3.2, 00:00:11, Serial1
        在PC1上也可以成功连接到PC2上:
    C:>tracert 192.168.1.2


    "Type escape sequence to abort."
    Tracing the route to 192.168.1.2

     1 192.168.0.1 0 msec 16 msec 0 msec
     2 192.168.2.3 20 msec 16 msec 16 msec
     3 192.168.3.1 20 msec 16 msec 16 msec
     4 192.168.1.2 20 msec 16 msec *
    (完)

    笔记:

    配置动态路由
    # PC1
    winipcfg
    # 192.20.10.87 255.255.255.0 192.20.10.1

    # PC2
    winipcfg
    # 192.168.0.87/24 192.168.0.1

    # Router1
    enable
    conf t
    interface e0
    ip address 192.20.10.1 255.255.255.0
    no shutdown
    exit
    interface s0
    ip address 192.200.10.1 255.255.255.0
    exit
    exit

    show controllers
    conf t
    interface s0
    clock rate 64000
    exit

    # Router2
    ......

    # Router3


    # Router1
    conf t
    router rip
    network 192.20.10.0 
    network 192.200.10.0
    exit

    # Router2
    conf t
    router rip
    network 192.168.0.0
    network 192.16.10.0
    exit

    # Router3
    conf t
    router rip
    network 192.200.10.0
    network 192.16.10.0
    exit
    exit

    # Router1



    # 开始配置OSPF协议

    # Router1,2,3
    conf t
    no router rip
    exit

    # router1,2,3 清除路由表
    clear ip route *

    # Router1
    conf t
    router ospf 100
    network 192.20.10.0 0.0.0.255 area 1 # 使用子网掩码的反码
    network 192.200.10.0 0.0.0.255 area 1
    exit

    # Router2
    conf t
    router ospf 200
    network 192.16.10.0 0.0.0.255 area 2
    network 192.168.0.0 0.0.0.255 area 2
    exit

    # Router3
    conf t
    router ospf 300
    network 192.200.10.0 0.0.0.255 area 1
    network 192.16.0.0 0.0.0.255 area 2
    exit

    # Router2
    show ip route

    # 配置完成

    静态路由的配置

    西安交通大学实验报告

    课程:网络技术实验
    完成时间:2010年5月13日
    实验名称:静态路由的配置

    实验内容

        使用Boson NetSim软件模拟出路由器的环境,并配置静态路由。

        使用Boson NetSim Designer软件设计一个含有三个路由器和两个PC机的网络环境,两个PC机器分别连接到两个路由器(1750)上,这两个1750型路由器连接到同一个2611型路由器上(使用串口)。如图:


        在PC1上使用ipconfig指令配置IP:
    C:>ipconfig /ip 192.168.0.2 255.255.255.0
    C:>ipconfig /dg 192.168.0.1
    C:>ipconfig
      Boson BOSS 5.0 IP Configuration
         Ethernet adapter Local Area Connection:
            IP Address. . . . . . . . . . . . : 192.168.0.2
            Subnet Mask . . . . . . . . . . . : 255.255.255.0
            Default Gateway . . . . . . . . . : 192.168.0.1
        在PC2上使用winipcfg进行类似配置:


        分别配置三个路由器的IP地址(#后为注释,下同):
    # Router1:
    Router>enable
    Router#conf t
    Enter configuration commands, one per line.  End with CNTL/Z.
    Router(config)#interface e0
    Router(config-if)#ip address 192.168.0.1 255.255.255.0
    Router(config-if)#no shutdown
    %LINK-3-UPDOWN: Interface Ethernet0, changed state to up
    Router(config-if)#exit
    Router(config)#interface s0
    Router(config-if)#ip address 192.168.2.1 255.255.255.0
    Router(config-if)#no shutdown
    %LINK-3-UPDOWN: Interface Serial0, changed state to up
    Router(config-if)#exit

    # Router2:

    Router>enable
    Router#conf t
    Enter configuration commands, one per line.  End with CNTL/Z.
    Router(config)#interface e0
    Router(config-if)#ip address 192.168.1.1 255.255.255.0
    Router(config-if)#no shutdown
    %LINK-3-UPDOWN: Interface Ethernet0, changed state to up
    Router(config-if)#exit
    Router(config)#interface s0
    Router(config-if)#ip address 192.168.3.2 255.255.255.0
    Router(config-if)#no shutdown
    %LINK-3-UPDOWN: Interface Serial0, changed state to up
    Router(config-if)#exit

    # Router3:
    Router>enable
    Router#conf t
    Enter configuration commands, one per line.  End with CNTL/Z.
    Router(config)#interface s0
    Router(config-if)#ip address 192.168.2.3 255.255.255.0
    Router(config-if)#no shutdown
    %LINK-3-UPDOWN: Interface Serial0, changed state to up
    Router(config-if)#exit
    Router(config)#interface s1
    %LINK-3-UPDOWN: Interface Serial0, changed state to down
    %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0, changed state to down
    Router(config-if)#ip address 192.168.3.3 255.255.255.0
    Router(config-if)#no shutdown
    %LINK-3-UPDOWN: Interface Serial1, changed state to up
    Router(config-if)#exit
    Router(config)#exit
    %LINK-3-UPDOWN: Interface Serial1, changed state to down
    %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial1, changed state to down
        使用show controllers指令查看各个路由是DCE还是DTE:
    # Router3:
    Router#show controllers

    HD unit 0, idb = 0x1AE828, driver structure at 0x1B4BA0
    buffer size 1524  HD unit 0,V.35 DCE cable
    cpb = 0x7, eda = 0x58DC, cda = 0x58F0
    RX ring with 16 entries at 0x4075800

    HD unit 0, idb = 0x1AE828, driver structure at 0x1B4BA0
    buffer size 1524  HD unit 0,V.35 DCE cable
    cpb = 0x7, eda = 0x58DC, cda = 0x58F0
    RX ring with 16 entries at 0x4075800
    ……

    # Router1:
    Router#show controllers

    HD unit 0, idb = 0x1AE828, driver structure at 0x1B4BA0
    buffer size 1524  HD unit 0,V.35 DTE cable
    cpb = 0x7, eda = 0x58DC, cda = 0x58F0
    RX ring with 16 entries at 0x4075800

    # Router 2:
    Router>show controllers

    HD unit 0, idb = 0x1AE828, driver structure at 0x1B4BA0
    buffer size 1524  HD unit 0,V.35 DTE cable
    cpb = 0x7, eda = 0x58DC, cda = 0x58F0
    RX ring with 16 entries at 0x4075800
        在Router3上配置时钟频率:
    Router#conf t
    Enter configuration commands, one per line.  End with CNTL/Z.
    Router(config)#interface s0
    Router(config-if)#clock rate 64000
    %LINK-3-UPDOWN: Interface Serial0, changed state to up
    %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0, changed state to up
    Router(config-if)#exit
    Router(config)#interface s1
    Router(config-if)#clock rate 64000
    Router(config-if)#exit
    %LINK-3-UPDOWN: Interface Serial1, changed state to up
    %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial1, changed state to up
        在3个路由器上分别配置转发规则:
    # Router1
    Router(config)#ip route 192.168.1.0 255.255.255.0 192.168.2.3
    Router(config)#ip route 192.168.3.0 255.255.255.0 192.168.2.3

    # Router2
    Router(config)#ip route 192.168.0.0 255.255.255.0 192.168.3.3
    Router(config)#ip route 192.168.2.0 255.255.255.0 192.168.3.3

    # Router3
    Router(config)#ip route 192.168.0.0 255.255.255.0 192.168.2.1
    Router(config)#ip route 192.168.1.0 255.255.255.0 192.168.3.2
        检查配置,在PC1上尝试traceroute到PC2:
    C:>tracert 192.168.1.2

    Tracing the route to 192.168.1.2

     1 192.168.0.1 0 msec 16 msec 0 msec
     2 192.168.2.3 20 msec 16 msec 16 msec
     3 192.168.3.2 20 msec 16 msec 16 msec
     4 192.168.1.2 20 msec 16 msec *
    (完)

    笔记:


    Router1, Router2: 1750
    Serial / Ethernet

    Router3: 2611
    2 Serials

    # PC1
    ipconfig /ip 192.20.10.87 255.255.255.0
    ipconfig /dg 192.20.10.1 # 配置网关

    # PC2
    winipcfg # 出现GUI界面
    # 192.168.0.87 255.255.255.0 192.168.0.1

    # Router1
    enable
    conf t
    interface e0
    ip address 192.20.10.1 255.255.255.0
    no shutdown
    exit
    interface s0
    ip address 192.200.10.1 255.255.255.0
    no shutdown
    exit

    # Router2
    enable
    conf t
    interface e0
    ip address 192.168.0.1 255.255.255.0
    no shutdown
    exit
    interface s0
    ip address 192.16.10.1 255.255.255.0
    no shutdown
    exit


    # Router3
    enable
    conf t
    interface s0
    ip address 192.200.10.2 255.255.255.0
    no shutdown
    exit
    interface s1
    ip address 192.16.10.2 255.255.255.0
    no shutdown
    exit

    show controllers # 检查是DCE还是DTE(DTE)

    # Router1
    show controllers

    conf t
    interface s0
    clock rate 64000

    # Router2
    show controllers
    conf t
    interface s0
    clock rate 64000

    # 开始配置路由协议(config提示符下)
    # Router1
    ip route 192.16.10.0 255.255.255.0 192.200.10.2 # 配置下一跳的地址
    ip route 192.168.0.0 255.255.255.0 192.200.10.2

    # Router2
    ip route 192.200.10.0 255.255.255.0 192.16.10.2
    ip route 192.20.10.0 255.255.255.0 192.16.10.2

    # Router3
    ip route 192.168.0.0 255.255.255.0 192.16.10.1
    ip route 192.20.10.0 255.255.255.0 192.200.10.1

    # 验证路由配置成功
    # PC1
    ping 192.168.0.87


    路由器的高级配置

    西安交通大学实验报告

    课程:网络技术实验
    完成时间:2010年5月12日
    实验名称:路由器的高级配置

    实验内容

        使用Boson NetSim软件模拟出路由器的环境,并测试路由器的各种指令。

        使用Boson NetSim Designer软件设计一个只含有两个路由器的网络,将这两个路由器的Ethernet端口用双绞线相连。



        进入Boson NetSim软件的命令行模式,开始对路由器进行配置。

        在Router1的命令行下,进行如下操作(#号后为注释,下同):
    Router>enable
    Router#conf t
    Enter configuration commands, one per line.  End with CNTL/Z.
    Router(config)#hostname Router1           # 设置主机名为Router1
    Router1(config)#interface e0              # 配置e0接口
    Router1(config-if)#no shutdown            # 设置以太网端口不掉线
    %LINK-3-UPDOWN: Interface Ethernet0, changed state to up
    Router1(config-if)#description Ethernet interface on Router1
                                              # 设置描述
    Router1(config-if)#end                    # 退出配置模式,回到特权模式
    Router1#show interfaces                   # 查看所有端口的状态
    Serial0/0 is administratively down, line protocol is down
      Hardware is HD64570
      MTU 1500 bytes, BW 1544 Kbit, DLY 1000 usec, rely 255/255, load 1/255
      Encapsulation HDLC, loopback not set, keepalive set (10 sec)
      Last input 00:00:00, output 00:00:00, output hang never
      Last clearing of "show interface" counters never
      Queueing strategy: fifo
      Output queue 0/40, 0 drops; input queue 0/75, 0 drops
      5 minute input rate 1000 bits/sec, 2 packets/sec
      5 minute output rate 1000 bits/sec, 2 packets/sec
         0 packets input, 0 bytes, 0 no buffer
         Received 0 broadcasts, 0 runts, 0 giants, 0 throttles
         0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort
         0 input packets with dribble condition detected
         0 packets output, 0 bytes, 0 underruns
         0 output errors, 0 collisions, 0 interface resets
         0 babbles, 0 late collision, 0 deferred
         0 lost carrier, 0 no carrier
         0 output buffer failures, 0 output buffers swapped out
    Serial1/0 is administratively down, line protocol is down
      Hardware is HD64570
      MTU 1500 bytes, BW 1544 Kbit, DLY 1000 usec, rely 255/255, load 1/255
      Encapsulation HDLC, loopback not set, keepalive set (10 sec)
      Last input 00:00:00, output 00:00:00, output hang never
      Last clearing of "show interface" counters never
      Queueing strategy: fifo
      Output queue 0/40, 0 drops; input queue 0/75, 0 drops
      5 minute input rate 1000 bits/sec, 2 packets/sec
      5 minute output rate 1000 bits/sec, 2 packets/sec
         0 packets input, 0 bytes, 0 no buffer
         Received 0 broadcasts, 0 runts, 0 giants, 0 throttles
         0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort
         0 input packets with dribble condition detected
         0 packets output, 0 bytes, 0 underruns
         0 output errors, 0 collisions, 0 interface resets
         0 babbles, 0 late collision, 0 deferred
         0 lost carrier, 0 no carrier
         0 output buffer failures, 0 output buffers swapped out
    Ethernet0 is up, line protocol is up
      Hardware is Lance, address is 000C.3070.1825 (bia 000C.3070.1825)
      Description: Ethernet interface on Router1
      MTU 1500 bytes, BW 10000 Kbit, DLY 1000 usec, rely 255/255, load 1/255
      Encapsulation ARPA, loopback not set, keepalive set (10 sec)
      ARP type: ARPA, ARP Timeout 04:00:00
      Last input 00:00:00, output 00:00:00, output hang never
      Last clearing of "show interface" counters never
      Queueing strategy: fifo
      Output queue 0/40, 0 drops; input queue 0/75, 0 drops
      5 minute input rate 1000 bits/sec, 2 packets/sec
      5 minute output rate 1000 bits/sec, 2 packets/sec
         0 packets input, 0 bytes, 0 no buffer
         Received 0 broadcasts, 0 runts, 0 giants, 0 throttles
         0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort
         0 input packets with dribble condition detected
         0 packets output, 0 bytes, 0 underruns
         0 output errors, 0 collisions, 0 interface resets
         0 babbles, 0 late collision, 0 deferred
         0 lost carrier, 0 no carrier
         0 output buffer failures, 0 output buffers swapped out
        对Router2进行类似配置:
    Router>enable
    Router#conf t
    Enter configuration commands, one per line.  End with CNTL/Z.
    Router(config)#hostname Router2
    Router2(config)#interface e0
    Router2(config-if)#no shutdown
    %LINK-3-UPDOWN: Interface Ethernet0, changed state to up
    Router2(config-if)#end
        在Router1上运行cdp协议,尝试发现周围主机(Router2):
    Router1#show cdp interface #使用cdp协议检测以太网端口
    Serial0/0 is down, line protocol is down
    encapsulation HDLC
    Sending CDP packets every 60 seconds
    Holdtime is 180 seconds
    Serial1/0 is down, line protocol is down
    encapsulation HDLC
    Sending CDP packets every 60 seconds
    Holdtime is 180 seconds
    Ethernet0 is up, line protocol is up
    encapsulation ARPA
    Sending CDP packets every 60 seconds
    Holdtime is 180 seconds

    Router1#show cdp neighbors # 使用cdp协议发现邻居
    Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge
    S -Switch, H - Host, i - IGMP, r - Repeater
    Device ID        Local Intrfce     Holdtme    Capability  Platform  Port ID
    Router2             Eth0           173          R         2611      Eth 0

    Router1#show cdp neighbors detail
                               # 显示发现邻居的详细信息,包含运行的OS和版本
    -------------------------
    Device ID: Router2
    Entry address(es):
    Platform: Boson 2611 , Capabilities: Router
    Interface: Eth0, Port ID (outgoing port): Eth 0
    Holdtime:  166 sec

    Version :
    Boson Operating System Software
    Software, Version 12.1(16), RELEASE SOFTWARE (fc2)
    Copyright (c) 1986-2001 by Systems, Inc.
    Compiled Fri 02-Mar-01 17:34 by dchih


    Router1#show cdp entry Router2
    -------------------------
    Device ID: Router2
    Entry address(es):
    Platform: Boson 2611 , Capabilities: Router
    Interface: Eth0, Port ID (outgoing port): Eth 0
    Holdtime:  175 sec

    Version :
    Boson Operating System Software
    Software, Version 12.1(16), RELEASE SOFTWARE (fc2)
    Copyright (c) 1986-2001 by Systems, Inc.
    Compiled Fri 02-Mar-01 17:34 by dchih


    Router1#show cdp # 查看cdp协议本身的信息
    Global CDP information:
            Sending CDP packets every 60 seconds
            Sending a holdtime value of 180 seconds
            Sending CDPv2 advertisements is enabled
        配置Router1的IP地址信息:
    Router1#conf t
    Enter configuration commands, one per line.  End with CNTL/Z.
    Router1(config)#interface e0
    Router1(config-if)#ip address 192.168.0.1 255.255.255.0
                                  # 配置IP地址,同时提供子网掩码
    Router1(config-if)#no shutdown
    Router1(config-if)#end
        对Router2进行类似配置:
    Router2#conf t
    Enter configuration commands, one per line.  End with CNTL/Z.
    Router2(config)#interface e0
    Router2(config-if)#ip address 192.168.0.2 255.255.255.0
    Router2(config-if)#end
        使用show ip interface命令查看Router2的接口信息:
    Router2#show ip interface
    Serial0/0 is administratively down, line protocol is down
      Internet protocol processing disabled
    Serial1/0 is administratively down, line protocol is down
      Internet protocol processing disabled
    Ethernet0 is up, line protocol is up
      Internet address is 192.168.0.2/24
      Broadcast address is 255.255.255.0
      MTU 1500 bytes,
      Helper address is not set
      Directed broadcast forwarding is disabled
      Outgoing access list is not set
      Inbound  access list is not set
      Proxy ARP Is Enabled
      Security Level Is Default
      Split horizon Is Enabled
      ICMP redirects are always sent
      ICMP unreachables are always sent
      ICMP mask replies are never sent
      IP fast switching is enabled
      IP fast switching on the same interface is enabled
      IP Null turbo vector
      IP multicast fast switching is enabled
      IP multicast distributed fast switching is disabled
      router Discovery Is disabled
      IP output packet accounting is disabled
      IP access violation accounting is disabled
      TCP/IP header compression is disabled
      RTP/IP header compression is disabled
      Probe proxy name replies are disabled
      Policy routing Is disabled
      Network address translation is disabled
      WCCP Redirect outbound is disabled
      WCCP Redirect exclude is disabled
      BGP Policy Mapping is disabled
        在Router2上执行ping命令,验证线路畅通情况
    Router2# ping 192.168.0.1

    Type escape sequence to abort.
    Sending 5, 100-byte ICMP Echos to 192.168.0.1, timeout is 2 seconds:
    !!!!!
    Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms
        在Router1上操作ARP表:
    Router1#clear arp     # 清空ARP表
    Router1#show arp      # 查看当前ARP表,查看不到Router2的ARP信息
    Protocol  Address          Age (min)  Hardware Addr   Type   Interface
    Internet  192.168.0.1             -   000C.3070.1825  ARPA   Ethernet0

    Router1#ping 192.168.0.2 # 发现Router2并存入ARP表

    Type escape sequence to abort.
    Sending 5, 100-byte ICMP Echos to 192.168.0.2, timeout is 2 seconds:
    !!!!!
    Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms
    Router1#show arp      # 此时可以看到Router2的ARP信息
    Protocol  Address          Age (min)  Hardware Addr   Type   Interface
    Internet  192.168.0.1             -   000C.3070.1825  ARPA   Ethernet0
    Internet  192.168.0.2             15   000C.5580.7189  ARPA   Ethernet0
        在Router1上操作主机表:
    Router1#ping Router2 # 主机表里没有Router2的记录,ping命令失败
    % Unrecognized host or address, or protocol not running.

    Router1#conf t
    Enter configuration commands, one per line.  End with CNTL/Z.
    Router1(config)#ip host Router2 192.168.0.2
                         # 手动在主机表中增加一条记录
    Router1(config)#end
    Router1#ping Router2 # ping命令成功执行

    Type escape sequence to abort.
    Sending 5, 100-byte ICMP Echos to 192.168.0.2, timeout is 2 seconds:
    !!!!!
    Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms
    (完)

    笔记:


    # Router1
    enable
    conf t
    hostname Router1
    interface e0
    no shutdown # 不关闭以太网端口零
    description Ethernet interface on Router 1 # 设置描述
    end # 退出配置模式,回到特权模式
    show interfaces # 查看所有端口的状态


    # Router2
    enable
    conf t
    hostname Router2
    interface e0
    no shutdown
    end

    # Router1
    show cdp interface # 使用cdp协议检测以太网端口
    show cdp neighbors # 使用cdp协议发现邻居
    show cdp neighbors detail # 显示发现邻居的详细信息,包含运行的OS和版本
    show cdp entry Router2 # ???
    show cdp # 查看cdp协议本身的信息

    conf t
    interface e0
    ip address 202.117.35.1 255.255.255.0 # 配置IP地址,同时提供子网掩码
    no shutdown # 配置不掉线
    end

    # Router2
    conf t
    interface e0
    ip address 202.117.35.2 255.255.255.0 # 2~254
    end

    show ip interface # 查看接口信息

    ping 202.117.35.1 # 验证线路畅通情况

    # Router1
    ping 202.117.35.2
    clear arp # 清空arp表
    show arp # 查看不到Router2的ARP信息
    ping 202.117.35.2 # 发现Router2并存入ARP表
    show arp # 此时可以看到Router2的ARP信息


    # 配置主机表
    conf t
    ip host Router2 202.117.35.2 # 在主机表中增加一条记录
    end

    ping Router2 # ping命令成功