JUNOS逻辑路由器(Logical Routers)互联网接入

juniper-junos-logical-routers-data-forwarding
Juniper Networks M-SeriesT-Series路由器平台均支持逻辑路由器(Logical Router)的概念。逻辑路由器允许网络管理员将单一物理路由器根据各种不同的业务需求,分割成多个执行单独路由任务的逻辑路由器。尽管逻辑路由器技术从本质上而言应该属于Juniper JUNOS的一项业务特性技术,然而出于Juniper物理路由器的成本方面的考虑,JUNOS逻辑路由器在另一方面又成为了现在绝大部分M/T方向JNCIP/JNCIE认证考试备考人员实验台搭建的必备技术。

因此,对于JUNOS的Logical Routers特性:包括在单个Juniper物理路由器内部创建多个逻辑路由器,并实现逻辑路由器之间的互联;甚至穿越多个Juniper物理路由器,实现不同的Juniper物理路由器内部的逻辑路由器之间互联对大部分人而言应该不会感觉陌生。同时,或许是受到通过配置路由泄露实现MPLS/VPN互联网接入设计方案的启发。最近有朋友在论坛或者新闻组内谈起关于逻辑路由器与主路由器互联,从而实现路由进程间融合互操作的话题。在我看来,出现这样的疑惑可能是由于配置层次的不同,将逻辑路由器接口与主路由器接口之间的平行关系,与Q-in-Q中的802.1Q VLAN-ID叠加关系混淆而造成的。实际上,逻辑路由器与主物理路由器间的互联,以及两者之间路由进程的融合互操作的实现,乃至将来接入三层/二层VPN;与在逻辑路由器之间实现的配置并没有多大区别。

国庆期间我个人还有其它工作,更新可能会减慢,于是在10月份前我先把这篇文档完成。

JUNOS逻辑路由器(Logical Routers)与主路由器互联

我们在JUNOS主路由器(LR Master)上,创建接口fxp2.81并使用vlan-id 181与其内部逻辑路由器R1互联。注意配置中JUNOS的层次目录。

[edit]
nigel@junos# show interfaces fxp2
vlan-tagging;
unit 81 {
    vlan-id 181;
    family inet {
        address 192.168.81.1/30;
    }
}

相应的,在内部逻辑路由器R1上完成对应的配置,并测试连通性。

[edit]
nigel@junos# show interfaces fxp1
vlan-tagging;

[edit logical-routers r1]
nigel@junos# show interfaces fxp1
unit 81 {
    vlan-id 181;
    family inet {
        address 192.168.81.2/30;
    }
}

[edit]
nigel@junos# run ping 192.168.81.2 rapid
PING 192.168.81.2 (192.168.81.2): 56 data bytes
!!!!!
--- 192.168.81.2 ping statistics ---
5 packets transmitted, 5 packets received, 0% packet
loss
round-trip min/avg/max/stddev = 0.393/0.427/0.521/0.048
ms

JUNOS逻辑路由器(Logical Routers)与主路由器IS-IS互联

配置JUNOS主路由器上的IS-IS路由进程。

nigel@junos# show interfaces lo0
unit 8 {
    family iso {
        address 49.0001.8888.8888.8888.00;
    }
}

[edit]
nigel@junos# set interfaces fxp2.81 family iso 

[edit]
nigel@junos# show protocols
isis {
    interface fxp2.81 {
        level 2 disable;
    }
}

配置JUNOS逻辑路由器R1上的IS-IS路由进程。

[edit logical-routers r1]
nigel@junos# show interfaces lo0
unit 1 {
    family inet {
        address 10.0.6.1/32;
    }
    family iso {
        address 49.0001.1111.1111.1111.00;
    }
}

[edit logical-routers r1]
nigel@junos# set interfaces fxp1.81 family iso

[edit logical-routers r1]
nigel@junos# show protocols
isis {
    interface fxp1.81 {
        level 2 disable;
    }
}

确认JUNOS逻辑路由器(Logical Routers)与主路由器(LR Master)之间的IS-IS互联邻接关系,我隐去了相关的MAC地址信息。

[edit]
nigel@junos# run show isis adjacency
Interface   System         L State  Hold (secs) SNPA
fxp2.81     1111.1111.1111 1 Up             22  

JUNOS逻辑路由器(Logical Routers)互联网接入

下一步,我们完成逻辑路由器到互联网的接入配置。由于当前JUNOS逻辑路由器R1通过vlan-tagging接口fxp1.81,与JUNOS主物理路由器的vlan-tagging接口fxp2.81,实现了IS-IS的互联。便可以通过在主物理路由器上,将来自逻辑路由器R1的互联网流量导向主物理路由器与网关相连的接口,从而实现JUNOS逻辑路由器的互联网接口配置。该接口可以是JUNOS主物理路由器上另外一个独立的物理接口,也可以是同样使用dot1.Q封装,使用另一个vlan-id的另一个逻辑接口,取决于JUNOS主物理路由器与网关之间的连接方式。在案例中,当前我们的JUNOS主物理路由器使用另一个独立的非vlan-tagging物理接口fxp0与网关IP 192.168.13.1连接:当然在现实中不可能会出现这样的情况,这里只是为了测试而临时借用这个接口。

首先完成JUNOS主路由器到网关的默认路由以及DNS解析配置。另外,你同时也需要在网关上增加一条指回JUNOS主路由器与JUNOS逻辑路由器R1之间的192.168.81/30网段的静态路由。这里将互联网出口网关的配置忽略。

[edit]
nigel@junos# show system
name-server {
    202.99.104.68;
    192.168.13.1;
}

[edit]
nigel@junos# show interfaces fxp0
unit 0 {
    family inet {
        address 192.168.13.254/24;
    }
}

[edit]
nigel@junos# show routing-options
static {
    route 0.0.0.0/0 next-hop 192.168.13.1;
}

在JUNOS主物理路由器上创建JUNOS Policy lr-internet,将上面的默认路由注入IS-IS路由协议,通告至JUNOS逻辑路由器R1上。

[edit]
nigel@junos# show policy-options
policy-statement lr-internet {
    term 1 {
        from {
            protocol static;
            route-filter 0.0.0.0/0 exact;
        }
        then accept;
    }
}

[edit]
nigel@junos# set protocols isis export lr-internet 

[edit]
nigel@junos# commit
commit complete

最后,确认JUNOS逻辑路由器从主路由器收到0/0默认路由,并且完成互联网连接测试。

nigel@junos# run show route logical-router r1 0/0 exact 

inet.0: 13 destinations, 13 routes (13 active, 0 holddown,
0 hidden)
+ = Active Route, - = Last Active, * = Both

0.0.0.0/0          *[IS-IS/160] 00:03:38, metric 10
                    > to 192.168.81.1 via fxp1.81

nigel@junos> traceroute www.apple.com logical-router r1
traceroute to www.apple.com.akadns.net (17.112.152.32),
30 hops max, 40 byte packets
......
<!--output omitted-->
 6  202.99.66.181 (202.99.66.181)
     12.759 ms  53.868 ms  9.645 ms
 7  219.158.13.253 (219.158.13.253)
     14.698 ms  12.663 ms  14.716 ms
 8  219.158.4.146 (219.158.4.146)
     40.732 ms  15.540 ms  13.739 ms
 9  12.116.103.9 (12.116.103.9)
     219.383 ms  244.448 ms  374.841 ms
10  tbr1.la2ca.ip.att.net (12.122.104.18)
     398.096 ms  238.519 ms  488.126 ms
     MPLS Label=29069 CoS=0 TTL=1 S=1
11  cr1.la2ca.ip.att.net (12.122.19.145)
     302.453 ms  349.816 ms  230.336 ms
     MPLS Label=17458 CoS=0 TTL=255 S=1
12  cr1.sffca.ip.att.net (12.122.3.121)
     232.256 ms  443.132 ms  233.304 ms
     MPLS Label=17088 CoS=0 TTL=255 S=1
13  cr1.sc1ca.ip.att.net (12.122.30.121)
     251.243 ms  249.509 ms  373.919 ms
     MPLS Label=16310 CoS=0 TTL=255 S=1
14  12.123.155.9 (12.123.155.9)
     263.958 ms  244.534 ms  218.387 ms
15  * * *
......
<!--output omitted-->

JUNOS – Giving You the Power of Choose

JUNOS - One OS, One interface, One code, the only One you need

JUNOS – One OS, One interface, One code, the only One you need

之前,Juniper Networks的市场宣传广告一直采用近乎恶搞的风格。我个人非常喜欢,而且有收集这类素材的爱好。这次找来肥版Juniper Man过来当主角的:

JUNOS – Giving you the power of choose

主题网站同样没有例外。

而如果你觉得这样的风格不够庄重的话,那么最新出炉的JUNOS ASIA,或许会适合你的口味。在这里回答三个关于JUNOS如何提网络效率的问题还能赢取Juniper T恤

Juniper JUNOS BGP与OSPF完全末节区域设计陷阱

完成JUNOS OSPF末节区域(Stub Area)配置以后,需要进一步过滤域间路由LSA-3,压缩OSPF数据库并不难。只需要在ABR上加入no-summary参数,将当前的OSPF末节区域10设置为OSPF完全末节区域(TSA)即可。我们不需要在OSPF 区域10的所有Juniper JUNOS路由器上面设置,因为OSPF LSA-3只会通过OSPF ABR将来自骨干区域的LSA转换为LSA-3注入末节区域,因此我们在OSPF ABR上设置该区域为OSPF末节区域,并且阻止netsummary LSA注入,便可过滤掉LSA-3/4/5三种LSA。在实验中,OSPF区域10存在R3/R4两台ABR,我们需要同时在这两台ABR上面加上no-summary参数。

[edit logical-routers r3 protocols]
nigel@junos# set ospf area 10 stub no-summaries

[edit logical-routers r4 protocols]
nigel@junos# set ospf area 10 stub no-summaries

查看Juniper JUNOS R1的OSPF数据库,只有由两台JUNOS OSPF ABR注入的,用于保持OSPF域外/域间目标网段连通性的默认路由仍然保留在JUNOS OSPF的数据库当中,同时注意这些默认路由依然以OSPF LSA-3的形式出现。OSPF区域10内的路由器仍然保持对200.200/24网段的连通性。

nigel@junos# run show ospf database logical-router r1
netsummary

    OSPF link state database, Area 0.0.0.10
 Type      ID       Adv Rtr   Seq    Age  Opt  Cksum Len
Summary 0.0.0.0  10.0.3.3 0x8000000a  31 0x20 0x849d 28
Summary 0.0.0.0  10.0.3.4 0x8000000b  30 0x20 0x7ea2 28

nigel@junos# run traceroute logical-router r1 200.200.0.1
traceroute to 200.200.0.1 (200.200.0.1), 30 hops max,
40 byte packets
 1  10.0.4.13 (10.0.4.13)  0.476 ms  0.364 ms  0.278 ms
 2  10.0.2.1 (10.0.2.1)  0.438 ms  0.577 ms  0.407 ms
 3  10.0.8.10 (10.0.8.10)  0.613 ms  0.583 ms  0.601 ms
 4  10.0.8.10 (10.0.8.10)  0.581 ms !H  0.661 ms !H
0.548 ms !H

Juniper JUNOS BGP与OSPF完全末节区域(TSA)的设计陷阱

需要特别注意的是:配置OSPF TSA,它往往是事故出现的多灾区域,因为不单失去了OSPF域外路由LSA-5,同时OSPF域间路由LSA-3同时被过滤掉,链路状态的瓶颈会增加OSPF网络的扩展性能。尤其由于设计上的疏忽,尝试在OSPF TSA内实现扩展特性,路由黑洞屡屡会产生。

常见的设计错误包括将本地子网在OSPF TSA内汇总,从而丢失域内路由器全部的外部连通性,使OSPF TSA成为网路孤岛;尝试穿越TSA建立OSPF虚链路;以及OSPF TSA域内路由器通过JUNOS BGP与域外路由器交换路由更新,而造成协议下一跳不可达,进而造成路由Hidden,如此这般的情况时有发生。

这些情况会在后面的内容里面逐一演示。因此在配置JUNOS OSPF区域的时候,需要明确OSPF TSA的角色,任何日后存在扩展性需求的区域都不应该被轻易的定义为OSPF TSA。

Juniper JUNOS OSPF末节区域(Stub Area)配置

configurate-juniper-junos-ospf-stub-tsa-nssa-area
为了测试Juniper JUNOS的OSPF末节区域(Stub Area)对域外LSA的过滤效果。我们预先在Juniper路由器R7上注入OSPF域外(外部)路由/LSA200.0.0.0/24,下面我们继续在R1, R2, R3, R4上完成OSPF末节区域10(Stub Area)的配置。本实验包含的目标如下所示:

  1. 在R7上,以域外路由的形式通告200.0.0/24网段
  2. R1与R2只能充当区域0.0.0.10的域内路由器
  3. 区域0.0.0.10内不允许出现任何类型5的LSA(LSA-5)
  4. 所有路由器的环回接口地址都能从区域0.0.0.10被访问
  5. 区域0.0.0.10内不允许出现任何静态路由

Juniper JUNOS OSPF末节区域(Stub Area)10配置 – R1

protocols {
    ospf {
        area 0.0.0.10 {
            stub;
            interface lo0.1 {
                passive;
            }
            interface fxp1.12;
            interface fxp1.13;
        }
    }
}
routing-options {
    router-id 10.0.6.1;
}

Juniper JUNOS OSPF末节区域(Stub Area)10配置 – R2

protocols {
    ospf {
        area 0.0.0.10 {
            stub;
            interface lo0.2 {
                passive;
            }
            interface fxp2.12;
            interface fxp2.24;
        }
    }
}
routing-options {
    router-id 10.0.6.2;
}

Juniper JUNOS OSPF末节区域(Stub Area)10配置 – R3

[edit logical-routers r3 protocols]
nigel@junos# set ospf area 10 interface fxp2.13

[edit logical-routers r3 protocols]
nigel@junos# set ospf area 10 stub

Juniper JUNOS OSPF末节区域(Stub Area)10配置 – R4

[edit logical-routers r4 protocols]
nigel@junos# set ospf area 10 interface fxp1.24

[edit logical-routers r4 protocols]
nigel@junos# set ospf area 10 stub

JUNOS OSPF末节区域与完全末节区域(TSA)默认路由特性

默认情况下,Juniper JUNOS路由器并不会像CISCO IOS在连接OSPF末节区域或者完全末节区域(TSA)的区域边界那样自动向末节区域或TSA注入默认路由。为了保证末节区域或TSA内部路由器对域外路由,域间路由的连通性。我们必须手动在ABR上指定默认路由的Metric值(default-Metric),才能保证ABR向末节区域/TSA通告默认路由。我们需要根据需求在R1/R2/R3/R4上将区域10配置成末节区域/TSA。

注意default-Metric只需要在ABR R3/R4上面配置即可,而作为区域10的域内路由器R1/R2只需要将区域10设置为末节区域。

nigel@junos# show r3 protocols ospf
area 0.0.0.0 {
    interface fxp1.34;
    interface fxp1.35;
    interface lo0.3 {
        passive;
    }
    interface fxp1.30 {
        passive;
    }
}
area 0.0.0.10 {
    stub default-metric 10;
    interface fxp2.13;
}

nigel@junos# show r4 protocols ospf
area 0.0.0.0 {
    interface fxp2.34;
    interface fxp1.45;
    interface lo0.4 {
        passive;
    }
}
area 0.0.0.10 {
    stub default-metric 10;
    interface fxp1.24;
}

完成配置以后,我们先检查一下末节区域10里面的OSPF邻接状态。由于我们设置区域10为末节区域,Hello中OSPF的数据包头的Option “E”位将被置0激活opt 0x0,邻接状态建立成功表明双方的option “E”位同步激活,确认区域10被设置为末节区域。另外,查看R1上OSPF的概括信息能更清晰的发现区域10被设置成为末节区域(Stub Area),同时存在两台区域边界路由器。

注意:overview为JUNOS 8.5版本参数。

nigel@junos# run show ospf neighbor logical-router r1
Address    Interface   State    ID          Pri  Dead
10.0.4.6    fxp1.12    Full    10.0.6.2    128    38
10.0.4.13   fxp1.13    Full    10.0.3.3    128    38

nigel@junos# run show ospf overview logical-router r1
Instance: master
  Router ID: 10.0.6.1
  Route table index: 10
  Full SPF runs: 27, SPF delay: 0.200000 sec,
  SPF holddown: 5 sec, SPF rapid runs: 3
  LSA refresh time: 50 minutes
  Area: 0.0.0.10
    Stub type: Stub
    Authentication Type: None
    Area border routers: 2, AS boundary routers: 0
    Neighbors
      Up (in full state): 2

随后我们清空一遍R1的OSPF数据库,确定R7通告过来的200.200/24域外路由LSA-5已经从R1的LSDB当中消失。同时查看R1路由表,确认收到用于连接域外网段的默认路由0.0.0.0,同时不存在200.200/16或更长前缀的路由。

nigel@junos# run clear ospf database logical-router r1

nigel@junos# run show ospf database logical-router r1
external | count
Count: 0 lines

nigel@junos# run show route protocol ospf logical-router
r1 | match 0.0.0.0
0.0.0.0/0          *[OSPF/10] 00:39:21, metric 11

nigel@junos# run show route protocol ospf logical-router
r1 200.200/16 | count
Count: 0 lines

虽然R1的路由表上已经没有域外路由200.200/24,由于从ABR上面接收到默认路由,因此R1依然能够通过traceroute测试R1到200.200/24网段的连通性。

nigel@junos# run traceroute 200.200.0.1 logical-router r1
traceroute to 200.200.0.1 (200.200.0.1), 30 hops max,
40 byte packets
 1  10.0.4.13 (10.0.4.13)  0.493 ms  0.882 ms  0.337 ms
 2  10.0.2.1 (10.0.2.1)  0.543 ms  0.439 ms  0.530 ms
 3  10.0.8.10 (10.0.8.10)  0.608 ms  0.741 ms  0.569 ms
 4  10.0.8.10 (10.0.8.10)  0.617 ms !H  0.662 ms !H
0.621 ms !H

最后,我们查看R1的OSPF数据库,保证域间路由LSA-3仍然存在于LSDB的区域10当中。

nigel@junos# run show ospf database logical-router r1
netsummary 

    OSPF link state database, Area 0.0.0.10
 Type      ID       Adv Rtr   Seq    Age  Opt  Cksum Len
Summary 0.0.0.0  10.0.3.3 0x80000004 731 0x20 0x849d 28
Summary 0.0.0.0  10.0.3.4 0x80000004 610 0x20 0x7ea2 28
Summary 10.0.2.0 10.0.3.3 0x80000005 429 0x20 0x7da3 28
…

JUNOS Aggregate routes pk. Generate routes

ITAA Juniper实验手册的《JUNOS Generate Route反传统接入设计》一文中,我花了很长的篇幅对比了Aggregate RoutesGenerate Routes,这两种JUNOS静态路由形式之间的异同。恰好看到jakee也在谈论这个问题,于是我将该设计方案的前面一段先发出来。

JUNOS当中,与配置Aggregate Routes非常相似的另外一种形式的静态路由是配置Generate Routes,Generate Routes通常被用作结合Aggregate Routes的汇总与静态路由的IP转发功能为一体而使用。Generate Routes与Aggregate Routes共享许多相同的特性,如汇总路由,本地路由表必须存在明细路由,以及大部分的附加路由属性。

实际上,JUNOS路由表将它们两者当作同属Aggregate协议的路由来对待,并且两者在Juniper JUNOS路由表当中的Preference均为130.

而两者最大的区别在于对待下一跳问题的处理上面:

Aggregate Routes路由的目的,仅仅为了将已经存在于本地路由表的路由手工汇总成一条单一路由表示,而并非为了在本地路由器上充当到达汇总路由网段的数据转发。所有到达汇总路由网段的数据流应当依赖本地的明细路由根据最长匹配原则转发,因此Aggregate Routes路由的下一跳为reject,或者是可选的discard

Generate Routes路由的角度上而言,其目的除了对路由进行汇总以外,同时也作为到达汇总目标网段的最后求助网关,因此Generate Routes路由存在一个确实的下一跳IP地址。该地址为Generate Routes的Contributing Routes当中数字最小的路由下一跳(对于单一路由协议而言),同时该Contributing Routes被认为是Primary Contributing Routes。

此外,对于Generate Routes,成为其Contributing Routes还有一个限制,所有下一跳为discard或者reject的路由均不能成为合法的Contributing Routes。

JUNOS Contributing Routes

Active IP routes in the routing table that share the same most-significant bits and are more specific than an aggregate or generate route.

JUNOS Primary Contributing Route

Contributing route with the numerically smallest prefix and smallest JUNOS software preference value. This route is the default next hop used for a generated route.

JUNOS Rescue Configuration(救援配置)

juniper-j-series-junos-rescue-configuration-button阿婆行得快,一定有古怪。我在之前发布的JUNOS配置管理文档,主要讨论如何使用JUNOS的CLI对Juniper Networks路由器上的配置文件进行JUNOS管理性操作。这是一种软件行为。而在JUNIPER网络公司J系列业务路由器平台上,其中一种重要的特性便在于:当出现人为配置失误出现网络故障时,你可以使用J-系列路由器面板上的RESET/CONFIG按钮从物理上,将Juniper路由器恢复到JUNOS厂商默认配置,或者一份之前由网络管理员创建并保存的,并且根据你的需求,能够确保Juniper路由器能够顺利的重新接入网络,或者能够承担提供基本正常数据转发功能的JUNOS Rescue Configuration(救援/挽救/紧急配置)上。

一般情况下,直接按下RESET/CONFIG按钮并马上松开,Juniper路由器将恢复到Rescue configuration上:这时按钮就叫CONFIG按钮;而按下该按钮并持续15秒以后再松开,Juniper路由器则恢复到Factory defaults配置上,这时按钮就又叫做RESET按钮了。JUNOS Cookbook上有关于在JUNOS CLI上创建/恢复JUNOS rescue紧急救援配置的章节可参考,这里不详细分析。

创建JUNOS Rescue Configuration(救援配置)

nigel@junos> request system configuration rescue save
nigel@junos> 

删除JUNOS Rescue Configuration(救援配置)

nigel@junos> request system configuration rescue delete
nigel@junos> 

还原并激活JUNOS Rescue Configuration(救援配置)

[edit]
nigel@junos> rollback rescue
load complete

[edit]
nigel@junos> commit

JUNOS配置标注技巧

1. JUNOS commit/rollback配置标注: commit comment

之前谈过commit commnet这个技巧,在配置Juniper路由器的过程中,当每次使用JUNOS的commit命令激活新配置的时候。最近4次被激活提交的4个JUNOS配置文件会被压缩并放在/config目录底下。

[edit]
nigel@junos# run file list /config/ 

/config/:
juniper.conf.1.gz
juniper.conf.2.gz
juniper.conf.3.gz
juniper.conf.gz
rescue.conf.gz

而为了使你在日后使用JUNOS的rollback功能,更早以前的其余45个JUNOS配置文件则被另外存放在另一个目录/var/db/config/底下。

[edit]
nigel@junos# run file list /var/db/config/ | count
Count: 47 lines

当然,与在Cisco IOS上使用configuration archive实现类JUNOS的rollback相比,JUNOS配置回滚具有明显的优势。同时,使用JUNOS的commit comment命令,在激活提交该关键的JUNOS配置的同时,为这次提交激活的JUNOS配置文件添加标注,是一个很好的习惯。简单的标注文字,让你能确定JUNOS系统将恢复到你希望的得到的配置结果上面。

nigel@junos# set system root-authentication
plain-text-password
New password:
Retype new password:

[edit]
nigel@junos# commit comment "root auth."
commit complete

[edit]
nigel@junos# run show system commit
0   2008-05-10 01:51:04 CST by nigel via cli
    root auth.
1   2008-05-10 01:19:01 CST by nigel via cli
2   2008-05-10 09:10:09 CST by nigel via cli
3   2008-05-10 09:27:40 CST by nigel via cli 

2. Juniper JUNOS路由器接口标注: interface description

对于熟悉Cisco IOS技巧的Geek来说,对于接口标注这个特性应该不会感到陌生,包括接口链路速率,对端设备,以及对端接口等信息均可以通过JUNOS的description命令,被加入到接口描述标注当中。为网络工程师提供网络拓扑连接方面的协助。

[edit]
nigel@junos# set interfaces fxp0 description
"OoB Management"

[edit]
nigel@junos# run show interfaces fxp0
Physical interface: fxp0, Enabled, Physical link is Up
  Interface index: 1, SNMP ifIndex: 1
  Description: OoB Management
......
<!-- output omitted-->

3. JUNOS配置文件分段标注: annote

我个人最喜爱的JUNOS标注技巧,使用JUNOS的annote命令,可以将JUNOS配置文件进行分段标注,进一步加强基于层次化架构的JUNOS配置文件的可读性。譬如你可以在OSPF协议层次下面,为不同OSPF区域上加入区域特性,或者是该区域所覆盖的地理范围等参考提示信息。

[edit interfaces]
nigel@junos# annotate fxp0
"Network MGMT Interface"                                

[edit interfaces]
nigel@junos# show
/* Network MGMT Interface */
fxp0 {
    description "OoB Management";
    unit 0 {
        family inet {
            address 192.168.13.254/24;
        }
    }
}
fxp1 {
    vlan-tagging;
}
fxp2 {
    vlan-tagging;
}

4. Juniper JUNOS路由器banner信息标注:

与Cisco IOS路由器的banner motd类似,JUNOS的message命令也允许你设置一个当其他用户连接到Juniper路由器上的时候所显示的提示信息。如果你需要换行,可以使用\n作为标识符。

[edit system login]
nigel@junos#set message "==============================\n
Access to this device is limited to authorized users only
\nWARNING: All unauthorized access is prohibited.\n
=============================="

连接到Juniper JUNOS路由器上显示效果如下。

bogon:~ nigel$ telnet 192.168.13.254
Trying 192.168.13.254...
Connected to bogon.
Escape character is '^]'.
=========================================================
Access to this device is limited to authorized users only
 WARNING: All unauthorized access is prohibited.
=========================================================

5. Juniper JUNOS路由器登录欢迎信息标注

另外,对于成功登录Juniper JUNOS路由器的用户,你也可以使用JUNOS的announcement命令制定另外一段欢迎的信息。

[edit system login]
nigel@junos# set announcement "Welcome to JUNIPER JUNOS"

成功登录到Juniper JUNOS路由器后显示效果如下。

login: nigel
Password:

--- JUNOS 7.2R4.2 built 2006-02-14 07:33:49 UTC

Welcome to JUNIPER JUNOS

nigel@junos> 

Juniper/Cisco互操作: 配置JUNOS/IOS SSH2互访

继续之前关于配置Juniper JUNOS路由器与Cisco IOS路由器之间远程互访登录的话题。无论是Juniper的JUNOS设备,还是Cisco的IOS设备,两者都可以同时充当Secure Shell (SSH)客户端与服务器端,这为我们实现两者的互联互访测试提供契机。我们将通过最简单的配置,实现JUNOS与IOS之间的SSHv2互访。注意,SSHv1与SSHv2实际上有很大的差别。作为用户而言,单纯笼统的就安全性而言话,SSHv2要大大高于SSHv1,而SSHv1仅仅比起telnet又要稍微好一点。由于Cisco IOS自12.0S开始支持SSHv1,而直到12.3T支持SSH2协议,所以我们的接下来便基于SSH2进行讨论。而至于具体区别在哪里?我估计你也不会有多大兴趣去了解,尽管用就是了。

SSH protocol in Cisco IOS release trains:

  • IOS 12.0S (SSH version 1)
  • IOS 12.1T (SSH version 1)
  • IOS 12.2 (SSH version 1)
  • IOS 12.2T (SSH version 1)
  • IOS 12.3T (SSH version 2)

Juniper JUNOS启用SSH2

那我们从最直观的在Juniper JUNOS上启用SSH2配置开始,在JUNOS上启用SSH2的基本配置非常简便。由于之前我们已经在JUNOS上加入用户名/密码分别为ciscoios123的本地帐号。只需要在[edit system services]层次下启用SSH服务,并且指定使用SSHv2就可以了。可以看到我们同时打开了JUNOS上的telnet与SSH2服务。假如有必要,建议你将telnet服务关闭,同时我们拒绝使用root用户帐号通过SSH登录到Juniper路由器上。

[edit]
nigel@junos# show system services
ssh {
    root-login deny;
    protocol-version v2;
}
telnet;

Cisco IOS路由器使用SSH2登录Juniper JUNOS

r4-ios#conf t
r4-ios(config)#no service timestamps
r4-ios(config)#line con 0
r4-ios(config-line)#logging synchronous
r4-ios(config-line)#end
r4-ios#debug ip ssh
Incoming SSH debugging is on

打开debug信息后,我们使用之前配置的用户名cisco,在IOS上通过SSH2登录到之前配置了静态主机名映射的Juniper JUNOS路由器juniper-junos上。

r4-ios#ssh -l cisco juniper-junos

Password:
SSH CLIENT0: protocol version id is - SSH-2.0-OpenSSH_3.8
SSH CLIENT0: sent protocol version id SSH-1.99-Cisco-1.25
SSH2 CLIENT 0: send: len 280 (includes padlen 4)
SSH2 CLIENT 0: SSH2_MSG_KEXINIT sent
SSH2 CLIENT 0: ssh_receive: 608 bytes received
SSH2 CLIENT 0: input: packet len 608
SSH2 CLIENT 0: partial packet 8, need 600, maclen 0
SSH2 CLIENT 0: input: padlen 7
SSH2 CLIENT 0: received packet type 20
SSH2 CLIENT 0: SSH2_MSG_KEXINIT received
......
<!--output omitted-->

--- JUNOS 7.2R4.2 built 2006-02-14 07:33:49 UTC
cisco@junos>

cisco@junos> show system connections | match 22
tcp4  0 156  10.0.4.10.22   10.0.4.9.60935  ESTABLISHED
tcp4  0   0  *.22           *.*             LISTEN
tcp4  0   0  *.6222         *.*             LISTEN

Cisco IOS启用SSH2

Cisco IOS上配置SSH实际上也不是很复杂。只是有几个地方需要注意。

1. 保证你配置了Cisco IOS路由器的主机名。

r4-ios(config)#host r4-ios

2. 使用ip domain-name命令配置路由器本地域名。

r4-ios(config)#ip domain-name itaalab.com

3. 关键的一点在于产生RSA公共密钥的时候,密钥长度不能使用默认的512 bits,而至少需要768 bits,否则SSH客户端无法使用SSH连接登录到Cisco IOS路由器上。我在这里先故意使用默认的512 bits长度。

r4-ios(config)#crypto key generate rsa
The name for the keys will be: r4-ios.itaalab.com
Choose the size of the key modulus in the range of 360
to 2048 for your
  General Purpose Keys. Choosing a key modulus greater
  than 512 may take a few minutes.

How many bits in the modulus [512]:
% Generating 512 bit RSA keys, keys will be non-exportable
...[OK]

r4-ios(config)#
%SSH-5-ENABLED: SSH 1.99 has been enabled

4. 指定Cisco IOS启用SSHv2

r4-ios(config)#ip ssh version 2

5. 在Cisco IOS上,为将要从Juniper JUNOS路由器使用SSH2登录的用户创建一个与Juniper JUNOS上相同的本地用户帐号,密码在Cisco IOS本地定义,可以不匹配。

r4-ios(config)#user nigel password test

r4-ios#show ip ssh
SSH Enabled - version 2.0
Authentication timeout: 120 secs;
Authentication retries: 3

6. 一旦启用SSH,可选的配置便是将安全性能较低的telnet服务端口关闭,只允许使用SSH协议远程登录到Cisco IOS路由器上。

r4-ios(config)#line vty 0 4
r4-ios(config-line)#transport input ssh

nigel@junos> telnet cisco-ios logical-router r2
Trying 10.0.4.9...
telnet: connect to address 10.0.4.9: Connection refused
telnet: Unable to connect to remote host

Juniper JUNOS路由器使用SSH2登录Cisco IOS

当我们试图在JUNOS上通过SSH2登录到之前配置了静态主机名映射的Cisco IOS路由器cisco-ios上的时候,由于我们刚刚在Cisco IOS上所生成的RSA公共密钥长度少于768 bits。JUNOS在对RSA进行校验时失败,此时我们无法使用SSH2登录到Cisco IOS路由器上面。

nigel@junos> ssh v2 cisco-ios logical-router r2
The authenticity of host 'cisco-ios (10.0.4.9)' can't be
established.
RSA key fingerprint is 1b:9a:81:65:3d:85:90:c0:b4:56:67
:89:52:02:89:40.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'cisco-ios,10.0.4.9' (RSA)
to the list of known hosts.
ssh_rsa_verify: RSA modulus too small:
512 < minimum 768 bits
key_verify failed for server_host_key

nigel@junos>

于是,我们需要在Cisco IOS上清除原有的RSA公共密钥,然后重新生成符合768 bits长度的新的SSH2 RSA公共密钥。

r4-ios(config)#crypto key zeroize rsa
% All RSA keys will be removed.
% All router certs issued using these keys will also be
removed.
Do you really want to remove these keys? [yes/no]: yes

%SSH-5-DISABLED: SSH 2.0 has been disabled

r4-ios(config)#crypto key generate rsa
The name for the keys will be: r4-ios.itaalab.com
Choose the size of the key modulus in the range of 360
to 2048 for your
  General Purpose Keys. Choosing a key modulus greater
  than 512 may take a few minutes.

How many bits in the modulus [512]: 768
% Generating 768 bit RSA keys, keys will be non-exportable
...[OK]

r4-ios(config)#
%SSH-5-ENABLED: SSH 2.0 has been enable

到这里,这事还没完,由于之前我们已经将错误生成的512 bits长度RSA公钥导入Juniper JUNOS内。此时我们再次通过SSH2从Juniper JUNOS尝试登录到Cisco IOS路由器上的时候,Juniper JUNOS发现当前Cisco IOS所提供的RSA公钥,与保存在JUNOS本地的RSA公钥不匹配。处于安全原因,Juniper JUNOS依然不允许我们登录 …… JUNOS这下立功了,真的喝水也有塞牙时啊。

nigel@junos> ssh v2 cisco-ios logical-router r2
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@   WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!    @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now
(man-in-the-middle attack)!
It is also possible that the RSA host key has just been
changed.
The fingerprint for the RSA key sent by the remote host
is 29:e8:4b:95:48:2d:7d:37:94:c2:a9:db:00:a2:56:ea.
Please contact your system administrator.
Add correct host key in /var/home/nigel/.ssh/known_hosts
to get rid of this message.
Offending key in /var/home/nigel/.ssh/known_hosts:1
RSA host key for cisco-ios has changed and you have
requested strict checking.
Host key verification failed.

nigel@junos> file show /var/home/nigel/.ssh/known_hosts
cisco-ios,10.0.4.9 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAQ
QDmWa/IYF2VLp27213/
OIn3SvWz9d91n7OBt3Z3rfrlRZYcmBP9E5NPs
Oxj7l8X5Pf3M7DPClF3UdoW8UYbAusp

最后删除原来保存在JUNOS上的RSA公钥,然后重新导入新的RSA公钥,终于通过SSH2成功登录到Cisco IOS路由器上。

nigel@junos> file delete /var/home/nigel/.ssh/*

nigel@junos> ssh v2 cisco-ios logical-router r2
The authenticity of host 'cisco-ios (10.0.4.9)' can't be 
established.
RSA key fingerprint is 29:e8:4b:95:48:2d:7d:37:94:c2:a9
:db:00:a2:56:ea.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'cisco-ios,10.0.4.9' (RSA) 
to the list of known hosts.
Password: 

r4-ios>