summaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2018-07-07 13:48:38 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2018-07-07 20:44:25 +0900
commitc4775c42510d1f1ddd55036dc19e982712fa6a0b (patch)
tree6ec8b61d4338c809e239e3003a2d32d480898e22 /tools
parentb3079759aa13172fcb548a83da9a9653d8d5fed4 (diff)
follow Standard Go Project Layout
https://github.com/golang-standards/project-layout Now you can see clearly what are private and public library code. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'tools')
-rw-r--r--tools/config/example_toml.go3
-rw-r--r--tools/contrib/centos/README.md111
-rwxr-xr-xtools/contrib/centos/add_gobgpd_account.sh6
-rw-r--r--tools/contrib/centos/gobgpd.service17
-rw-r--r--tools/contrib/ubuntu/gobgpd.conf26
-rw-r--r--tools/route-server/quagga-rsconfig.go2
6 files changed, 163 insertions, 2 deletions
diff --git a/tools/config/example_toml.go b/tools/config/example_toml.go
index 62e6b8f6..0018f582 100644
--- a/tools/config/example_toml.go
+++ b/tools/config/example_toml.go
@@ -3,8 +3,9 @@ package main
import (
"bytes"
"fmt"
+
"github.com/BurntSushi/toml"
- "github.com/osrg/gobgp/config"
+ "github.com/osrg/gobgp/internal/pkg/config"
)
func main() {
diff --git a/tools/contrib/centos/README.md b/tools/contrib/centos/README.md
new file mode 100644
index 00000000..a8416b45
--- /dev/null
+++ b/tools/contrib/centos/README.md
@@ -0,0 +1,111 @@
+# GoBGP systemd Integration for CentOS
+
+The following document describes how to manage `gobgp` with `systemd`.
+
+Download `gobgp` binaries, unpack them, and put them `/usr/bin/`:
+
+```bash
+mkdir -p /tmp/gobgp
+cd /tmp/gobgp && curl -s -L -O https://github.com/osrg/gobgp/releases/download/v1.31/gobgp_1.31_linux_amd64.tar.gz
+tar xvzf gobgp_1.31_linux_amd64.tar.gz
+mv gobgp /usr/bin/
+mv gobgpd /usr/bin/
+```
+
+Grant the capability to bind to system or well-known ports, i.e. ports with
+numbers `0–1023`, to `gobgpd` binary:
+
+```bash
+/sbin/setcap cap_net_bind_service=+ep /usr/bin/gobgpd
+/sbin/getcap /usr/bin/gobgpd
+```
+
+First, create a system account for `gobgp` service:
+
+```bash
+groupadd --system gobgpd
+useradd --system -d /var/lib/gobgpd -s /bin/bash -g gobgpd gobgpd
+mkdir -p /var/{lib,run,log}/gobgpd
+chown -R gobgpd:gobgpd /var/{lib,run,log}/gobgpd
+mkdir -p /etc/gobgpd
+chown -R gobgpd:gobgpd /etc/gobgpd
+```
+
+Paste the below to create `gobgpd` configuration file. The `router-id` in this
+example is the IP address of the interface the default route of the host is
+pointing to.
+
+```bash
+DEFAULT_ROUTE_INTERFACE=$(cat /proc/net/route | cut -f1,2 | grep 00000000 | cut -f1)
+DEFAULT_ROUTE_INTERFACE_IPV4=$(ip addr show dev $DEFAULT_ROUTE_INTERFACE | grep "inet " | sed "s/.*inet //" | cut -d"/" -f1)
+BGP_AS=65001
+BGP_PEER=10.0.255.1
+cat << EOF > /etc/gobgpd/gobgpd.conf
+[global.config]
+ as = $BGP_AS
+ router-id = "$DEFAULT_ROUTE_INTERFACE_IPV4"
+
+[[neighbors]]
+ [neighbors.config]
+ neighbor-address = "$BGP_PEER"
+ peer-as = $BGP_AS
+EOF
+chown -R gobgpd:gobgpd /etc/gobgpd/gobgpd.conf
+```
+
+Next, copy the `systemd` unit file, i.e. `gobgpd.service`, in this directory
+to `/usr/lib/systemd/system/`:
+
+```bash
+cp gobgpd.service /usr/lib/systemd/system/
+```
+
+Next, enable and start the `gobgpd` services:
+
+```bash
+systemctl enable gobgpd
+systemctl start gobgpd
+```
+
+If necessary, create an `iptables` rule to allow traffic to `gobgpd` service:
+
+```bash
+iptables -I INPUT 4 -p tcp -m state --state NEW --dport 179 -j ACCEPT
+```
+
+Also, add the following rule into `INPUT` chain in `/etc/sysconfig/iptables`:
+
+```plaintext
+# BGP
+-A INPUT -p tcp -m state --state NEW -m tcp --dport 179 -j ACCEPT
+```
+
+Check the status of the services:
+
+```bash
+systemctl status gobgpd
+```
+
+The logs are available via `journald`:
+
+```bash
+journalctl -u gobgpd.service --since today
+journalctl -u gobgpd.service -r
+```
+
+A user may interract with GoBGP daemon via `gobgp` tool:
+
+```bash
+# gobgp global
+AS: 65001
+Router-ID: 10.0.255.1
+Listening Port: 179, Addresses: 0.0.0.0, ::
+
+# gobgp global rib summary
+Table ipv4-unicast
+Destination: 0, Path: 0
+
+# gobgp neighbor
+Peer AS Up/Down State |#Received Accepted
+10.0.255.1 65001 never Active | 0
+```
diff --git a/tools/contrib/centos/add_gobgpd_account.sh b/tools/contrib/centos/add_gobgpd_account.sh
new file mode 100755
index 00000000..05ee46fe
--- /dev/null
+++ b/tools/contrib/centos/add_gobgpd_account.sh
@@ -0,0 +1,6 @@
+groupadd --system gobgpd
+useradd --system -d /var/lib/gobgpd -s /bin/bash -g gobgpd gobgpd
+mkdir -p /var/{lib,run,log}/gobgpd
+chown -R gobgpd:gobgpd /var/{lib,run,log}/gobgpd
+mkdir -p /etc/gobgpd
+chown -R gobgpd:gobgpd /etc/gobgpd
diff --git a/tools/contrib/centos/gobgpd.service b/tools/contrib/centos/gobgpd.service
new file mode 100644
index 00000000..5aac6d7b
--- /dev/null
+++ b/tools/contrib/centos/gobgpd.service
@@ -0,0 +1,17 @@
+[Unit]
+Description=GoBGP Routing Daemon
+Wants=network.target
+After=network.target
+
+[Service]
+Type=simple
+ExecStartPre=/usr/bin/gobgpd -f /etc/gobgpd/gobgpd.conf -d
+ExecStart=/usr/bin/gobgpd -f /etc/gobgpd/gobgpd.conf
+ExecReload=/usr/bin/gobgpd -r
+StandardOutput=journal
+StandardError=journal
+User=gobgpd
+Group=gobgpd
+
+[Install]
+WantedBy=multi-user.target
diff --git a/tools/contrib/ubuntu/gobgpd.conf b/tools/contrib/ubuntu/gobgpd.conf
new file mode 100644
index 00000000..ba1ef826
--- /dev/null
+++ b/tools/contrib/ubuntu/gobgpd.conf
@@ -0,0 +1,26 @@
+description "GoBGP BGP daemon"
+author "Pavel Odintsov <pavel.odintsov@gmail.com>"
+
+start on (filesystem and net-device-up IFACE=lo)
+stop on runlevel [!2345]
+
+# TODO: use path without version number
+env DAEMON=/usr/sbin/gobgpd
+env CONFIGURATION_FILE=/etc/gobgpd.conf
+env DAEMON_OPTIONS="--disable-stdlog --syslog yes"
+
+#expect fork
+#respawn
+#respawn limit 10 5
+#oom never
+
+# Check configuration before start. You could check result in dmesg output:
+# gobgp pre-start process (12265) terminated with status 1
+pre-start script
+ $DAEMON --dry-run -f $CONFIGURATION_FILE
+ if [ $? -ne 0 ]; then
+ exit $?
+ fi
+end script
+
+exec $DAEMON -f $CONFIGURATION_FILE $DAEMON_OPTIONS
diff --git a/tools/route-server/quagga-rsconfig.go b/tools/route-server/quagga-rsconfig.go
index 517125f3..24ff62c3 100644
--- a/tools/route-server/quagga-rsconfig.go
+++ b/tools/route-server/quagga-rsconfig.go
@@ -11,7 +11,7 @@ import (
"github.com/BurntSushi/toml"
"github.com/jessevdk/go-flags"
- "github.com/osrg/gobgp/config"
+ "github.com/osrg/gobgp/internal/pkg/config"
)
type QuaggaConfig struct {