最近在学习JUNOS,刚刚起步,感觉从IOS过渡还是蛮快的,毕竟原理性的东西相通,今天特意做了一下OSPF,实验环境是ITAA的JUNOS虚拟机(哈哈打一下小广告),从以前不能识别Intel网卡到不支持组播再到现在的基本OK,虚拟机的发展还是挺迅速的,这对我们来讲无疑是莫大的帮助,好,不说这个,我们来看看如何在JUNOS中配置OSPF。
实验中利用JUNOS的逻辑路由器特性起了3台Router,分别为R1,R2,R3 ,拓扑为(lo0.0 1.1.1.1)R1---12.1.1.0---R2(lo0.1 2.2.2.2)---23.1.1.0----R3(lo0.2 3.3.3.3),由于是逻辑上的路由器,实际的物理接口只有FXP0到FXP3,所以要打上Vlan-tagging,事实上就是每台逻辑路由器的单臂路由。
具体配置如下:(大家不要以为是C++ , JUNOS的show可读性还是很强的)
[edit]
root@Router1 # show
## Last changed: 2008-06-02 21:52:49 UTC
version 8.5R1.14;
system {
host-name Router1;
domain-name mynetwork.com;
backup-router 192.168.15.2;
root-authentication {
encrypted-password "$1$rJIo5b.H$JOjbMEuowTG/IE1lh4Upo0"; ## SECRET-DATA
}
name-server {
192.168.15.3;
}
services {
web-management {
http {
port 80;
}
}
}
syslog {
user * {
any emergency;
}
file messages {
any notice;
authorization info;
}
file interactive-commands {
interactive-commands any;
}
}
}
logical-routers {
R1 {
interfaces {
fxp1 {
unit 10 {
vlan-id 10;
family inet {
address 12.1.1.1/30;
}
}
}
lo0 {
unit 0 {
family inet {
address 1.1.1.1/32;
}
}
}
}
protocols {
ospf {
area 0.0.0.0 {
interface fxp1.10;
interface lo0.0;
}
}
}
routing-options {
router-id 1.1.1.1;
}
}
R2 {
interfaces {
fxp2 {
unit 20 {
vlan-id 10;
family inet {
address 12.1.1.2/30;
}
}
unit 30 {
vlan-id 20;
family inet {
address 23.1.1.2/24;
}
}
}
lo0 {
unit 1 {
family inet {
address 2.2.2.2/32;
}
}
}
}
protocols {
ospf {
area 0.0.0.0 {
interface fxp2.20;
interface lo0.1;
interface fxp2.30;
}
}
}
routing-options {
router-id 2.2.2.2;
}
}
R3 {
interfaces {
fxp3 {
unit 30 {
vlan-id 20;
family inet {
address 23.1.1.3/24;
}
}
}
lo0 {
unit 2 {
family inet {
address 3.3.3.3/32;
}
}
}
}
protocols {
ospf {
area 0.0.0.0 {
interface lo0.2;
interface fxp3.30;
}
}
}
routing-options {
router-id 3.3.3.3;
}
}
}
interfaces {
fxp0 {
unit 0 {
family inet {
address 192.168.200.205/24;
}
}
}
fxp1 {
vlan-tagging;
}
fxp2 {
vlan-tagging;
}
fxp3 {
vlan-tagging;
}
}
routing-options {
static {
route 192.168.0.0/16 {
next-hop 192.168.200.1;
active;
}
}
}
root@Router1 # show
## Last changed: 2008-06-02 21:52:49 UTC
version 8.5R1.14;
system {
host-name Router1;
domain-name mynetwork.com;
backup-router 192.168.15.2;
root-authentication {
encrypted-password "$1$rJIo5b.H$JOjbMEuowTG/IE1lh4Upo0"; ## SECRET-DATA
}
name-server {
192.168.15.3;
}
services {
web-management {
http {
port 80;
}
}
}
syslog {
user * {
any emergency;
}
file messages {
any notice;
authorization info;
}
file interactive-commands {
interactive-commands any;
}
}
}
logical-routers {
R1 {
interfaces {
fxp1 {
unit 10 {
vlan-id 10;
family inet {
address 12.1.1.1/30;
}
}
}
lo0 {
unit 0 {
family inet {
address 1.1.1.1/32;
}
}
}
}
protocols {
ospf {
area 0.0.0.0 {
interface fxp1.10;
interface lo0.0;
}
}
}
routing-options {
router-id 1.1.1.1;
}
}
R2 {
interfaces {
fxp2 {
unit 20 {
vlan-id 10;
family inet {
address 12.1.1.2/30;
}
}
unit 30 {
vlan-id 20;
family inet {
address 23.1.1.2/24;
}
}
}
lo0 {
unit 1 {
family inet {
address 2.2.2.2/32;
}
}
}
}
protocols {
ospf {
area 0.0.0.0 {
interface fxp2.20;
interface lo0.1;
interface fxp2.30;
}
}
}
routing-options {
router-id 2.2.2.2;
}
}
R3 {
interfaces {
fxp3 {
unit 30 {
vlan-id 20;
family inet {
address 23.1.1.3/24;
}
}
}
lo0 {
unit 2 {
family inet {
address 3.3.3.3/32;
}
}
}
}
protocols {
ospf {
area 0.0.0.0 {
interface lo0.2;
interface fxp3.30;
}
}
}
routing-options {
router-id 3.3.3.3;
}
}
}
interfaces {
fxp0 {
unit 0 {
family inet {
address 192.168.200.205/24;
}
}
}
fxp1 {
vlan-tagging;
}
fxp2 {
vlan-tagging;
}
fxp3 {
vlan-tagging;
}
}
routing-options {
static {
route 192.168.0.0/16 {
next-hop 192.168.200.1;
active;
}
}
}
然后在R1上查看路由表看是否学习到OSPF路由:
[edit]
root@Router1 # run show route logical-router R1
root@Router1 # run show route logical-router R1
inet.0: 7 destinations, 7 routes (7 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both
+ = Active Route, - = Last Active, * = Both
1.1.1.1/32 *[Direct/0] 00:27:16
> via lo0.0
2.2.2.2/32 *[OSPF/10] 00:26:27, metric 10
> to 12.1.1.2 via fxp1.10
3.3.3.3/32 *[OSPF/10] 00:13:33, metric 20
> to 12.1.1.2 via fxp1.10
12.1.1.0/30 *[Direct/0] 00:27:16
> via fxp1.10
12.1.1.1/32 *[Local/0] 00:27:16
Local via fxp1.10
23.1.1.0/24 *[OSPF/10] 00:13:38, metric 20
> to 12.1.1.2 via fxp1.10
224.0.0.5/32 *[OSPF/10] 00:27:21, metric 1
MultiRecv
> via lo0.0
2.2.2.2/32 *[OSPF/10] 00:26:27, metric 10
> to 12.1.1.2 via fxp1.10
3.3.3.3/32 *[OSPF/10] 00:13:33, metric 20
> to 12.1.1.2 via fxp1.10
12.1.1.0/30 *[Direct/0] 00:27:16
> via fxp1.10
12.1.1.1/32 *[Local/0] 00:27:16
Local via fxp1.10
23.1.1.0/24 *[OSPF/10] 00:13:38, metric 20
> to 12.1.1.2 via fxp1.10
224.0.0.5/32 *[OSPF/10] 00:27:21, metric 1
MultiRecv
通过ping在R3上测试连通性:
root@Router1
> ping 1.1.1.1 logical-router R3
PING 1.1.1.1 (1.1.1.1): 56 data bytes
64 bytes from 1.1.1.1: icmp_seq=0 ttl=63 time=3.499 ms
64 bytes from 1.1.1.1: icmp_seq=1 ttl=63 time=4.611 ms
64 bytes from 1.1.1.1: icmp_seq=2 ttl=63 time=4.507 ms
64 bytes from 1.1.1.1: icmp_seq=3 ttl=63 time=4.489 ms
^C
--- 1.1.1.1 ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max/stddev = 3.499/4.276/4.611/0.451 ms
PING 1.1.1.1 (1.1.1.1): 56 data bytes
64 bytes from 1.1.1.1: icmp_seq=0 ttl=63 time=3.499 ms
64 bytes from 1.1.1.1: icmp_seq=1 ttl=63 time=4.611 ms
64 bytes from 1.1.1.1: icmp_seq=2 ttl=63 time=4.507 ms
64 bytes from 1.1.1.1: icmp_seq=3 ttl=63 time=4.489 ms
^C
--- 1.1.1.1 ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max/stddev = 3.499/4.276/4.611/0.451 ms
JUNOS的ping个人感觉比较诡异,就是不按Ctrl+C就不会停止,和IOS反差好大,一开始不知道这个键的时候,真是郁闷,ping死了给...
通过show在R2上查看OSPF邻居是否建立:
root@Router1
> show ospf neighbor logical-router R2
Address Interface State ID Pri Dead
12.1.1.1 fxp2.20 Full 1.1.1.1 128 39
23.1.1.3 fxp2.30 Full 3.3.3.3 128 37
Address Interface State ID Pri Dead
12.1.1.1 fxp2.20 Full 1.1.1.1 128 39
23.1.1.3 fxp2.30 Full 3.3.3.3 128 37
转载于:https://blog.51cto.com/steven24/80698