Skip to content

Instantly share code, notes, and snippets.

@hkwi
Last active December 4, 2018 07:08
Show Gist options
  • Save hkwi/71bb35226309bb63318c6d2164601a89 to your computer and use it in GitHub Desktop.
Save hkwi/71bb35226309bb63318c6d2164601a89 to your computer and use it in GitHub Desktop.
mpls bgp inter-as asbr without next-hop-self

mpls bgp inter-as asbr

  • without LDP
  • without next-hop-self
  • without loopback
  • with bgp labeled-unicast
  • without route-reflector
  • without multi-hop ebgp
 +----+    +----+
 | r1 |----| r2 |
 +----+    +----+
   |         |
 +----+    +----+
 | r3 |    | r4 |
 +----+    +----+

向こう側が見える前提で組むのであれば、向こう側からのラベルを BGP 経由で通知してもらう(neighbor send-label)ことになる。

from r4

ping vrf A 192.168.3.1

diag

show ip bgp sum
show ip cef vrf A detail
show ip route vrf A
show ip route
show ip mpls forwarding-table

loopback address で LDP は使えない。

r2(config)#int lo 0
r2(config-if)#mpls ip
% MPLS not supported on interface Loopback0
r2(config-if)#mpls bgp forwarding

iBGP で MPLS するには loopback がいいらしい。

%BGP: For distributing MPLS labels to IBGP peers, the update source should be set to a loopback interface

loopback でなくても MPLS は通じる。

loopback があれば ip bgp forwarding は自動的には設定されるが、無い場合は明示的に設定する。

pcap json

tshark -r r1-r3.pcapng -T json -J bgp bgp.type==2 で取り出せる。tshark の json 出力は key が重複しているので、他のツールに接続する際には注意が必要になる。

[
{
"_source": {
"layers": {
"bgp": {
"bgp.update.path_attributes": {
"bgp.update.path_attribute": {
"bgp.update.path_attribute.as_path_segment": {
"bgp.update.path_attribute.as_path_segment.as4": "65000"
}
},
"bgp.update.path_attribute": {
"bgp.update.path_attribute.mp_reach_nlri.afi": "1",
"bgp.update.path_attribute.mp_reach_nlri.afi": "4",
"Next hop network address (4 bytes)": {
"bgp.update.path_attribute.mp_reach_nlri.next_hop": "192.168.0.1"
},
"Network layer reachability information (22 bytes)": {
"Label Stack=3 (bottom) IPv4=192.168.1.0\/24": {
"bgp.prefix_length": "48",
"bgp.label_stack": "3 (bottom)",
"bgp.mp_reach_nlri_ipv4_prefix": "192.168.1.0"
},
"Label Stack=16 (bottom) IPv4=192.168.0.2\/32": {
"bgp.prefix_length": "56",
"bgp.label_stack": "16 (bottom)",
"bgp.mp_reach_nlri_ipv4_prefix": "192.168.0.2"
},
"Label Stack=3 (bottom) IPv4=192.168.0.0\/24": {
"bgp.prefix_length": "48",
"bgp.label_stack": "3 (bottom)",
"bgp.mp_reach_nlri_ipv4_prefix": "192.168.0.0"
}
}
}
}
}
}
}
}
,
{
"_source": {
"layers": {
"bgp": {
"bgp.update.path_attributes": {
"bgp.update.path_attribute": {
"bgp.update.path_attribute.as_path_segment": {
"bgp.update.path_attribute.as_path_segment.as4": "65001"
}
},
"bgp.update.path_attribute": {
"bgp.update.path_attribute.mp_reach_nlri.afi": "1",
"bgp.update.path_attribute.mp_reach_nlri.afi": "4",
"Next hop network address (4 bytes)": {
"bgp.update.path_attribute.mp_reach_nlri.next_hop": "192.168.0.2"
},
"Network layer reachability information (22 bytes)": {
"Label Stack=3 (bottom) IPv4=192.168.2.0\/24": {
"bgp.prefix_length": "48",
"bgp.label_stack": "3 (bottom)",
"bgp.mp_reach_nlri_ipv4_prefix": "192.168.2.0"
},
"Label Stack=16 (bottom) IPv4=192.168.0.1\/32": {
"bgp.prefix_length": "56",
"bgp.label_stack": "16 (bottom)",
"bgp.mp_reach_nlri_ipv4_prefix": "192.168.0.1"
},
"Label Stack=3 (bottom) IPv4=192.168.0.0\/24": {
"bgp.prefix_length": "48",
"bgp.label_stack": "3 (bottom)",
"bgp.mp_reach_nlri_ipv4_prefix": "192.168.0.0"
}
}
}
}
}
}
}
}
,
{
"_source": {
"layers": {
"bgp": {
"bgp.update.path_attributes": {
"bgp.update.path_attribute": {
"bgp.update.path_attribute.as_path_segment": {
"bgp.update.path_attribute.as_path_segment.as4": "65000"
}
},
"bgp.update.path_attribute": {
"bgp.ext_communities": {
"bgp.ext_community": {
"bgp.ext_com.value_as2": "65000",
"bgp.ext_com.value_an4": "100"
}
}
},
"bgp.update.path_attribute": {
"bgp.update.path_attribute.mp_reach_nlri.afi": "1",
"bgp.update.path_attribute.mp_reach_nlri.afi": "128",
"Next hop network address (12 bytes)": {
"bgp.update.path_attribute.mp_reach_nlri.next_hop": "Empty Label Stack RD=0:0 IPv4=192.168.0.1"
},
"Network layer reachability information (15 bytes)": {
"BGP Prefix": {
"bgp.prefix_length": "112",
"bgp.label_stack": "18 (bottom)",
"bgp.rd": "65000:2",
"bgp.mp_reach_nlri_ipv4_prefix": "192.168.3.0"
}
}
}
}
}
}
}
}
,
{
"_source": {
"layers": {
"bgp": {
"bgp.update.path_attributes": {
"bgp.update.path_attribute": {
"bgp.update.path_attribute.as_path_segment": {
"bgp.update.path_attribute.as_path_segment.as4": "65001"
}
},
"bgp.update.path_attribute": {
"bgp.ext_communities": {
"bgp.ext_community": {
"bgp.ext_com.value_as2": "65000",
"bgp.ext_com.value_an4": "100"
}
}
},
"bgp.update.path_attribute": {
"bgp.update.path_attribute.mp_reach_nlri.afi": "1",
"bgp.update.path_attribute.mp_reach_nlri.afi": "128",
"Next hop network address (12 bytes)": {
"bgp.update.path_attribute.mp_reach_nlri.next_hop": "Empty Label Stack RD=0:0 IPv4=192.168.0.2"
},
"Network layer reachability information (15 bytes)": {
"BGP Prefix": {
"bgp.prefix_length": "112",
"bgp.label_stack": "18 (bottom)",
"bgp.rd": "65001:2",
"bgp.mp_reach_nlri_ipv4_prefix": "192.168.4.0"
}
}
}
}
}
}
}
}
]
[
{
"_source": {
"layers": {
"bgp": {
"bgp.update.path_attributes": {
"bgp.update.path_attribute": {
"bgp.update.path_attribute.mp_reach_nlri.afi": "1",
"bgp.update.path_attribute.mp_reach_nlri.afi": "4",
"Next hop network address (4 bytes)": {
"bgp.update.path_attribute.mp_reach_nlri.next_hop": "192.168.1.1"
},
"Network layer reachability information (22 bytes)": {
"Label Stack=3 (bottom) IPv4=192.168.1.0\/24": {
"bgp.prefix_length": "48",
"bgp.label_stack": "3 (bottom)",
"bgp.mp_reach_nlri_ipv4_prefix": "192.168.1.0"
},
"Label Stack=16 (bottom) IPv4=192.168.0.2\/32": {
"bgp.prefix_length": "56",
"bgp.label_stack": "16 (bottom)",
"bgp.mp_reach_nlri_ipv4_prefix": "192.168.0.2"
},
"Label Stack=3 (bottom) IPv4=192.168.0.0\/24": {
"bgp.prefix_length": "48",
"bgp.label_stack": "3 (bottom)",
"bgp.mp_reach_nlri_ipv4_prefix": "192.168.0.0"
}
}
}
}
}
}
}
}
,
{
"_source": {
"layers": {
"bgp": {
"bgp.update.path_attributes": {
"bgp.update.path_attribute": {
"bgp.update.path_attribute.as_path_segment": {
"bgp.update.path_attribute.as_path_segment.as4": "65001"
}
},
"bgp.update.path_attribute": {
"bgp.update.path_attribute.mp_reach_nlri.afi": "1",
"bgp.update.path_attribute.mp_reach_nlri.afi": "4",
"Next hop network address (4 bytes)": {
"bgp.update.path_attribute.mp_reach_nlri.next_hop": "192.168.1.1"
},
"Network layer reachability information (7 bytes)": {
"Label Stack=17 (bottom) IPv4=192.168.2.0\/24": {
"bgp.prefix_length": "48",
"bgp.label_stack": "17 (bottom)",
"bgp.mp_reach_nlri_ipv4_prefix": "192.168.2.0"
}
}
}
}
}
}
}
}
,
{
"_source": {
"layers": {
"bgp": {
"bgp.update.path_attributes": {
"bgp.update.path_attribute": {
"bgp.ext_communities": {
"bgp.ext_community": {
"bgp.ext_com.value_as2": "65000",
"bgp.ext_com.value_an4": "100"
}
}
},
"bgp.update.path_attribute": {
"bgp.update.path_attribute.mp_reach_nlri.afi": "1",
"bgp.update.path_attribute.mp_reach_nlri.afi": "128",
"Next hop network address (12 bytes)": {
"bgp.update.path_attribute.mp_reach_nlri.next_hop": "Empty Label Stack RD=0:0 IPv4=192.168.1.2"
},
"Network layer reachability information (15 bytes)": {
"BGP Prefix": {
"bgp.prefix_length": "112",
"bgp.label_stack": "16 (bottom)",
"bgp.rd": "65000:2",
"bgp.mp_reach_nlri_ipv4_prefix": "192.168.3.0"
}
}
}
}
}
}
}
}
,
{
"_source": {
"layers": {
"bgp": {
"bgp.update.path_attributes": {
"bgp.update.path_attribute": {
"bgp.ext_communities": {
"bgp.ext_community": {
"bgp.ext_com.value_as2": "65000",
"bgp.ext_com.value_an4": "100"
}
}
},
"bgp.update.path_attribute": {
"bgp.update.path_attribute.mp_reach_nlri.afi": "1",
"bgp.update.path_attribute.mp_reach_nlri.afi": "128",
"Next hop network address (12 bytes)": {
"bgp.update.path_attribute.mp_reach_nlri.next_hop": "Empty Label Stack RD=0:0 IPv4=192.168.1.2"
},
"Network layer reachability information (15 bytes)": {
"BGP Prefix": {
"bgp.prefix_length": "112",
"bgp.label_stack": "16 (bottom)",
"bgp.rd": "65000:2",
"bgp.mp_reach_nlri_ipv4_prefix": "192.168.3.0"
}
}
}
}
}
}
}
}
,
{
"_source": {
"layers": {
"bgp": {
"bgp.update.path_attributes": {
"bgp.update.path_attribute": {
"bgp.update.path_attribute.as_path_segment": {
"bgp.update.path_attribute.as_path_segment.as4": "65001"
}
},
"bgp.update.path_attribute": {
"bgp.ext_communities": {
"bgp.ext_community": {
"bgp.ext_com.value_as2": "65000",
"bgp.ext_com.value_an4": "100"
}
}
},
"bgp.update.path_attribute": {
"bgp.update.path_attribute.mp_reach_nlri.afi": "1",
"bgp.update.path_attribute.mp_reach_nlri.afi": "128",
"Next hop network address (12 bytes)": {
"bgp.update.path_attribute.mp_reach_nlri.next_hop": "Empty Label Stack RD=0:0 IPv4=192.168.0.2"
},
"Network layer reachability information (15 bytes)": {
"BGP Prefix": {
"bgp.prefix_length": "112",
"bgp.label_stack": "18 (bottom)",
"bgp.rd": "65001:2",
"bgp.mp_reach_nlri_ipv4_prefix": "192.168.4.0"
}
}
}
}
}
}
}
}
]
version 12.4
ip cef
hostname r1
ip vrf A
rd 65000:1
route-target both 65000:100
interface f 0/0
ip address 192.168.0.1 255.255.255.0
mpls bgp forwarding
no shutdown
interface e 1/0
ip address 192.168.1.1 255.255.255.0
mpls bgp forwarding
no shutdown
router bgp 65000
neighbor 192.168.0.2 remote-as 65001
neighbor 192.168.0.2 send-label
neighbor 192.168.1.2 remote-as 65000
neighbor 192.168.1.2 send-label
redistribute connected
address-family vpnv4
neighbor 192.168.0.2 activate
neighbor 192.168.1.2 activate
end
version 12.4
ip cef
hostname r2
ip vrf A
rd 65001:1
route-target both 65000:100
interface f 0/0
ip address 192.168.0.2 255.255.255.0
mpls bgp forwarding
no shutdown
interface e 1/0
ip address 192.168.2.1 255.255.255.0
mpls bgp forwarding
no shutdown
router bgp 65001
neighbor 192.168.0.1 remote-as 65000
neighbor 192.168.0.1 send-label
neighbor 192.168.2.2 remote-as 65001
neighbor 192.168.2.2 send-label
redistribute connected
address-family vpnv4
neighbor 192.168.0.1 activate
neighbor 192.168.2.2 activate
end
version 12.4
ip cef
hostname r3
ip vrf A
rd 65000:2
route-target both 65000:100
interface e 1/0
ip address 192.168.1.2 255.255.255.0
mpls bgp forwarding
no shutdown
interface e 1/1
ip vrf forwarding A
ip address 192.168.3.1 255.255.255.0
no shutdown
router bgp 65000
neighbor 192.168.1.1 remote-as 65000
neighbor 192.168.1.1 send-label
address-family vpnv4
neighbor 192.168.1.1 activate
address-family ipv4 vrf A
redistribute connected
end
version 12.4
ip cef
hostname r4
ip vrf A
rd 65001:2
route-target both 65000:100
interface e 1/0
ip address 192.168.2.2 255.255.255.0
mpls bgp forwarding
no shutdown
interface e 1/1
ip vrf forwarding A
ip address 192.168.4.1 255.255.255.0
no shutdown
router bgp 65001
neighbor 192.168.2.1 remote-as 65001
neighbor 192.168.2.1 send-label
address-family vpnv4
neighbor 192.168.2.1 activate
address-family ipv4 vrf A
redistribute connected
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment