Skip to content

quick start

Thomas Mangin edited this page Nov 14, 2026 · 9 revisions

Pre-Alpha. This page describes behavior that may change.

Start with the local two-peer lab to exchange routes without another router. The later sections show initialization and configuration for an external peer.

If you have not built Ze yet, read Install first.

Local two-peer lab

Run from the repository root after ./ze version builds the daemon. The supplied examples use iBGP in AS 65001, explicit import/export policy and opposite documentation prefixes. Their known lab / lab credentials are for this isolated lab only; management binds loopback and resolver file output is disabled. Each explicit configuration needs its own directory for private state. No ze init step is needed for these configured users.

mkdir -p tmp
ZE_LAB_DIR="$(mktemp -d "$PWD/tmp/quickstart.XXXXXX")"
mkdir "$ZE_LAB_DIR/r1" "$ZE_LAB_DIR/r2"
cp examples/quickstart/r1.conf "$ZE_LAB_DIR/r1/ze.conf"
cp examples/quickstart/r2.conf "$ZE_LAB_DIR/r2/ze.conf"
./ze config validate "$ZE_LAB_DIR/r1/ze.conf"
./ze config validate "$ZE_LAB_DIR/r2/ze.conf"
./ze start "$ZE_LAB_DIR/r1/ze.conf" >"$ZE_LAB_DIR/r1.log" 2>&1 &
R1_PID=$!
./ze start "$ZE_LAB_DIR/r2/ze.conf" >"$ZE_LAB_DIR/r2.log" 2>&1 &
R2_PID=$!

Linux provides both loopback addresses. On macOS, add the second address before starting: sudo ifconfig lo0 alias 127.0.0.2.

In the same shell, query the sessions and received routes. If a listener is still starting, inspect the logs and retry after it is ready:

ZE_SSH_PASSWORD=lab ./ze cli --remote 127.0.0.1:2221 --user lab -c "show bgp peer list"
ZE_SSH_PASSWORD=lab ./ze cli --remote 127.0.0.1:2221 --user lab -c "show bgp rib | received"
ZE_SSH_PASSWORD=lab ./ze cli --remote 127.0.0.1:2222 --user lab -c "show bgp rib | received"

Both sessions must establish. The received RIB on r1 must contain 198.51.100.0/24; r2 must contain 192.0.2.0/24. This proves control-plane exchange. The synthetic advertised next hops do not establish host forwarding connectivity.

Stop both owned processes before removing their files:

kill -TERM "$R1_PID" "$R2_PID"
wait "$R1_PID" "$R2_PID"
printf 'Lab files and stores: %s\n' "$ZE_LAB_DIR"

Keep the printed directory to inspect logs and stores or restart the lab. Remove it only after both processes have stopped.

Initialize credentials

The remaining example uses an external router. Its configured addresses must exist on your host and peer; use the complete local lab above when no such router is available.

Ze runs an SSH server on localhost for every CLI call. This keeps the control plane authenticated even when multiple users share the host. You set up the credentials once, in the folder that will hold the example config:

export ZE_CONFIG_DIR="$PWD"
bin/ze init

The prompt asks for a username, a password, an SSH host (defaults to 127.0.0.1), a port (defaults to 2222), and an instance name (defaults to the hostname). Passwords are stored bcrypt-hashed in Ze's local store, a database/ directory in the configuration folder.

You can script this:

echo -e "admin\nsecret" | bin/ze init

Running ze init a second time refuses with database already exists. If you need to start over, stop the daemon and run ze init --force. The old store is kept as database.replaced-<stamp> once the fresh one is in place. --force --yes confirms the replacement in a script, and the replacement refuses while any process owns the store. To start from an existing backup instead, run ze init --from <file>, which imports a local blob; see Backup and restore.

Write a minimal config

Save this as example.conf:

static {
    table default {
        route 172.16.0.0/24 {
            next {
                hop 10.0.0.1 {
                }
            }
        }
    }
}

redistribute {
    destination bgp {
        import static
    }
}

bgp {
    router-id 10.0.0.1
    session {
        asn {
            local 65000
        }
    }

    peer test-peer {
        connection {
            remote {
                ip 10.0.0.2
            }
            local {
                ip 10.0.0.1
            }
        }

        session {
            asn {
                local 65000
                remote 65001
            }
            family {
                ipv4/unicast {
                    prefix {
                        maximum 1000000
                    }
                }
            }
        }

        filter {
            export {
                final accept
            }
        }

        update {
            attribute {
                origin igp
                next-hop 10.0.0.1
            }
            nlri {
                ipv4/unicast add 192.168.1.0/24
            }
        }
    }
}

This advertises two prefixes to test-peer, one by each of the two ways a prefix gets into BGP:

  • Redistribution (172.16.0.0/24): a static route pulled into BGP by the top-level redistribute { destination bgp { import static } } block. Every source protocol (static, connected, kernel, ospf, isis, ...) redistributes into any destination the same way.
  • Direct announcement (192.168.1.0/24): a prefix declared inline in the peer's update {} block, sent when the session establishes. The automatic End-of-RIB marker follows Ze's own routes; behavior { manual-eor true } suppresses the marker, not the routes.

The filter { export { final accept } } block is required: test-peer is an EBGP peer (AS 65001), and with no export policy Ze sends an EBGP peer no routes at all (RFC 8212 Section 3), originated ones included. See Policies.

No plugin block is needed: the RIB plugin loads on its own. A process binding, which attaches a plugin or your own program to a peer, is the advanced route; see Plugins.

Validate and start

Always validate before starting:

bin/ze config validate example.conf

You should see configuration valid: example.conf (add -v to see peer and plugin counts). Then start the daemon:

bin/ze start example.conf

The config path is a value, so it follows the start keyword. A bare ze example.conf is refused with unknown command: example.conf (exit 1): position 1 is reserved for commands, and the only free-form value there is -, which reads the config from stdin. With no file, ze start uses the config the store names, and refuses with exit 1 if the store's instance name cannot be read; ze doctor checks the store.

Ze logs to stderr. The default level is warn, so silence is a good sign. Add -d for debug logging while you are getting a feel for what is happening:

bin/ze -d start example.conf

Verify

Open another terminal. Keep ZE_CONFIG_DIR set there too, so the CLI reads the credentials from the same folder. All these commands talk to the daemon over the SSH control channel you set up with ze init:

bin/ze status                      # is the daemon alive?
bin/ze cli -c "show bgp peer list"              # list configured peers
bin/ze cli -c "show bgp peer test-peer detail"  # peer state and counters
bin/ze cli -c "monitor event"                   # live event stream, Ctrl-C to exit

If the peer is in IDLE or CONNECT and stuck there, the other side is unreachable. That is expected for this example: 10.0.0.2 is almost certainly not live on your box.

Test without a real peer

To see a session actually come up, use the bundled sink peer. It accepts any BGP session and replies with keepalives:

bin/le test peer --mode sink --port 1179 --asn 65001

Point your config at 127.0.0.1:1179 and restart Ze. The session will go to ESTABLISHED and your announced prefix will appear in the sink peer's log.

Stop and restart

bin/ze signal stop       # graceful shutdown, no GR marker
bin/ze signal restart    # graceful restart with GR marker, preserves routes

Next

Adapted from main/docs/guide/quickstart.md.

Home

About

First Steps

Configuration

Operation

Interfaces

Plugins

Plugin Development

Chaos Testing

Blueprints

Development

Reference

Clone this wiki locally