peer source-address
Use peer source-address to specify a source IPv4 or IPv6 address for establishing TCP connections to a peer or peer group.
Use undo peer source-address to remove the configuration.
Syntax
peer ipv4-address [ mask-length ] source-address source-ipv4-address
peer ipv6-address [ prefix-length ] source-address source-ipv6-address
undo peer { ipv4-address [ mask-length ] | ipv6-address [ prefix-length ] } source-address
peer group-name source-address { source-ipv4-address | source-ipv6-address } *
undo peer group-name source-address [ source-ipv4-address | source-ipv6-address ]
Default
BGP uses the primary IPv4 or IPv6 address of the output interface in the optimal route destined for the BGP peer or peer group as the source address for TCP connection establishment.
Views
BGP instance view
BGP-VPN instance view
Predefined user roles
network-admin
Parameters
ipv4-address: Specifies a peer by its IPv4 address. The peer must have been created.
mask-length: Specifies a mask length in the range of 0 to 32. You can use the ipv4-address and mask-length arguments together to specify a subnet. If you specify a subnet, this command specifies a source IP address for establishing TCP connections to all dynamic peers in the subnet.
source-ipv4-address: Specifies a source IPv4 address.
ipv6-address: Specifies a peer by its IPv6 address. The peer must have been created.
prefix-length: Specifies a prefix length in the range of 0 to 128. You can use the ipv6-address and prefix-length arguments together to specify a subnet. If you specify a subnet, this command specifies a source IPv6 address for establishing TCP connections to all dynamic peers in the subnet.
source-ipv6-address: Specifies a source IPv6 address.
group-name: Specifies a peer group by its name, a case-sensitive string of 1 to 47 characters. The peer group must have been created.
Usage guidelines
The peer connect-interface command and the peer source-address command can both change the source address for establishing TCP connections. If you execute both commands, the most recent configuration takes effect.
The peer source-address and peer connect-interface commands are applicable to the following scenarios:
The peer's IPv4/IPv6 address does not belong to the interface directly connected to the local router. To ensure successful TCP connection establishment, use one of the following methods:
Specify the interface to which the IPv4/IPv6 address belongs as the source interface on the peer.
Specify the IPv4/IPv6 address of the interface directly connected to the local router as the source address on the peer.
On a BGP router that has multiple links to a peer, the source interface for TCP connection changes because the primary source interface fails. To avoid this problem, specify a loopback interface as the source interface or specify the IP address of a loopback interface as the source address.
You want to establish multiple BGP sessions to a router. In this case, BGP might fail to determine the source address for each TCP connection based on the optimal route to the peer. To prevent this problem, use one of the following methods:
If the BGP sessions use IP addresses of different interfaces, specify a source interface or source address for each session.
If the BGP sessions use different IP addresses of the same interface, specify a source address for each session.
The source addresses on the local router and the peer must be reachable to each other.
To specify the address of an indirectly connected interface as the source address, use the peer ebgp-max-hop command. The command allows the establishment of an EBGP session to the indirectly connected peer.
You can specify both a source IPv4 address and a source IPv6 address for a peer group. BGP uses the source IPv4 address to establish TCP connections to IPv4 peers in the group. It also uses the source IPv6 address to establish TCP connections to IPv6 peers in the group.
Examples
# In BGP instance view, specify source IPv4 address 1.1.1.1 for peer group test.
<Sysname> system-view [Sysname] bgp 100 [Sysname-bgp-default] peer test source-address 1.1.1.1
Related commands
peer connect-interface
peer ebgp-max-hop