The network command configures the local network routes advertised by the local BGP. The routes in the local routing table are statically added to the BGP routing table and are advertised to the peers.
The undo network command deletes the existing configuration.
By default, BGP does not advertise any local network route.
network { ipv4-address [ mask | mask-length ] | ipv6-address prefix-length } [ route-policy route-policy-name ]
undo network { ipv4-address [ mask | mask-length ] | ipv6-address prefix-length }
| Parameter | Description | Value |
|---|---|---|
| ipv4-address | Specifies the IPv4 network address advertised by BGP. | It is in dotted decimal notation. |
| mask | Specifies the IP address mask. If the mask is not specified, the address is processed as the classful address. | It is in dotted decimal notation. |
| mask-length | Specifies the length of the mask. If the length of the mask is not specified, the address is processed as the classful address. | It is an integer ranging from 0 to 32. |
| ipv6-address | Specifies the IPv6 network address advertised by BGP. | The prefix is a 32-digit hexadecimal number, in the format of X:X:X:X:X:X:X:X. |
| prefix-length | Specifies the prefix length of the IPv6 network address advertised by BGP. | It is an integer ranging from 0 to 128. |
| route-policy route-policy-name | Specifies the name of the Route-Policy that is used to the advertised routes. | The name must be unique and is a string of 1 to 40 characters. It is case-sensitive. |
ipv4-address is valid only in BGP view, BGP-IPv4 unicast address family view, BGP-VPN instance IPv4 address family view.
ipv6-address is valid only in BGP-IPv6 unicast address family view and BGP-VPN instance IPv6 address family view.
BGP view, BGP-VPN instance IPv4 address family view, BGP-VPN instance IPv6 address family view, BGP-IPv6 unicast address family view, BGP-IPv4 unicast address family view
Usage Scenario
BGP itself cannot discover routes. Instead, it imports routes discovered by other protocols such as an IGP or static routes into the BGP routing table. These imported routes then are transmitted within an AS or between ASs. Before adding routes to the BGP routing table, BGP filters these routes by the routing protocol. If routes in the local IP routing table need to be statically added to the BGP routing table and then advertised, you can use the network command.
The Origin attribute of the routes imported into the BGP routing table by using the network command is IGP.
If a route with a specific prefix or mask is added to the BGP routing table by using the network command, this route is the optimal route selected from all types of protocol routes. Unlike the network command, the import-route command is used to add all routes of a particular protocol such as RIP, OSPF, IS-IS, static route, or direct route to the BGP routing table.
Configuration Impact
After the network command is configured, specific routes are statically added to the BGP routing table.
Precautions
The network command is used to import exactly-matching routes. This means that only the routes in the local IP routing table that exactly match the specified destination address and prefix length can be added to the BGP routing table. If mask is not specified, routes are exactly matched against the natural network mask.
When using the undo network command to delete the existing configuration, specify a correct mask.
To prevent security risks, do not set network 0.0.0.0.
# Configure BGP to advertise the local route 10.0.0.0/16.
<sysname> system-view
[sysname] bgp 100
[sysname-bgp] ipv4-family unicast
[sysname-bgp-af-ipv4] network 10.0.0.0 255.255.0.0
<sysname> system-view
[sysname] bgp 100
[sysname-bgp] ipv6-family unicast
[sysname-bgp-af-ipv6] network 2002:: 16