github.com/osrg/gobgp/v3@v3.30.0/tools/contrib/centos/README.md (about) 1 # GoBGP systemd Integration for CentOS 2 3 The following document describes how to manage `gobgp` with `systemd`. 4 5 Download `gobgp` binaries, unpack them, and put them `/usr/bin/`: 6 7 ```bash 8 mkdir -p /tmp/gobgp 9 cd /tmp/gobgp && curl -s -L -O https://github.com/osrg/gobgp/releases/download/v1.31/gobgp_1.31_linux_amd64.tar.gz 10 tar xvzf gobgp_1.31_linux_amd64.tar.gz 11 mv gobgp /usr/bin/ 12 mv gobgpd /usr/bin/ 13 ``` 14 15 First, create a system account for `gobgp` service: 16 17 ```bash 18 groupadd --system gobgpd 19 useradd --system -d /var/lib/gobgpd -s /bin/bash -g gobgpd gobgpd 20 mkdir -p /var/{lib,run,log}/gobgpd 21 chown -R gobgpd:gobgpd /var/{lib,run,log}/gobgpd 22 mkdir -p /etc/gobgpd 23 chown -R gobgpd:gobgpd /etc/gobgpd 24 ``` 25 26 Paste the below to create `gobgpd` configuration file. The `router-id` in this 27 example is the IP address of the interface the default route of the host is 28 pointing to. 29 30 ```bash 31 DEFAULT_ROUTE_INTERFACE=$(cat /proc/net/route | cut -f1,2 | grep 00000000 | cut -f1) 32 DEFAULT_ROUTE_INTERFACE_IPV4=$(ip addr show dev $DEFAULT_ROUTE_INTERFACE | grep "inet " | sed "s/.*inet //" | cut -d"/" -f1) 33 BGP_AS=65001 34 BGP_PEER=10.0.255.1 35 cat << EOF > /etc/gobgpd/gobgpd.conf 36 [global.config] 37 as = $BGP_AS 38 router-id = "$DEFAULT_ROUTE_INTERFACE_IPV4" 39 40 [[neighbors]] 41 [neighbors.config] 42 neighbor-address = "$BGP_PEER" 43 peer-as = $BGP_AS 44 EOF 45 ``` 46 47 Next, copy the `systemd` unit file, i.e. `gobgpd.service`, in this directory 48 to `/usr/lib/systemd/system/`: 49 50 ```bash 51 cp gobgpd.service /usr/lib/systemd/system/ 52 ``` 53 54 Next, enable and start the `gobgpd` services: 55 56 ```bash 57 systemctl enable gobgpd 58 systemctl start gobgpd 59 ``` 60 61 If necessary, create an `iptables` rule to allow traffic to `gobgpd` service: 62 63 ```bash 64 iptables -I INPUT 4 -p tcp -m state --state NEW --dport 179 -j ACCEPT 65 ``` 66 67 Also, add the following rule into `INPUT` chain in `/etc/sysconfig/iptables`: 68 69 ```plaintext 70 # BGP 71 -A INPUT -p tcp -m state --state NEW -m tcp --dport 179 -j ACCEPT 72 ``` 73 74 Check the status of the services: 75 76 ```bash 77 systemctl status gobgpd 78 ``` 79 80 The logs are available via `journald`: 81 82 ```bash 83 journalctl -u gobgpd.service --since today 84 journalctl -u gobgpd.service -r 85 ``` 86 87 A user may interract with GoBGP daemon via `gobgp` tool: 88 89 ```bash 90 # gobgp global 91 AS: 65001 92 Router-ID: 10.0.255.1 93 Listening Port: 179, Addresses: 0.0.0.0, :: 94 95 # gobgp global rib summary 96 Table ipv4-unicast 97 Destination: 0, Path: 0 98 99 # gobgp neighbor 100 Peer AS Up/Down State |#Received Accepted 101 10.0.255.1 65001 never Active | 0 102 ```