summaryrefslogtreecommitdiff
path: root/docs/routing/routing-policy.rst
blob: 253dd980f629c664a1c9b1c67b21999a91fb53bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59

Routing-policy
--------------

Routing Policies could be used to tell the router (self or neighbors) what routes and their attributes needs to be put into the routing table.

There could be a wide range of routing policies. Some examples are below:

  * Set some metric to routes learned from a particular neighbor
  * Set some attributes (like AS PATH or Community value) to advertised routes to neighbors
  * Prefer a specific routing protocol routes over another routing protocol running on the same router

Routing Policy Example
~~~~~~~~~~~~~~~~~~~~~~

**Policy definition:**

.. code-block:: sh

  #Create policy
  set policy route-map setmet rule 2 action 'permit'
  set policy route-map setmet rule 2 set as-path-prepend '2 2 2'  
  
  #Apply policy to BGP
  set protocols bgp 1 neighbor 1.1.1.2 route-map import 'setmet'
  set protocols bgp 1 neighbor 1.1.1.2 soft-reconfiguration 'inbound' <<<< *** 
  
  *** get policy update without bouncing the neighbor

**Routes learned before routing policy applied:**

.. code-block:: sh

  vyos@vos1:~$ show ip bgp
  BGP table version is 0, local router ID is 192.168.56.101
  Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
                r RIB-failure, S Stale, R Removed
  Origin codes: i - IGP, e - EGP, ? - incomplete
  
     Network          Next Hop            Metric LocPrf Weight Path
  *> 22.22.22.22/32   1.1.1.2                  1             0 2 i  < Path 
  
  Total number of prefixes 1

**Routes learned after routing policy applied:**

.. code-block:: sh

  vyos@vos1:~$ sho ip b
  BGP table version is 0, local router ID is 192.168.56.101
  Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
                r RIB-failure, S Stale, R Removed
  Origin codes: i - IGP, e - EGP, ? - incomplete
  
     Network          Next Hop            Metric LocPrf Weight Path
  *> 22.22.22.22/32   1.1.1.2                  1             0 2 2 2 2 i < longer AS_path length
  
  Total number of prefixes 1
  vyos@vos1:~$