各位新年快乐
Happy New Year
诸君、新年おめでとうございます!
The abuse of greatness is when it disjoins remorse from power.
开放式最短路径优先(英文Open Shortest Path First,OSPF)是对链路状态路由协议的一种实现,隶属内部网关协议(IGP),故运作于自治系统内部。著名的迪克斯加算法(Dijkstra)被用来计算最短路径树。它使用“成本”作为路由度量。链路状态数据库用网络拓扑来创建,它在区域中的全部路由器上是等价的。
OSPF协议大概是在大型网络上使用最为广泛的IGP(Interior Gateway Protocol)协议。节点在建立邻接,接受连接状态宣告(link-state advertisement)之前,可以通过MD5进行安全验证。
一个OSPF网络可以被划分成更小的网络。其中,一个特别的区域(area)被称为骨干区域(backbone area),该区域是整个OSPF网络的核心区域,并且所有其他的区域都与之连接。所有的内部路由都通过骨干区域。所有的区域都必须连接到骨干区域,如果 不能建立直接连接,那么可以通过虚拟通道建立虚拟连接(virtual link)。
同一个广播域(broadcast domain)的路由器或者一个点对点(point to point)连接的两端的路由器,在发现彼此的时候,建立邻接(adjacencies)[1]。 同一广播网络或者模拟广播网络的点对点网络中的路由器会选举指定路由器(designated router, DR)和备份指定路由器(backup designated router, BDR),DR和BDR作为网络的中心负责路由器之间的信息交换从而降低了网络中的信息流量。OSPF协议同时使用单播(unicast)和多播(multicast)来发送Hello包和连接状态更新(link state updates),使用的多播地址为224.0.0.5和224.0.0.6。与RIP和BGP不同的是,OSPF协议不使用TCP或者UDP协议而是直接使用IP协议。
root@bearice-ubuntu-server:~# ifconfig
eth1 Link encap:Ethernet HWaddr 00:40:45:0e:52:12
inet addr:172.21.204.65 Bcast:172.21.204.255 Mask:255.255.255.0
inet6 addr: fe80::240:45ff:fe0e:5212/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2162021 errors:0 dropped:940 overruns:0 frame:0
TX packets:669879 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:196472110 (187.3 MB) TX bytes:565933427 (539.7 MB)
Interrupt:11 Base address:0x6e00
eth2 Link encap:Ethernet HWaddr 00:00:21:0e:22:f6
inet addr:192.168.100.200 Bcast:192.168.100.255 Mask:255.255.255.0
inet6 addr: fe80::200:21ff:fe0e:22f6/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1809604 errors:0 dropped:0 overruns:0 frame:127
TX packets:406894 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:153446129 (146.3 MB) TX bytes:323207532 (308.2 MB)
Interrupt:3 Base address:0x300
! /etc/quagga/zerba.conf
! Zebra configuration saved from vty
! 2008/12/18 00:19:21
!
hostname Bearice-Zebra-Router
password goodpassword
enable password goodpassword
!
interface eth1
ipv6 nd suppress-ra
!
interface eth2
ipv6 nd suppress-ra
!
interface lo
!
ip forwarding
!
!
line vty
!
! /etc/quagga/ospfd.conf
! Zebra configuration saved from vty
! 2008/12/18 00:19:21
!
hostname Bearice-OSPF-Router
password goodpassword
enable password goodpassword
!
!
!
interface eth1
!
interface eth2
!
interface lo
!
router ospf
ospf router-id 172.21.204.65
network 172.21.204.0/24 area 0.2.0.0
network 192.168.100.0/24 area 0.2.0.0
area 0.2.0.0 stub
!
line vty
!
root@bearice-ubuntu-server:~# telnet 0 2604
Trying 0.0.0.0...
Connected to 0.
Escape character is '^]'.
Hello, this is Quagga (version 0.99.9).
Copyright 1996-2005 Kunihiro Ishiguro, et al.
User Access Verification
Password:
Bearice-OSPF-Router> en
Password:
Bearice-OSPF-Router# sh ip os ne
Neighbor ID Pri State Dead Time Address Interface RXmtL RqstL DBsmL
172.16.7.3 1 Full/DR 31.559s 172.21.204.254 eth1:172.21.204.65 0 0 0
Bearice-OSPF-Router#
root@bearice-ubuntu-server:~# nslookup www.baidu.com
Server: 202.103.224.68
Address: 202.103.224.68#53
Non-authoritative answer:
www.baidu.com canonical name = www.a.shifen.com.
Name: www.a.shifen.com
Address: 121.14.88.14
Name: www.a.shifen.com
Address: 121.14.89.14
auto eth2:3
iface eth2:3 inet static
address 121.14.89.14
netmask 255.255.255.255
auto eth2:4
iface eth2:4 inet static
address 121.14.88.14
netmask 255.255.255.255
root@bearice-ubuntu-server:~# telnet 0 2604
Trying 0.0.0.0...
Connected to 0.
Escape character is '^]'.
Hello, this is Quagga (version 0.99.9).
Copyright 1996-2005 Kunihiro Ishiguro, et al.
User Access Verification
Password:
Bearice-OSPF-Router> en
Password:
Bearice-OSPF-Router#
Bearice-OSPF-Router# con
Bearice-OSPF-Router# configure
Bearice-OSPF-Router# configure terminal
Bearice-OSPF-Router(config)# rout
Bearice-OSPF-Router(config)# router o
Bearice-OSPF-Router(config)# router ospf
Bearice-OSPF-Router(config-router)# network 121.14.88.14/32 ar
Bearice-OSPF-Router(config-router)# network 121.14.88.14/32 area 0.2.0.0
Bearice-OSPF-Router(config-router)# network 121.14.89.14/32 area 0.2.0.0
C:\Users\Bearice>tracert 121.14.89.14
通过最多 30 个跃点跟踪到 121.14.89.14 的路由
1 1 ms 1 ms 1 ms 172.21.204.254
2 1 ms 1 ms 1 ms 172.16.7.254
3 2 ms 5 ms 9 ms 10.4.0.1
4 1 ms 1 ms 1 ms 219.159.104.129
5 2 ms 2 ms 2 ms 218.65.144.129
6 * * 16 ms 218.65.144.5
7 * 6 ms 6 ms 202.97.66.113
8 11 ms 12 ms 14 ms 202.97.66.125
9 24 ms 24 ms 25 ms 202.97.21.130
10 24 ms 23 ms 23 ms 202.97.44.9
11 28 ms 35 ms 35 ms 202.97.25.197
12 <1>tracert 121.14.89.14
通过最多 30 个跃点跟踪到 121.14.89.14 的路由
1 1 ms 1 ms 1 ms 172.21.204.254
2 <1>