Skip to content

How to Run a bridge as a service on Ubuntu 20.04 LTS

Last validated:
View as Markdown

This Document shows how to set up the swXtch-bridge application running as a service on Ubuntu 20.04.

To Run a Bridge as a Service, you will first need to provision a VM/Agent and install the swXtch-bridge application. These steps can be found in the User Manual.

After installing the swXtch-bridge application, you will need to follow the below steps to configure your bridge service.

Create the service and change its permission to become an executable file:

sudo touch /etc/systemd/system/bridge.service
sudo chmod 664 /etc/systemd/system/bridge.service

Edit the service file:

sudo vim /etc/systemd/system/bridge.service
[Unit] Description=swXtch.io bridge service After=syslog.target After=network.target

[Service] Type=simple ExecStart=/usr/local/bin/bridge2.sh

[Install] WantedBy=default.target

Note: on the ExecStart line you must put the full path of the script or command to run.

Enable the Service:

Before enabling the service, you can check the current status of it by running this command:

sudo systemctl status bridge.service
The below screenshot shows that the service is currently “disabled”

disabled service.png

Now run the below commands:

cd /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable bridge.service
Confirm Bridge Service is active:
sudo systemctl status bridge.service

active bridge.png

Create the shell script and assign the necessary permissions:

sudo touch /usr/local/bin/bridge2.sh
sudo chmod 744 /usr/local/bin/bridge2.sh
Next, edit it with the command below:
sudo vim /usr/local/bin/bridge2.sh
#!/bin/bash
#Sleep startup to allow xnic program to boot so you can utilize swxtch-tun0 ip
sleep 10s
swxtch-bridge --input multicast://239.5.69.2:172.30.0.42:10000,multicast://239.5.69.3:172.30.0.42:10000 --output udp://10.2.153.4:9999 --override-multicast-sender-ip 172.30.1.1 --last-leg &
swxtch-perf producer --pps 1000

Reboot VM and Confirm Service booted at Startup as Expected

sudo reboot
sudo systemctl status Bridge.service
service start.png

The above screenshot shows the bridge status is “enabled” and that upon boot the system ran the executable command given in the service file to succession. The Bridge upon boot is performing the following actions:

  1. Receiving traffic from a swXtch in the same upstream subnet via 2 multicast groups - 239.5.69.2 & 239.5.69.3

  2. Pushing that traffic at 1k pps to the downstream swXtch that resides on a different subnet.

Next, Set an Agent on a downstream subnet to listen to the downstream swXtch for the traffic being pushed from that upstream bridge as seen above

To do this, you can run the below command on any agent in your downstream swXtch subnet to consume the traffic being sent:

swxtch-perf consumer
You can now monitor the flow of this traffic by running the “swxtch-top” command on any of your downstream or upstream agents that have the xNIC program installed to be able to see the flow of traffic. The screenshot below shows that your upstream bridge is now transmitting traffic to your downstream swXtch and the packets are being consumed by a downstream agent.

1.png

2.png

This document shows how you can achieve the flow of multicast traffic from one upstream bridge to a downstream swXtch using an Ubuntu Agent running v. 20.04 LTS