I tried modifying the example. Here is the situation.
No clients, just have my own block of IPs I want to announce (A.A.A.A/22). I
also have two /29s, one from each provider (Y.Y.Y.A/29, Y.Y.Y.B/29) that
contains the external IP address for each of my router's two ethernet
interfaces, as assigned by each ISP. The two providers I'm trying to just run
so one is preferred, but both can be used. The asymetric isn't a huge deal, so
if it's simpler to take it out, that's ok also.
Also, besides the bird setup, I ran the following rules:
ip rule add iif eth2 table 1
ip rule add iif eth5 table 2
(This is on Ubuntu, btw, and my two ISP interfaces are eth2 (my less prefered
one) and eth5 (my high speed 10 Gig fiber one).
The problems / questions I ran into was this.
1) Does the table 1 / table 2 need to be declared in the underlying system
first? I didn't think so, like in /etc/iproute2/rt_tables? Because the IP
rules seemed to work for pinging out on the interface.
2) When I looked at the routing tables, I didn't see all the global routes, so
it didn't seem like I was getting them all pushed to me with that
configuration. The routing table only showed my routes for my interfaces (have
6, actually, 2 ISP the other 4 internal for my network), and the /22 (and I
think the /29s). Is there something wrong with how the bgp protocol sections
are set up with the import all / export all? As the current way before this I
was getting the full BGP tables from provider A.
3) Is the ospf part needed or helpful? Is it a good practice to have the BGP
router also run OSPF, in general?
-----Original Message-----
From: "Ondrej Zajicek" <[email protected]>
Sent: Tuesday, December 6, 2011 7:58am
To: [email protected]
Cc: [email protected]
Subject: Re: Routing issues
On Mon, Dec 05, 2011 at 07:53:03PM -0500, [email protected] wrote:
> Let's say you have two routing tables (T1, T2), one for each interface (eth0,
> eth1), so you can route traffic out each one separately.
>
> https://git.nic.cz/redmine/projects/bird/wiki/BGP_example_2
>
> I'm assuming there would have to be some changes to that BGP script to
> support both routing tables. I'm not sure how to support multiple routing
> tables with bird. Would someone be able to show that? Seems like it would
> be a useful example in general, and be a pretty simple modification to that
> example for someone who knows what they are doing.
>
> I didn't see anything on any of the examples on git.nic.cz that showed using
> multiple tables, as a configuration like
> http://lartc.org/howto/lartc.rpdb.multiple-links.html shows you'd be using
> for multiple outgoing connections, which you would typically have in a BGP
> situation.
>
> Though maybe https://git.nic.cz/redmine/projects/bird/wiki/Policy_routing
> explains it. I plan on keep looking into that example as well.
Yes, that is an example for using multiple routing tables. You can
prefer one uplink in one table and the other in the second table. You
can specify that internal traffic from eth0 go through the first one and
from eth1 through the second one, but:
- The OSPF config (mentioned before) does not automatically split that
traffic, 'cost' work in a different way.
- Even if traffic from eth0 and eth1 is sufficiently splited, that
will hel just split outgoing traffic on uplinks, splitting
incoming is harder.
--
Elen sila lumenn' omentielvo
Ondrej 'SanTiago' Zajicek (email: [email protected])
OpenPGP encrypted e-mails preferred (KeyID 0x11DEADC3, wwwkeys.pgp.net)
"To err is human -- to blame it on a computer is even more so."
log syslog all;
router id A.B.C.D;
define myas = myASN;
define linka = ASN1;
define linkb = ASN2;
define gatewaya = X.X.X.A;
define gatewayb = X.X.X.B;
table ispa;
table ispb;
protocol device
{
scan time 10;
}
protocol static static_bgp {
import all;
route A.A.A.A/22 reject;
route Y.Y.Y.A/29 reject;
route Y.Y.Y.B/29 reject;
}
function net_local()
{
return net ~ [ A.A.A.A/22+ ];
}
# Generic / Helper Functions / filters
function net_martian()
{
return net ~ [ 169.254.0.0/16+, 172.16.0.0/12+, 192.168.0.0/16+, 10.0.0.0/8+,
127.0.0.0/8+, 224.0.0.0/4+, 240.0.0.0/4+, 0.0.0.0/32-, 0.0.0.0/0{25,32},
0.0.0.0/0{0,7} ];
}
function rt_import()
int asn;
int set peer_asns;
prefix set peer_nets;
{
if ! (net ~ peer_nets) then return false;
if ! (bgp_path.last ~ peer_asns) then return false;
if bgp_path.first != asn then return false;
if bgp_path.len > 64 then return false;
if bgp_next_hop != from then return false;
return true;
}
function rt_import_all(int asn)
{
if net_martian() || net_local() then return false;
if bgp_path.first != asn then return false;
if bgp_path.len > 64 then return false;
if bgp_next_hop != from then return false;
return true;
}
function rt_export()
{
if proto = "static_bgp" then return true;
if source != RTS_BGP then return false;
if net_martian() then return false;
if bgp_path.len > 64 then return false;
return bgp_path.first ~ [ myas ];
}
function rt_export_all()
{
if proto = "static_bgp" then return true;
if source != RTS_BGP then return false;
if net_martian() then return false;
if bgp_path.len > 64 then return false;
return true;
}
### End Helper Functions
### BGP uplink A
protocol kernel k_a
{
table ispa;
export all;
kernel table 1;
scan time 15;
}
filter bgp_in_uplink_a
{
if ! rt_import_all(linka) then reject;
accept;
}
filter bgp_out_uplink_a
{
if ! rt_export() then reject;
# Routing policy: penalize routes that other people would
# get to me through isp A
bgp_path.prepend(myas);
bgp_path.prepend(myas);
bgp_path.prepend(myas);
accept;
}
protocol pipe p_a
{
table master;
peer table ispa;
import filter bgp_in_uplink_a;
export filter bgp_out_uplink_a;
}
protocol bgp bgp_a
{
table ispa;
import all;
export all;
local as myas;
neighbor gatewaya as linka;
# Routing policy: make routes from uplinks less prefered
default bgp_local_pref 50;
}
### BGP uplink B
protocol kernel k_b
{
table ispb;
export all;
kernel table 2;
scan time 15;
}
filter bgp_in_uplink_b
{
if ! rt_import_all(linkb) then reject;
accept;
}
filter bgp_out_uplink_b
{
if ! rt_export() then reject;
accept;
}
protocol pipe p_b
{
table master;
peer table ispb;
import filter bgp_in_uplink_b;
export filter bgp_out_uplink_b;
}
protocol bgp bgp_b
{
table ispb;
import all;
export all;
local as myas;
neighbor gatewayb as linkb;
}
protocol static static_ospf {
import all;
route 0.0.0.0/0 reject;
}
protocol ospf {
import all;
export where proto = "static_ospf";
export filter {
ospf_metric1 = 1000;
if source = RTS_STATIC then accept; else reject;
};
area 0 {
interface "eth2" {
cost 200;
type pointopoint;
hello 5; retransmit 2; wait 10; dead 20;
};
interface "eth5" {
cost 5;
type pointopoint;
hello 5; retransmit 2; wait 10; dead 20;
};
interface "*" {
cost 1000;
stub;
};
};
}