From owner-freebsd-net@FreeBSD.ORG  Wed Feb  6 14:56:51 2008
Return-Path: <owner-freebsd-net@FreeBSD.ORG>
Delivered-To: freebsd-net@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 954EA16A41B
	for <freebsd-net@freebsd.org>; Wed,  6 Feb 2008 14:56:51 +0000 (UTC)
	(envelope-from jp@tns.cz)
Received: from bns.tns.cz (bns.tns.cz [213.194.214.115])
	by mx1.freebsd.org (Postfix) with ESMTP id D264813C457
	for <freebsd-net@freebsd.org>; Wed,  6 Feb 2008 14:56:50 +0000 (UTC)
	(envelope-from jp@tns.cz)
Received: from bns.tns.cz (localhost [127.0.0.1])
	by bns.tns.cz (Postfix) with ESMTP id 820CD55E4E9
	for <freebsd-net@freebsd.org>; Wed,  6 Feb 2008 15:40:33 +0100 (CET)
Received: from bonifac.tns.cz (bertik [192.168.144.14])
	by bns.tns.cz with ESMTP id 4FAE6T40014IUYQD0MR;
	Wed, 6 Feb 2008 15:40:33 +0100 (CET)
Received: by bonifac.tns.cz (Postfix, from userid 1001)
	id C8886F19AF; Wed,  6 Feb 2008 15:41:04 +0100 (CET)
Date: Wed, 6 Feb 2008 15:41:04 +0100
From: Josef Pojsl <jp@tns.cz>
To: freebsd-net@freebsd.org
Message-ID: <20080206144104.GL1122@bonifac.tns.cz>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.5.16 (2007-06-09)
Subject: ospf cost and route selection (openospfd)
X-BeenThere: freebsd-net@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Networking and TCP/IP with FreeBSD <freebsd-net.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-net>,
	<mailto:freebsd-net-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-net>
List-Post: <mailto:freebsd-net@freebsd.org>
List-Help: <mailto:freebsd-net-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-net>,
	<mailto:freebsd-net-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Wed, 06 Feb 2008 14:56:51 -0000

Hello,

I am trying to use openospfd 4.0 over FreeBSD 6.2 in order
to provide redundancy for routing between LAN 1 and LAN 2.
The picture is as follows:


Locality 1 (LAN 1)                 Locality 2 (LAN 2)
                   WAN X
           ------------------------
 Router 1          WAN Y            Router 2
           ------------------------

Router 1 is connected to LAN 1 on one side
and to two WANs, X and Y, on the other side.
The same holds for Router 2, it is connected
to LAN 2, WAN X and WAN Y.

There are gre tunnels between the routers
over both WAN X and WAN Y. These tunnels get
encrypted with IPsec transport.

I have configured openospfd over both gre interfaces.
The preferred link that I would like to be used for routing
of LANs is the gre tunnel between 1 and 2 over WAN X.
The cost of that link is the least of both costs.
But, openospfd converges with routing between 1 and 2
over WAN Y, not WAN X. I have no clue why.

LAN 1 is 192.168.1.0/24, LAN 2 is 192.168.2.0/24.

gre30 is the link over WAN X, gre31 over WAN Y. 10.10.0.0/16 is WAN X,
10.20.0.0/16 is WAN Y.

Configuration of gre tunnels:
Router 1:
gre30: flags=b051<UP,POINTOPOINT,RUNNING,LINK0,LINK1,MULTICAST> mtu 1476
        tunnel inet 10.10.1.2 --> 10.10.2.2
        inet 10.30.1.2 --> 10.30.2.2 netmask 0xffffff00 
gre31: flags=b051<UP,POINTOPOINT,RUNNING,LINK0,LINK1,MULTICAST> mtu 1476
        tunnel inet 10.20.1.2 --> 10.20.2.2
        inet 10.31.1.2 --> 10.31.2.2 netmask 0xffffff00 

Router 2:
gre30: flags=b051<UP,POINTOPOINT,RUNNING,LINK0,LINK1,MULTICAST> mtu 1476
        tunnel inet 10.10.2.2 --> 10.10.1.2
        inet 10.30.2.2 --> 10.30.1.2 netmask 0xffffff00 
gre31: flags=b051<UP,POINTOPOINT,RUNNING,LINK0,LINK1,MULTICAST> mtu 1476
        tunnel inet 10.20.2.2 --> 10.20.1.2
        inet 10.31.2.2 --> 10.31.1.2 netmask 0xffffff00

Configuration of openospfd:
Router 1:
router-id 0.0.0.1
redistribute connected

area 0.0.0.0 {
    interface gre30 {
        metric 20
    }
    interface gre31 {
        metric 50
    }
}

Router 2:
router-id 0.0.0.2
redistribute connected

area 0.0.0.0 {
    interface gre30 {
        metric 20
    }
    interface gre31 {
        metric 50
    }
}

ospfctl show rib:
Router 1:
Destination          Nexthop           Path Type    Type      Cost    Uptime  
0.0.0.2              10.31.2.2         Intra-Area   Router    20      00:03:51
10.30.1.2/32         10.31.2.2         Intra-Area   Network   40      00:03:41
10.31.1.2/32         10.31.2.2         Intra-Area   Network   70      00:03:51
10.10.0.0/16         10.31.2.2         Type 1 ext   Network   120     00:03:51
10.20.0.0/16         10.31.2.2         Type 1 ext   Network   120     00:03:51
192.168.2.0/24       10.31.2.2         Type 1 ext   Network   120     00:03:51

Router 2:
Destination          Nexthop           Path Type    Type      Cost    Uptime  
0.0.0.1              10.31.1.2         Intra-Area   Router    20      00:04:51
10.30.2.2/32         10.31.1.2         Intra-Area   Network   40      00:04:44
10.31.2.2/32         10.31.1.2         Intra-Area   Network   70      00:04:51
10.10.0.0/16         10.31.1.2         Type 1 ext   Network   120     00:04:51
10.20.0.0/16         10.31.1.2         Type 1 ext   Network   120     00:04:51
192.168.1.0/24       10.31.1.2         Type 1 ext   Network   120     00:04:51

ospfctl show interface detail:
Router 1:
Interface gre31, line protocol is UP
  Internet address 10.31.1.2/24, Area 0.0.0.0
  Linkstate unknown
  Router ID 0.0.0.1, network type POINTOPOINT, cost: 50
  Transmit delay is 1 sec(s), state P2P, priority 1
  Designated Router (ID) 0.0.0.0, interface address 0.0.0.0
  Backup Designated Router (ID) 0.0.0.0, interface address 0.0.0.0
  Timer intervals configured, hello 10, dead 40, wait 40, retransmit 5
    Hello timer due in 00:00:06
    Uptime 00:06:04
  Neighbor count is 1, adjacent neighbor count is 1

Interface gre30, line protocol is UP
  Internet address 10.30.1.2/24, Area 0.0.0.0
  Linkstate unknown
  Router ID 0.0.0.1, network type POINTOPOINT, cost: 20
  Transmit delay is 1 sec(s), state P2P, priority 1
  Designated Router (ID) 0.0.0.0, interface address 0.0.0.0
  Backup Designated Router (ID) 0.0.0.0, interface address 0.0.0.0
  Timer intervals configured, hello 10, dead 40, wait 40, retransmit 5
    Hello timer due in 00:00:06
    Uptime 00:06:04
  Neighbor count is 1, adjacent neighbor count is 1

Router 2:
Interface gre31, line protocol is UP
  Internet address 10.31.2.2/24, Area 0.0.0.0
  Linkstate unknown
  Router ID 0.0.0.2, network type POINTOPOINT, cost: 50
  Transmit delay is 1 sec(s), state P2P, priority 1
  Designated Router (ID) 0.0.0.0, interface address 0.0.0.0
  Backup Designated Router (ID) 0.0.0.0, interface address 0.0.0.0
  Timer intervals configured, hello 10, dead 40, wait 40, retransmit 5
    Hello timer due in 00:00:09
    Uptime 00:06:02
  Neighbor count is 1, adjacent neighbor count is 1

Interface gre30, line protocol is UP
  Internet address 10.30.2.2/24, Area 0.0.0.0
  Linkstate unknown
  Router ID 0.0.0.2, network type POINTOPOINT, cost: 20
  Transmit delay is 1 sec(s), state P2P, priority 1
  Designated Router (ID) 0.0.0.0, interface address 0.0.0.0
  Backup Designated Router (ID) 0.0.0.0, interface address 0.0.0.0
  Timer intervals configured, hello 10, dead 40, wait 40, retransmit 5
    Hello timer due in 00:00:09
    Uptime 00:06:02
  Neighbor count is 1, adjacent neighbor count is 1

Why the LANs get routed over gre31, having cost 50, and not over gre30
with lower cost 20? Has anybody got any clue?

Thanks in advance for any comments,
--
Josef Pojsl