ネットワーク備忘録

アラフォーエンジニアのネットワーク系の備忘録。twitter:@deigo25374582

JUNOS_BGP2

引き続きBGP復習

構成は↓

f:id:klock_3rd:20181022221222p:plain

R1・・・AS1
R2,R3・・・AS2

前回と違いR1----R2間はOSPFは削除

 R1

router bgp 1
bgp router-id 1.1.1.1
bgp log-neighbor-changes
neighbor 10.1.1.254 remote-as 2
!
address-family ipv4
neighbor 10.1.1.254 activate
neighbor 10.1.1.254 soft-reconfiguration inbound
exit-address-family

 R2

router bgp 2
bgp router-id 2.2.2.2
bgp log-neighbor-changes
neighbor 3.3.3.3 remote-as 2
neighbor 3.3.3.3 update-source Loopback0
neighbor 10.1.1.1 remote-as 1
!
address-family ipv4
neighbor 3.3.3.3 activate
neighbor 3.3.3.3 soft-reconfiguration inbound
neighbor 10.1.1.1 activate
neighbor 10.1.1.1 soft-reconfiguration inbound
exit-address-family 

 R3

router bgp 2
bgp router-id 3.3.3.3
bgp log-neighbor-changes
neighbor 2.2.2.2 remote-as 2
neighbor 2.2.2.2 update-source Loopback0
!
address-family ipv4
neighbor 2.2.2.2 activate
neighbor 2.2.2.2 soft-reconfiguration inbound
exit-address-family 

 

R1のLoop0をBGPで広告

R1

interface Loopback0
ip address 1.1.1.1 255.255.255.255
!
router bgp 1
bgp router-id 1.1.1.1
bgp log-neighbor-changes
neighbor 10.1.1.254 remote-as 2
!
address-family ipv4
network 1.1.1.1 mask 255.255.255.255
neighbor 10.1.1.254 activate
neighbor 10.1.1.254 soft-reconfiguration inbound
exit-address-family

 R2で確認

R2#show bgp ipv4 unicast neighbors 10.1.1.1 received-routes
BGP table version is 2, local router ID is 2.2.2.2

   Network     Next Hop      Metric LocPrf Weight Path
*> 1.1.1.1/32    10.1.1.1         0       0 1 i

 

R2#show ip route bgp

Gateway of last resort is not set

   1.0.0.0/32 is subnetted, 1 subnets
B    1.1.1.1 [20/0] via 10.1.1.1, 00:04:42

R3で確認

R3#show bgp ipv4 unicast neighbors 2.2.2.2 received-routes
BGP table version is 1, local router ID is 3.3.3.3

   Network     Next Hop      Metric LocPrf Weight Path
* i 1.1.1.1/32    10.1.1.1         0  100   0 1 i

 

R3#show ip route bgp

Gateway of last resort is not set

R3#

 R3は1.1.1.1の経路を受け取っているけど、Next-HopがR1のままなのでRoutingテーブルには乗らない。 これはR2を直せば解決

R2

router bgp 2
bgp router-id 2.2.2.2
bgp log-neighbor-changes
neighbor 3.3.3.3 remote-as 2
neighbor 3.3.3.3 update-source Loopback0
neighbor 10.1.1.1 remote-as 1
!
address-family ipv4
neighbor 3.3.3.3 activate
neighbor 3.3.3.3 next-hop-self
neighbor 3.3.3.3 soft-reconfiguration inbound
neighbor 10.1.1.1 activate
neighbor 10.1.1.1 soft-reconfiguration inbound
exit-address-family 

 R3で確認

R3#show bgp
BGP table version is 2, local router ID is 3.3.3.3

   Network     Next Hop      Metric LocPrf Weight Path
*>i 1.1.1.1/32    2.2.2.2         0  100   0 1 i

 ちなみに、R2の設定はそのままで、R3でLo0をBGPで広告してもR1はeBGPなので問題なし

R1で確認

R1#show bgp
BGP table version is 13, local router ID is 1.1.1.1

   Network     Next Hop      Metric LocPrf Weight Path
*> 1.1.1.1/32    0.0.0.0         0     32768 i
*> 3.3.3.3/32    10.1.1.254               0 2 i
R1#

 

・・・こっから本題
同じ流れをJUNOSでやる

R1

set routing-options router-id 1.1.1.1
set routing-options autonomous-system 1
set protocols bgp group EBGP type external
set protocols bgp group EBGP peer-as 2
set protocols bgp group EBGP neighbor 10.1.1.2544 

 R2

set routing-options router-id 2.2.2.2
set routing-options autonomous-system 2
set protocols bgp group EBGP type external
set protocols bgp group EBGP peer-as 1
set protocols bgp group EBGP neighbor 10.1.1.1
set protocols bgp group IBGP type internal
set protocols bgp group IBGP local-address 2.2.2.2
set protocols bgp group IBGP neighbor 3.3.3.3

 R3

set routing-options router-id 3.3.3.3
set routing-options autonomous-system 2
set protocols bgp group IBGP type internal
set protocols bgp group IBGP local-address 3.3.3.3
set protocols bgp group IBGP neighbor 2.2.2.2

 R1のLoopbackをeBGPで広告

R1

set routing-options router-id 1.1.1.1
set routing-options autonomous-system 1
set protocols bgp group EBGP type external
set protocols bgp group EBGP export to-eBGP
set protocols bgp group EBGP peer-as 2
set protocols bgp group EBGP neighbor 10.1.1.254
set policy-options policy-statement to-eBGP term 1 from route-filter 1.1.1.1/32 exact
set policy-options policy-statement to-eBGP term 1 then accept 

 →Ciscoの「Network」コマンドに相当するのが、青字

R2確認

admin@R2# run show route protocol bgp

inet.0: 10 destinations, 10 routes (10 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

1.1.1.1/32   *[BGP/170] 00:21:56, localpref 100
         AS path: 1 I, validation-state: unverified
        > to 10.1.1.1 via ge-0/0/0.0

 R3は当然・・・

admin@R3# run show route protocol bgp

inet.0: 8 destinations, 8 routes (7 active, 0 holddown, 1 hidden)

inet6.0: 1 destinations, 1 routes (1 active, 0 holddown, 0 hidden)

Cisco同様R2でNext-hopを入れる

R2

set routing-options router-id 2.2.2.2
set routing-options autonomous-system 2
set protocols bgp group EBGP type external
set protocols bgp group EBGP peer-as 1
set protocols bgp group EBGP neighbor 10.1.1.1
set protocols bgp group IBGP type internal
set protocols bgp group IBGP local-address 2.2.2.2
set protocols bgp group IBGP export to-iBGP
set protocols bgp group IBGP neighbor 3.3.3.3
set policy-options policy-statement to-iBGP term 1 from protocol bgp
set policy-options policy-statement to-iBGP term 1 from route-type external
set policy-options policy-statement to-iBGP term 1 then next-hop self

→青字がCiscoのNext-hop-selfと同じ。
JUNOSはPolicyステートメントで定義する必要があり。

R3確認

admin@R3# run show route receive-protocol bgp 2.2.2.2

inet.0: 8 destinations, 8 routes (8 active, 0 holddown, 0 hidden)
 Prefix     Nexthop   MED   Lclpref  AS path
* 1.1.1.1/32   2.2.2.2       100    1 I

 

admin@R3# run show route protocol bgp

inet.0: 8 destinations, 8 routes (8 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

1.1.1.1/32  *[BGP/170] 00:04:56, localpref 100, from 2.2.2.2
        AS path: 1 I, validation-state: unverified
       > to 10.1.2.1 via ge-0/0/1.0

 

ちなみに、R2が上のままで、R3でLo0をiBGPで広告すると・・・

R1確認

admin@R2# run show route receive-protocol bgp 3.3.3.3

inet.0: 10 destinations, 11 routes (10 active, 0 holddown, 0 hidden)
 Prefix     Nexthop   MED   Lclpref  AS path
 3.3.3.3/32   3.3.3.3       100    I


admin@R2# run show route advertising-protocol bgp 10.1.1.1

[edit]

 →Ciscoと違い「3.3.3.3」の経路広告しない。 Cisco同様にするには以下
R2

set routing-options router-id 2.2.2.2
set routing-options autonomous-system 2
set protocols bgp group EBGP type external
set protocols bgp group EBGP advertise-inactive
set protocols bgp group EBGP peer-as 1
set protocols bgp group EBGP neighbor 10.1.1.1
set protocols bgp group IBGP type internal
set protocols bgp group IBGP local-address 2.2.2.2
set protocols bgp group IBGP export to-iBGP
set protocols bgp group IBGP neighbor 3.3.3.3
set policy-options policy-statement to-iBGP term 1 from protocol bgp
set policy-options policy-statement to-iBGP term 1 from route-type external
set policy-options policy-statement to-iBGP term 1 then next-hop self 

R1確認

 

admin@R1# run show route receive-protocol bgp 10.1.1.254

inet.0: 6 destinations, 6 routes (6 active, 0 holddown, 0 hidden)
 Prefix     Nexthop    MED   Lclpref  AS path
* 3.3.3.3/32   10.1.1.254            2 I

 

admin@R1# run show route protocol bgp


3.3.3.3/32   *[BGP/170] 00:07:08, localpref 100
         AS path: 2 I, validation-state: unverified
        > to 10.1.1.254 via ge-0/0/0.0

 

 

このやり方、面倒臭くなってきた。