Skip to content

listen

Accept an incoming BGP connection over TCP.

Synopsis

bgpipe [...] -- listen [OPTIONS] [ADDR]

Description

The listen stage binds to a local TCP address and waits for a single incoming BGP connection. It is both a producer and a consumer: it reads BGP messages from the connected client and writes pipeline messages back to it.

The optional ADDR argument specifies the listen address as host:port, :port, or host. Defaults to :179 (all interfaces, standard BGP port).

Once a client connects, the listener closes and no further connections are accepted. By default any source address may connect first, so in production always restrict it with --peer (and ideally --md5): connections from other addresses are rejected and logged, and the stage keeps listening.

By default, listen messages flow left-to-right (-R direction), but if it is the last stage in the pipeline, it defaults to the left (-L) direction, so that incoming messages flow right-to-left.

Options

Option Type Default Description
--timeout duration 0 Accept timeout; 0 means wait indefinitely
--closed-timeout duration 1s TCP half-closed timeout: how long to wait for the other direction once one has ended (at least 30s after we sent everything, so the peer can read it and close first); 0 disables
--keepalive duration 15s TCP keepalive period; -1 disables
--peer strings Accept only these peer IPs or prefixes (CSV, repeatable), eg. 192.0.2.1,2001:db8::/32
--md5 string TCP MD5 password (Linux/OpenBSD): $ENV_VAR, file path (/... or ./...), or literal
--transparent bool false Transparent proxy mode (Linux TPROXY); see below
--ttl int 0 Outgoing IP TTL / hop limit; 0 leaves the kernel default

With --transparent (Linux only), the listener sets IP_TRANSPARENT and accepts connections destined to a foreign address (redirected to this host via TPROXY, PBR, or an inline bridge), recovering the original destination. It publishes the captured tuple for a transparent connect stage to re-originate - see connect for the full setup.

Examples

Listen on the default BGP port and proxy to an upstream router, accepting only the expected peer:

bgpipe -- connect --wait listen 192.0.2.1 -- listen --peer 198.51.100.7 :179

Listen on a non-standard port for local BIRD integration:

bgpipe -- connect --wait listen --md5 "s3cret" 192.0.2.1 -- listen localhost:1790

Add TCP-MD5 to a session (listen without, connect with), reading the password from the environment:

export BGP_MD5="s3cret"
bgpipe -o -- listen --peer 198.51.100.0/24 :179 -- connect --md5 '$BGP_MD5' 10.0.0.1

See Also

connect, speaker, Stages overview