Saturday, April 18, 2015

Step 2 - Local Preferenc (Highest) ( 13 step selection route BGP)

2- Local Preferenc (Highest)
2.1 overview.
+ Giá trị càng cao càng ưu tiên
+ Local preferenc chỉ sử dụng trong 1 AS.
+ có thể áp dụng route-map  theo chiều out hoặc in                      //in trong cùng 1 As hoặc AS theo chiều inbound từ AS khác, out chỉ áp        dụng trong 1 AS)
+ route not match route-map by discard
+ mặc định local-prefer = 100
2.2 command modify:
+ neighbor {ip} [weight]
+ route-map
2.3 Test.

+ R2 thiết lập iBGP với R6, R3
+ R2 thiết lập eBGP với R4

+ Advertise L0: 8.8.8.0/24 trên R6, R4, R3 vào network.

=> R2 học 8.8.8.0/24 qua R3 là best .
Chúng ta đi kiểm tra từng bước sau:
  1. Weight: bằng nhau
  2. Local prefer: bằng nhau
  3. Perfer the path was locally..: bằng nhau
  1. AS-path: R3 vs R6 bằng nhau (tới đây bỏ qua xét R4)
  1. Origin type : bằng nhau
  1. Med: bằng nhau
  2. Prefer eBGP over iBGP: R3 vs R6 cùng AS = 200
  3. Prefer with lowes IGP metric to BGP next-hop : bằng nhau
  1. Không xét ở đây.
  1. The path are external: cùng học iBGP
  2. Lown router-id : BREAK. R3 có giá trị router-id 3.3.3.3 < R6 = 6.6.6.6

- Modify giá trị local preference sao cho R2 chọn R6 như là best path tới 8.8.8.0/24
 có 2 cách:
+ sử dụng bgp default local-preference
+ sử dụng route-map

Cách 1: bgp default local-preference
Command "bgp default local-prefer" được quảng bá ở dạng outgoing only, có nghĩa là router được cấu hình lệnh này sẽ quảng bá local-prefer sang các neighbor.
=> để R2 chọn R6 là next-hop để đến mạng 8.8.8.0/24 thì ta phải điều chỉnh giá trị local-prefer trên R6.
Config R6:
#router bgp 200
  #bgp default local-prefer 200
Cách 2: sử dụng route-map
Khi sử dụng route-map có thể áp dụng theo chiều out hoặc in sao cho tuân thủ theo nguyên tắc giá trị local-prefer chỉ trong AS.
Config R6:
#access-list 1 permit 8.8.8.0/24
#route-map TST permit 10
#math ip address 1
#set local-preference 200
#route-map TST permit 20   // modify route not match route-map will be discard
#router bgp 200
#neighbor 10.1.26.2 route-map TST out
Hoặc config R2 (theo chiều in):

#access-list 1 permit 8.8.8.0/24
#route-map TST permit 10
#math ip address 1
#set local-preference 200
#route-map TST permit 20  
#router bgp 200
#neighbor 10.1.26.6 route-map TST in

- Modify giá trị local preference sao cho R2 chọn R4 như là best path tới 8.8.8.0/24
Config R2 (chỉ áp dụng theo chiều in trên R2, bởi vì local-prefer chỉ có giá trị trong AS)
#access-list 1 permit 8.8.8.0/24
#route-map TST permit 10
#math ip address 1
#set local-preference 200
#route-map TST permit 20  
#router bgp 200
#neighbor 10.1.24.4 route-map TST in
Note: Tương tự như trường hợp modify weight:  chung ta có thể sử dụng match AS-path, attribute thay cho access-list. Tùy vào trường hợp cụ thể để lựa chọn cách sử dụng cho thích hợp, vì mỗi cái có ưu nhược điểm riêng.

Step 1- Weight ( 13 step selection routes BGP)


1- WEIGHT (Highest)
1.1 overview:
+ Wieght càng cao càng ưu tiên
+ sử dụng trên thiết bị cisco
+ mang tính chất local router, không gửi đi trong quá trình update
+ áp dụng theo chiều incoming update và ảnh hưởng outbound update
+ mặc định giá trị weight khi nhận update = 0 (không thể giảm weight trong chọn route) , và local = 32768
1.2 command modify:
+ neighbor {ip} [Weight]
+ route-map
Route-map có thể map:
_Prefix-list
_AS-path :
_ BGP attribute

Chú ý: + chỉ áp dụng theo chiều IN
  + Route not match by route-map by discarded
1.3 Test.

Ví dụ: R6 và R4 advertise 8.8.8.0/24 sang R2.

=> R2 học 8.8.8.0/24 qua 10.1.26.6 R6. best 
Xem lại 13 step chon route trong BGP:
  1. Giá trị weight =  0
  1. Local preference = 100 ( defaul = 100, để rõ ta show ip bgp 8.8.8.0 để thấy rõ hơn).
  1. As-path ==>BREAK . R2 học qua R6 có As-path ngắn hơn R4 

- Modify weight sao R2 chọn R4 như là best path tới 8.8.8.0
+  change default weight to neighbor:
 #router bgp 200
   #nei 10.1.24.4 weight 200          // modify all weight value in  route update from R4 to R2
+ sử dụng route-map
#access-list 1 permit 8.8.8.0 0.0.0.255   //match only route 8.8.8.0 and modify weight update from R4->R2
#route-map modify_weight_from_R4 permit 10
   #match ip address 1
    #set weight 100
#route-map modify_weight_from_R4 permit 20    //modify route not map by route-map by discarst
#router bgp 200
   #nei 10.1.24.4 route-map modify_weight_from_R4 permit 10 in   //chỉ áp dụng theo chiều in, nếu áp dụng theo chiều out sẽ có. Log thông báo không hỗ trợ, tuy nhiên cmd vẫn có trong config

      - Ngoài cách match ip access-list chúng ta có thể sự dụng:
  •  match ip prefix-list:
         #ip prefix-list ccie permit 8.8.8.0/24
         #route-map TST permit 10
            #mat ip address prefix-list ccie
            #Set weight 100
         #route-map TST permit 20
  • Match As-path
       #ip as-path access-list 1 permit _200$
           #route-map TST permit 10
           #ip as-path access-list 1
           #set weight 100
        #route-map TST permit 20

                 => mỗi phương pháp có ưu điểm và nhược điểm riêng, nên chú ý lựa chọn phù hợp theo yêu cầu.

Saturday, April 11, 2015

OSPF problem when config summary network with virtual-link

Topology:



- R1 create 3 loopback network then advertise into ospf area 0.
 lo0: 1.1.0.1/24
 lo1: 1.1.1.1/24
 lo2: 1.1.2.1/24

- Advertise loopback0 network R4 into ospf area 2.
- verify R1:

- Because area 2 are discontigous Non-AREA .router in area 0 havent route loopback R4.
- Config virtual-link btw R2 and R4 are slove problem.
                                 R2#
                                       router ospf 1
                                       area 1 virtual-link 4.4.4.4
                                 R4#
                                        router ospf 1
                                        area 1 virtual-link 2.2.2.2
=> Neighbor btw R2 and R4 over virtual-link up.
- in R2, summary 3 network learn via R1 into area 1.
                                                                         1.1.0.0/24
                                                                         1.1.1.0/24
                                                                         1.1.2.0/24
                                      => summary route: 1.1.0.0/22
                               R2#
                                     router ospf 1
                                     are 0 range 1.1.0.0 255.255.252.0
- verify R3:


=> we have problem, 3 network advertise by R1 are not summary.

WHY ???
Area 1 should be transit and carry a virtual link and area 0 prefixes should be summarized in the transit area. Per OSPF functionality, it is impossible to summarize prefixes entering a transit area, as this may result in routing loops. Therefore, summarization requirement and virtual link do not work together well.
This solution to this problem is using a tunnel in area 0 as opposed to a virtual-link. The tunnel will encapsulate transit packets and hide them from R3, therefore preventing any possible forwarding loops due to summarization
R2#
router ospf 1
 no area 1 virtual-link 4.4.4.4
 area 0 range 1.1.0.0 255.255.252.0
!
interface Tunnel0
 ip address 192.168.24.2 255.255.255.0
 ip ospf 1 area 0
 tunnel source 10.1.23.2
 tunnel destination 10.1.34.4

R4#
router ospf 1
 no area 1 virtual-link 2.2.2.2
 area 0 range 1.1.0.0 255.255.252.0 not-advertise
!
interface Tunnel0
 ip address 192.168.24.4 255.255.255.0
 ip ospf 1 area 0
 tunnel source 10.1.34.4
 tunnel destination 10.1.23.2

- Verify R3:

Thursday, April 9, 2015

NAT over MPLS VPN

Step 1: config MPLS VPN
 - network: 10.1.xy.0/24
 - loopback address: x.x.x.0/24
 - R2, R3, R4 core MPLS. running ospf are 0.
 - R2 and R4 establish M-BGP
Step 2: config nat on R4.
R4#
interface Loopback1
 ip vrf forwarding VPN
 ip address 44.44.44.44 255.255.255.0
 ip nat outside
 ip virtual-reassembly
!
interface FastEthernet0/0
 ip vrf forwarding VPN
 ip address 192.168.45.4 255.255.255.0
 ip nat inside
 ip virtual-reassembly
 duplex auto
 speed auto
!
interface Serial0/0
 ip address 10.1.34.4 255.255.255.0
 ip nat outside
 ip virtual-reassembly
 ip ospf 1 area 0
 mpls ip
!
ip route vrf VPN 5.5.5.5 255.255.255.255 FastEthernet0/0 192.168.45.5
!
ip nat inside source list 1 interface Loopback1 vrf VPN overload
!
access-list 1 permit 5.5.5.5
-------------------------------------------------------------------------------------------
R5# 
interface FastEthernet0/0
 ip address 192.168.45.5 255.255.255.0
!
ip forward-protocol nd
ip route 0.0.0.0 0.0.0.0 FastEthernet0/0 10.1.45.4

Step 3: verify
R5#ping 1.1.1.1 so l0
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
Packet sent with a source address of 5.5.5.5
!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 32/46/84

R4#debug ip nat
Mar  1 00:38:42.427: NAT*: s=5.5.5.5->44.44.44.44, d=1.1.1.1 [70]
*Mar  1 00:38:42.507: NAT*: s=1.1.1.1, d=44.44.44.44->5.5.5.5 [70]
*Mar  1 00:38:42.535: NAT*: s=5.5.5.5->44.44.44.44, d=1.1.1.1 [71]
*Mar  1 00:38:42.559: NAT*: s=1.1.1.1, d=44.44.44.44->5.5.5.5 [71]
*Mar  1 00:38:42.575: NAT*: s=5.5.5.5->44.44.44.44, d=1.1.1.1 [72]
*Mar  1 00:38:42.583: NAT*: s=1.1.1.1, d=44.44.44.44->5.5.5.5 [72]
*Mar  1 00:38:42.603: NAT*: s=5.5.5.5->44.44.44.44, d=1.1.1.1 [73]
*Mar  1 00:38:42.631: NAT*: s=1.1.1.1, d=44.44.44.44->5.5.5.5 [73]
*Mar  1 00:38:42.655: NAT*: s=5.5.5.5->44.44.44.44, d=1.1.1.1 [74]
*Mar  1 00:38:42.667: NAT*: s=1.1.1.1, d=44.44.44.44->5.5.5.5 [74]
R4#show ip nat translations vrf VPN
Pro Inside global      Inside local       Outside local      Outside global
icmp 44.44.44.44:14    5.5.5.5:14         1.1.1.1:14         1.1.1.1:14

Wednesday, April 1, 2015

Native vlan



Đối với 802.1Q, thì mỗi port trunk sẽ có 1 native vlan. Giá trị này có ý nghĩa như sau:
+ khi gói tin đi ra khỏi port trunk có giá trị vlan giống với native thì vlan header này sẽ bị bóc ra
+ khi gói tin đi vào port-trunk không có vlan thì switch sẽ gán thêm native vlan vào header


R1
interface FastEthernet0/0
 ip address 10.1.12.1 255.255.255.0
R2
interface FastEthernet0/0
 ip address 10.1.12.2 255.255.255.0
R3
interface FastEthernet1/0
 switchport access vlan 10
!
interface FastEthernet1/1
 switchport mode trunk

R1 không thể ping đến 10.1.12.2

Giải thích như sau:
R1 ping 10.1.12.2 gói tin ra đền f1/0 R3 sẽ tag vlan 10 và được đẩy ra trunk qua cổng f1/1. Nhưng khi gói tin về, gói tin sẽ đi untag đi vào f1/1 và sẽ tag native vlan (default vlan 1) --> gói tin bị drop tai R3
 => solution: sử dụng " switchport trunk native vlan 10" ở port f1/1 để SW tag vlan 10 vào gói tin => gói tin sẽ được đẩy ra int f1/0