Skip to content

Adding custom routes to containers

Create script file

Create the file /usr/local/bin/add-routes.sh with the contents

#!/bin/bash
ip route add 10.60.21.0/24 via 10.60.12.1 || true
# Add more routes as above
## The ` || True` ignores errors
Make the script executable

chmod +x /usr/local/bin/add-routes.sh

Create service file

Create the file /etc/systemd/system/ocs-add-routes.service with the contents

[Unit]
Description=Add custom routes for OCS services
After=network-online.target
Wants=network-online.target

[Service]
Type=oneshot
ExecStart=/usr/local/bin/add-routes.sh
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

Reload and enable services

systemctl daemon-reload
systemctl enable --now ocs-add-routes