Skip to content
This repository was archived by the owner on Oct 11, 2020. It is now read-only.

05. Openconfig demo using cli on Juniper devices

Khelil Sator edited this page Jun 19, 2017 · 13 revisions

Openconfig configuration:

Below OC configuration examples with

BGP configuration on Juniper routers with Openconfig:

fabric-02:

OpenConfig BGP data models:

lab@fabric-02> show configuration openconfig-bgp:bgp | display set
set openconfig-bgp:bgp neighbors neighbor 192.168.1.1 config peer-as 104
set openconfig-bgp:bgp neighbors neighbor 192.168.1.1 config peer-group OC
set openconfig-bgp:bgp neighbors neighbor 192.168.1.1 config neighbor-address 192.168.1.1
set openconfig-bgp:bgp neighbors neighbor 192.168.1.1 config enabled true
set openconfig-bgp:bgp peer-groups peer-group OC config local-as 110
set openconfig-bgp:bgp peer-groups peer-group OC config peer-type EXTERNAL
set openconfig-bgp:bgp peer-groups peer-group OC config peer-group-name OC
set openconfig-bgp:bgp peer-groups peer-group OC apply-policy config import-policy bgp-in
set openconfig-bgp:bgp peer-groups peer-group OC apply-policy config export-policy bgp-out

Interface configuration (I am using the Junos model):

lab@fabric-02> show configuration interfaces xe-0/0/0 | display set
set interfaces xe-0/0/0 unit 0 family inet address 192.168.1.2/24

Routing policies configuration (I am using the Junos model):

lab@fabric-02> show configuration policy-options policy-statement bgp-in | display set
set policy-options policy-statement bgp-in then accept

lab@fabric-02> show configuration policy-options policy-statement bgp-out | display set
set policy-options policy-statement bgp-out then accept

fabric-01:

OpenConfig BGP data models:

lab@fabric-01> show configuration openconfig-bgp:bgp
neighbors {
    neighbor 192.168.1.2 {
        config {
            peer-as 110;
            peer-group OC;
        }
    }
}
peer-groups {
    peer-group OC {
        config {
            local-as 104;
            peer-type EXTERNAL;
        }
        apply-policy {
            config {
                import-policy bgp-in;
                export-policy bgp-out;
            }
        }
    }
}

To display the json representation, include | display json

lab@fabric-01> show configuration openconfig-bgp:bgp | display json
{
    "openconfig-bgp:bgp" : {
        "neighbors" : {
            "neighbor" : [
            {
                "neighbor-address" : "192.168.1.2",
                "config" : {
                    "peer-as" : 110,
                    "peer-group" : "OC"
                }
            }
            ]
        },
        "peer-groups" : {
            "peer-group" : [
            {
                "peer-group-name" : "OC",
                "config" : {
                    "local-as" : 104,
                    "peer-type" : "EXTERNAL"
                },
                "apply-policy" : {
                    "config" : {
                        "import-policy" : ["bgp-in"],
                        "export-policy" : ["bgp-out"]
                    }
                }
            }
            ]
        }
    }
}

To display the XML representation, include | display xml
Please note the xmlns (xml name space) in the below example.

lab@fabric-01> show configuration openconfig-bgp:bgp | display xml
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/16.1I0/junos">
    <bgp xmlns="http://openconfig.net/yang/bgp">
            <neighbors>
                <neighbor>
                    <neighbor-address>192.168.1.2</neighbor-address>
                    <config>
                        <peer-as>110</peer-as>
                        <peer-group>OC</peer-group>
                    </config>
                </neighbor>
            </neighbors>
            <peer-groups>
                <peer-group>
                    <peer-group-name>OC</peer-group-name>
                    <config>
                        <local-as>104</local-as>
                        <peer-type>EXTERNAL</peer-type>
                    </config>
                    <apply-policy>
                        <config>
                            <import-policy>bgp-in</import-policy>
                            <export-policy>bgp-out</export-policy>
                        </config>
                    </apply-policy>
                </peer-group>
            </peer-groups>
    </bgp>
    <cli>
        <banner></banner>
    </cli>
</rpc-reply>

Interface configuration (I am using the Junos model):

lab@fabric-01> show configuration interfaces xe-0/0/0
unit 0 {
    family inet {
        address 192.168.1.1/24;
    }
}

Routing policies configuration (I am using the Junos model):

lab@fabric-01> show configuration policy-options policy-statement bgp-in
then accept;

lab@fabric-01> show configuration policy-options policy-statement bgp-out
then accept;
Display the Junos configuration emitted by the translation scripts

To display only the Junos configuration emitted by the translation scripts:

lab@fabric-01> show configuration | display translation-scripts translated-config
protocols {
    bgp {
        group OC {
            type external;
            import bgp-in;
            export bgp-out;
            local-as 104;
            neighbor 192.168.1.2 {
                peer-as 110;
            }
        }
    }
}

To display the whole configuration in junos data model after translation scripts have been applied:

lab@fabric-01> show configuration | display translation-scripts
Audit the BGP operational state:
lab@fabric-01> show bgp neighbor 192.168.1.2
Peer: 192.168.1.2+57620 AS 110 Local: 192.168.1.1+179 AS 104
  Group: OC                    Routing-Instance: master
  Forwarding routing-instance: master
  Type: External    State: Established    Flags: <Sync>
  Last State: OpenConfirm   Last Event: RecvKeepAlive
  Last Error: None
  Export: [ bgp-out ] Import: [ bgp-in ]
  Options: <Preference LogUpDown PeerAS LocalAS Refresh>
  Holdtime: 90 Preference: 170 Local AS: 104 Local System AS: 200
  Number of flaps: 0
  Peer ID: 100.0.0.2       Local ID: 100.0.0.1         Active Holdtime: 90
  Keepalive Interval: 30         Group index: 3    Peer index: 0
  I/O Session Thread: bgpio-0 State: Enabled
  BFD: disabled, down
  Local Interface: xe-0/0/0.0
  NLRI for restart configured on peer: inet-unicast
  NLRI advertised by peer: inet-unicast
  NLRI for this session: inet-unicast
  Peer supports Refresh capability (2)
  Stale routes from peer are kept for: 300
  Peer does not support Restarter functionality
  Restart flag received from the peer: Notification
  NLRI that restart is negotiated for: inet-unicast
  NLRI of received end-of-rib markers: inet-unicast
  NLRI of all end-of-rib markers sent: inet-unicast
  Peer does not support LLGR Restarter functionality
  Peer supports 4 byte AS extension (peer-as 110)
  Peer does not support Addpath
  Table inet.0 Bit: 40001
    RIB State: BGP restart is complete
    Send state: in sync
    Active prefixes:              2
    Received prefixes:            15
    Accepted prefixes:            14
    Suppressed due to damping:    0
    Advertised prefixes:          14
  Last traffic (seconds): Received 1560640 Sent 282 Checked 1560640
  Input messages:  Total 23     Updates 7       Refreshes 0     Octets 789
  Output messages: Total 14     Updates 7       Refreshes 0     Octets 753
  Output Queue[3]: 0            (inet.0, inet-unicast)

To display the Junos RPC for an operational mode command, include the | display xml rpc
The equivalent RPC for the Junos command "show bgp neighbor| display xml" is get-bgp-neighbor-information

lab@fabric-01> show bgp neighbor | display xml rpc
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/16.1I0/junos">
    <rpc>
        <get-bgp-neighbor-information>
        </get-bgp-neighbor-information>
    </rpc>
    <cli>
        <banner></banner>
    </cli>
</rpc-reply>

lab@fabric-01> show bgp neighbor 192.168.1.2 | display xml rpc
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/16.1I0/junos">
    <rpc>
        <get-bgp-neighbor-information>
                <neighbor-address>192.168.1.2</neighbor-address>
        </get-bgp-neighbor-information>
    </rpc>
    <cli>
        <banner></banner>
    </cli>
</rpc-reply>

interface configuration on Juniper routers with Openconfig

lab@spine-02# set openconfig-interfaces:interfaces interface et-0/0/12 config type ethernetCsmacd
lab@spine-02# set openconfig-interfaces:interfaces interface et-0/0/12 config mtu 9192
lab@spine-02# set openconfig-interfaces:interfaces interface et-0/0/12 config name et-0/0/12
lab@spine-02# set openconfig-interfaces:interfaces interface et-0/0/12 config description "* to leaf-01"
lab@spine-02# set openconfig-interfaces:interfaces interface et-0/0/12 config enabled true
lab@spine-02# set openconfig-interfaces:interfaces interface et-0/0/12 subinterfaces subinterface 0 openconfig-if-ip:ipv4 addresses address 172.16.0.4/31 config ip 172.16.0.4
lab@spine-02# set openconfig-interfaces:interfaces interface et-0/0/12 subinterfaces subinterface 0 openconfig-if-ip:ipv4 addresses address 172.16.0.4/31 config prefix-length 31
lab@spine-02# show | compare
[edit]
+  openconfig-interfaces:interfaces {
+      interface et-0/0/12 {
+          config {
+              type ethernetCsmacd;
+              mtu 9192;
+              name et-0/0/12;
+              description "* to leaf-01";
+              enabled true;
+          }
+          subinterfaces {
+              subinterface 0 {
+                  openconfig-if-ip:ipv4 {
+                      addresses {
+                          address 172.16.0.4/31 {
+                              config {
+                                  ip 172.16.0.4;
+                                  prefix-length 31;
+                              }
+                          }
+                      }
+                  }
+              }
+          }
+      }
+  }
lab@spine-02# commit
configuration check succeeds
commit complete
lab@spine-02# show openconfig-interfaces:interfaces
interface et-0/0/12 {
    config {
        type ethernetCsmacd;
        mtu 9192;
        name et-0/0/12;
        description "* to leaf-01";
        enabled true;
    }
    subinterfaces {
        subinterface 0 {
            openconfig-if-ip:ipv4 {
                addresses {
                    address 172.16.0.4/31 {
                        config {
                            ip 172.16.0.4;
                            prefix-length 31;
                        }
                    }
                }
            }
        }
    }
}

openconfig configuration translated into junos:

lab@spine-02# show | display translation-scripts translated-config
chassis {
    aggregated-devices {
        ethernet {
            device-count 100;
        }
    }
}
interfaces {
    et-0/0/12 {
        description "* to leaf-01";
        enable;
        mtu 9192;
        unit 0 {
            family inet {
                address 172.16.0.4/31;
            }
        }
    }
}

routing policy configuration on Juniper routers with Openconfig

lab@spine-02#set openconfig-routing-policy:routing-policy defined-sets prefix-sets prefix-set "100.0.0.0/16 or longer" config prefix-set-name "100.0.0.0/16 or longer"
lab@spine-02#set openconfig-routing-policy:routing-policy defined-sets prefix-sets prefix-set "100.0.0.0/16 or longer" prefixes prefix 100.0.0.0/16 16..32
lab@spine-02#set openconfig-routing-policy:routing-policy policy-definitions policy-definition bgp-ipclos-in config name "100.0.0.0/16 or longer"
lab@spine-02#set openconfig-routing-policy:routing-policy policy-definitions policy-definition bgp-ipclos-in statements statement loopbacks conditions lab@spine-02#match-prefix-set config prefix-set "100.0.0.0/16 or longer"
lab@spine-02#set openconfig-routing-policy:routing-policy policy-definitions policy-definition bgp-ipclos-in statements statement loopbacks actions config accept-route
lab@spine-02# show openconfig-routing-policy:routing-policy
defined-sets {
    prefix-sets {
        prefix-set "100.0.0.0/16 or longer" {
            config {
                prefix-set-name "100.0.0.0/16 or longer";
            }
            prefixes {
                prefix 100.0.0.0/16 16..32;
            }
        }
    }
}
policy-definitions {
    policy-definition bgp-ipclos-in {
        config {
            name "100.0.0.0/16 or longer";
        }
        statements {
            statement loopbacks {
                conditions {
                    match-prefix-set {
                        config {
                            prefix-set "100.0.0.0/16 or longer";
                        }
                    }
                }
                actions {
                    config {
                        accept-route;
                    }
                }
            }
        }
    }
}
lab@spine-02# commit
configuration check succeeds
commit complete

openconfig configuration translated into junos:

lab@spine-02# show | display translation-scripts translated-config
policy-options {
    route-filter-list "100.0.0.0/16 or longer" {
        100.0.0.0/16 prefix-length-range /16-/32;
    }
    policy-statement bgp-ipclos-in {
        term loopbacks {
            from {
                route-filter-list "100.0.0.0/16 or longer";
            }
            then accept;
        }
    }
}

LLDP configuration on Juniper routers with Openconfig

lab@spine-02# set openconfig-lldp:lldp config enabled true hello-timer 20
lab@spine-02# set openconfig-lldp:lldp interfaces interface et-0/0/12 config name et-0/0/12
lab@spine-02# set openconfig-lldp:lldp interfaces interface et-0/0/12
lab@spine-02# set openconfig-lldp:lldp interfaces interface et-0/0/13 config name et-0/0/13
lab@spine-02# set openconfig-lldp:lldp interfaces interface et-0/0/13 config enabled false
lab@spine-02# show | compare
[edit]
+  openconfig-lldp:lldp {
+      config {
+          enabled true;
+          hello-timer 20;
+      }
+      interfaces {
+          interface et-0/0/12 {
+              config {
+                  name et-0/0/12;
+              }
+          }
+          interface et-0/0/13 {
+              config {
+                  name et-0/0/13;
+                  enabled false;
+              }
+          }
+      }
+  }
lab@spine-02# commit
configuration check succeeds
commit complete
lab@spine-02# show openconfig-lldp:lldp
config {
    enabled true;
    hello-timer 20;
}
interfaces {
    interface et-0/0/12 {
        config {
            name et-0/0/12;
        }
    }
    interface et-0/0/13 {
        config {
            name et-0/0/13;
            enabled false;
        }
    }
}
lab@spine-02# show | display translation-scripts translated-config
protocols {
    lldp {
        enable;
        advertisement-interval 20;
        interface et-0/0/12;
        interface et-0/0/13 {
            disable;
        }
    }
}

Clone this wiki locally