osrg / gobgp

BGP implemented in the Go Programming Language
https://osrg.github.io/gobgp/
Apache License 2.0
3.66k stars 699 forks source link

Listen port doesn't change from 179 #2847

Closed azi1233 closed 1 month ago

azi1233 commented 1 month ago

I don't know whether it's mandatory to use port 179 or not. But when the port is changed in the global config from 179, like this:

as = 65001
  router-id = "172.17.0.1"
  port = 1790

[[neighbors]]
  [neighbors.config]
    neighbor-address = "172.17.0.2"
    peer-as = 64512

The TCP connection port stays at 179:

image

It seems that the TCP port doesn't change based on the configuration. See fsm.go, line 507:

                addr := fsm.pConf.State.NeighborAddress
        port := int(bgp.BGP_PORT)
        if fsm.pConf.Transport.Config.RemotePort != 0 {
            port = int(fsm.pConf.Transport.Config.RemotePort)
        }

I don't know how the configuration should be passed in order to establish a TCP connection, but I'm willing to handle this myself if it's okay to do so.

SkalaNetworks commented 1 month ago

Are you trying to bind your own BGP server to port 1790 or are you trying to talk with peers over a port that is different from 179? Your configuration only binds to 1790. The line of code you found indicates what parameter should be changed to communicate over 1790 with your remote peer.

See https://github.com/osrg/gobgp/blob/master/docs/sources/configuration.md

image

azi1233 commented 1 month ago

Thank you @SkalaNetworks I want to talk to other peers with different port. I didn't know about the "remote-port" config. (Actually, I should have noticed the if statement after setting bgp.BGP_PORT in fsm.go:))