Naked BGP
Naked BGP
Naked BGP
Thomas Mangin
Exa Networks Limited
UKNOF 15
Who reads RFCs ?
Desperate network engineers
why is that session stuck in ACTIVE
why are my routers now crashing (ASN4)
Bleeding edge engineers
what is FlowSpec ?
Curious Engineers
what if I changed the HoldTime value to 3 ??
MAD people
wanting to write their own software I am here ..
mostly SIP developers nowdays
A new application why ?
Announce our service IP (/32)
SMTP, MX, POP, IMAP, WEBMAIL, AUTH DNS, ...
Others exist but ....
OpenBGPD great but no official support on Linux
BIRD good but no package for all our Linux distros
Quagga Cisco configuration format (pain)
bgpfeeder, bgpsimple, pybgp no IPv6
Wanted ....
easy installation (python always installed, nothing else needed)
familiar and simple configuration
integrate with our code base (suspension, IWF filtering, etc.)
BGP4 Main RFCs
RFC 4271
A Border Gateway Protocol 4 (BGP-4)
Obsoletes: 1771
RFC 5492
Capabilities Advertisement with BGP-4
Obsoletes: 3392, 2842
RFC 2385
Protection of BGP Sessions via the TCP MD5 Signature
I can't implement it, the Python socket module does not
export TCP_MD5_AUTH
BGP4 Common RFCs
RFC 3107
Carrying Label Information in BGP-4
RFC 4893
BGP Support for Four-octet AS Number Space
BGP4 Less common RFCs
RFC 4724
Graceful Restart Mechanism for BGP
RFC 4360
BGP Extended Communities Attribute
RFC 5575
Dissemination of Flow Specification Rules
Graceful Restart
let the speaker know
if the session is from a restart
how long to wait before dropping stale routes
AFI/SAFI for which GR is supported
OPEN parsed
OPEN Message
Marker: 16 bytes
Length: 45 bytes
Type: OPEN Message (1)
Version: 4
My AS: 100
Hold time: 180
BGP identifier: 1.1.1.1
Optional parameters length: 16 bytes
Optional parameters
Capabilities Advertisement (8 bytes)
Parameter type: Capabilities (2)
Parameter length: 6 bytes
Multiprotocol extensions capability (6 bytes)
Capability code: Multiprotocol extensions capability (1)
Capability length: 4 bytes
Capability value
Address family identifier: IPv4 (1)
Reserved: 1 byte
Subsequent address family identifier: Unicast (1)
Capabilities Advertisement (4 bytes)
Parameter type: Capabilities (2)
Parameter length: 2 bytes
Route refresh capability (2 bytes)
Capability code: Route refresh capability (128)
Capability length: 0 bytes
Capabilities Advertisement (4 bytes)
Parameter type: Capabilities (2)
Parameter length: 2 bytes
Route refresh capability (2 bytes)
Capability code: Route refresh capability (2)
Capability length: 0 bytes
NOTIFICATION
Format
Error code 1 byte
Error subcode 1 byte
Data variable
Error codes
1 Message header error 4 Hold timer expired
2 OPEN message error 5 State machine error
3 UPDATE message error 6 Cease
Space efficient
Maximum message size is 4096
NLRI
Network Layer Reachability Information
Fancy RFC name for a prefix
Netmask as a character => /32 byte of value 32
Followed by only the necessary bytes of the IP address
Examples
10.0.0.0/8 0x08 0x10
192.0.2.0/24 0x18 0xC0 0x00 0x02
192.0.2.1/29 0x1D 0xC0 0x00 0x02 0x01
0.0.0.0/0 0x00
Path Attributes
Store routes meta-data
Transitive : Router must relay the Attribute
Unknown Transitive SHOULD be accepted
Unknown non-transitive MUST be ignored
Optional : Understanding of this attribute is optional
Mandatory : Must be present (or Discretionary)
Well known MUST be transitive
MUST be supported by every implementation
Partial : Do we know this attribute
Once set as unknown the value stays set
Every route in the path can add some optional transitive attribute
Well Known Attributes (minimum implementation)
Mandatory ORIGIN, AS_PATH, NEXT_HOP
Discretionary LOCAL_PREF, ATOMIC_AGGREGATE
Path Attributes
Best known attributes
CODE NAME FLAGS Number Other
0x01 ORIGIN Mandatory, Transitive Unique
0x02 AS-PATH Mandatory, Transitive Unique
0x03 NEXT_HOP Mandatory, Transitive Unique
0x04 MED Optional Unique EBGP only
0x05 LOCALPREF Discretionary,Transitive Unique IBGP only
0x06 ATOMIC_AGGREGATE Discretionary, Transitive
0x07 AGGREGATOR Optional Unique
0x08 COMMUNITIES Optional,Transitive Unique
0x09 ORGINATOR_ID, 0x0A CLUSTER_LIST
0x0E MP REACH NLRI Optional,Transitive Multiple
0x0F MP UNREACH NLRI Optional,Transitive Multiple
What is a flow ?
new NLRI (like IPv6, MPLS, VPLS, )
but not a route more a firewall match condition
AFI 1, SAFI 133 for internet trafic
AFI 1, SAFI 134 for MPLS traffic
validated against corresponding unicast routing table
build with components
Why use it ?
handle DDOS with ASIC accelerated routers
throttle protocols
redirect selected type of traffic
RFC 5575 / Flow Spec
Possible components making the flow
Prefix (source and destination)
IP Protocol (list of <action, value>)
end of list, AND, LEN, less than, more than, equal
allow to express a port range, ie > 6880 and < 6890
Port (source, destination, either)
ICMP (type, code)
TCP flag (list of <action, value>)
end of list, AND, LEN, NOT, match (set or unset)
Packet Len
DSCP
Fragment
Don't Fragment, Is Fragment, First Fragment, Last Fragment
Format
the RFC includes some example packets
and how to decode them in the RFC :D
RFC 5575 / Flow Spec
Filtering actions
Use communities (your network, your choice)
Normal or extended
No convention but a small set of extended communities
See RFC 4360
0x8006 traffic-rate 2-byte as#, 4-byte float
0x8007 traffic-action bitmask
0x47 Terminal Filtering Action
0x46 Sample and Log for this NLRI
0x45-0x00 Reserved / Undefined
0x8008 redirect 6-byte Route Target
0x8009 traffic-marking DSCP value
Variation between vendors
Pretty clear and well followed RFC
make reading SIP RFC painful
no major variation noted
Malformed Packets
Quagga and Cisco accept wrong Attribute Flag for Well
Known Attributes (like with wrong Transitivity)
Juniper refuse and send you some obscure
NOTIFICATION (my fault in the first instance)
Not many differences
CISCO_ROUTE_REFRESH and ROUTE_REFRESH
Cisco extra KEEPALIVE as EOR
Extra KEEPALIVE
Sequence of messages
OPEN
OPEN
KEEPALIVE
KEEPALIVE (end of OPEN sequence)
KEEPALIVE (as no update / EOR ?)
KEEPALIVE (used as EOR / Normal KA ?)
Normal usage of KEEPALIVE
Not in any RFC
BGP route injector
Usage
initially for ASN 112 annoucement
now to announce all customer facing IPs (/32)
for both IPv4 and IPv6
Replaced some LVS and Wackamole
Graceful Restart allows for
for service on one machine only
restart the daemon without flap on config change
reboot machine without causing any routing change
A low hold-time allows to:
rapid fail-over to a active backup machine
BGP route injector
Juniper do not like gratuitous ARP
disabling it is a security risk
behaviour may only be changed per interface, not VLAN
causes issues with most failover systems client side
not able to announce /32 or /128 using ARP broadcast
static {
route 192.175.48.0/25 {
next-hop 192.0.2.1;
med 100;
community [ 64511:30740 64511:0 ];
}
route 192.175.48.128/25 next-hop 192.0.2.2 community 0x101;
}
}
The program itself
No dependencies
No need to run as root (does not bind)
Single threaded with co-routine
Recommend the issue of daemontools for
supervision
In production in our network for a few months
QUESTIONS ??
Answers :
# urpmi bird
To satisfy dependencies, the following packages are going to be installed:
Package Version Release Arch
(medium "contrib")
libquagga0 0.99.7 2mdv2008.0 i586
quagga 0.99.7 2mdv2008.0 i586
3.7MB of additional disk space will be used.
Proceed with the installation of the 2 packages? (Y/n) n