diff --git a/pkg/server/server.go b/pkg/server/server.go index 8888f39ab..69e2c837b 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -879,6 +879,9 @@ func (s *BgpServer) toConfig(peer *peer, getAdvertised bool) *oc.Neighbor { if state == bgp.BGP_FSM_ESTABLISHED { peer.fsm.lock.RLock() conf.Transport.State.LocalAddress, conf.Transport.State.LocalPort = peer.fsm.LocalHostPort() + if conf.Transport.Config.LocalAddress != "0.0.0.0" { + conf.Transport.State.LocalAddress = conf.Transport.Config.LocalAddress + } _, conf.Transport.State.RemotePort = peer.fsm.RemoteHostPort() buf, _ := peer.fsm.recvOpen.Serialize() // need to copy all values here @@ -1616,6 +1619,10 @@ func (s *BgpServer) handleFSMMessage(peer *peer, e *fsmMsg) { // exclude zone info ipaddr, _ := net.ResolveIPAddr("ip", laddr) peer.fsm.peerInfo.LocalAddress = ipaddr.IP + if peer.fsm.pConf.Transport.Config.LocalAddress != "0.0.0.0" { + peer.fsm.peerInfo.LocalAddress = net.ParseIP(peer.fsm.pConf.Transport.Config.LocalAddress) + peer.fsm.pConf.Transport.State.LocalAddress = peer.fsm.pConf.Transport.Config.LocalAddress + } neighborAddress := peer.fsm.pConf.State.NeighborAddress peer.fsm.lock.Unlock() deferralExpiredFunc := func(family bgp.RouteFamily) func() {