Skip to content

How to change the control and/or data port for swXtch Components

Last validated:
View as Markdown

Info

WHAT TO EXPECT

In this article, users will learn which control (TCP) and data (UDP) ports the swXtch components use by default, and how to change them with the cloudSwXtch installer.

Default ports

Component Control (TCP) Data (UDP) Configuration file
cloudSwXtch 9443 (httpPort) 9999 (component.dataplaneConfig.dataPort) /var/opt/swx/swxtch/swx-swxtch-config.json
OMNI (wXcked Eye and the System API) 8443 (httpPort) – /var/opt/swx/omni/swx-omni-config.json
xNIC (Linux) Connects to the cloudSwXtch control port (component.installedConnection) 9999 (component.dataPort) /var/opt/swx/xnic/swx-xnic-config.json
swXtchBridge Connects to the cloudSwXtch control port (component.installedConnection.controlAddress) 9999 (component.dataPort) /var/opt/swx/bridge/swx-bridge-config.json

The configuration files are owned by root, except the OMNI one, which belongs to the unprivileged OMNI container user (UID 10443). The xNIC and swXtchBridge configuration files hold the request key their cloudSwXtch issued them, so they are readable by root only (mode 0600); on xNIC Types 1 and 2, the xNIC's own group (swx-xnic) can read it too (mode 0640).

The cloudSwXtch acts as the server: it listens on its control port. The xNICs and swXtchBridges act as clients and open the control connection to the cloudSwXtch. The Linux xNIC does not listen on any TCP port of the VM's network interfaces.

Changing the ports

The ports are set with these cloudSwXtch installer arguments (see the installer help in Cloud agnostic cloudSwXtch Install):

Argument Port Default
--swxtch_port <port> cloudSwXtch control (HTTPS) port the installed one, else 9443
--omni_port <port> OMNI HTTPS port the installed one, else 8443
--data_port <port> cloudSwXtch data (UDP) port the installed one, else 9999

The ports are kept across reinstalls: a reinstall without one of these arguments keeps the port that is already installed. Use the installer arguments instead of editing the configuration files: the host firewall opens only the cloudSwXtch and OMNI ports the installer set.

To change a port on an installed cloudSwXtch, run the installer again with --persist and the new port, for example:

./swx-install.sh --auto_deps --persist --swxtch_port 4300

The installer checks the ports before changing anything. It refuses:

  • ports outside 1-65535, or written with leading zeros;
  • ports the cloudSwXtch uses itself: 443, 7150, 9002-9005 and 10002-10004;
  • the same port for the cloudSwXtch and OMNI.

An OMNI port below 1024 is accepted, but then OMNI runs as root instead of as its unprivileged user, and the installer logs a warning. Use a port of 1024 or above.

What happens after a port change

  • cloudSwXtch control port: the OMNI installed on the same VM adds the cloudSwXtch at its new port and removes the old address. With an OMNI on another VM, the installer prints the swx-cli command to run on the OMNI.
  • xNICs and swXtchBridges do not follow a change of the cloudSwXtch control port. Reinstall each one from the new port: https://<cloudSwXtch-ctrl-ip>:<new-port>/swx/services/install/..., with --persist to keep its identity and approval. The cloudSwXtch's key pin does not change, so its install commands only change in the port (the installer prints them again, and wXcked Eye shows them).
  • Data port: the connected xNICs and swXtchBridges follow the new data port.
  • OMNI port: the cloudSwXtches move to the new OMNI address by themselves, including a cloudSwXtch that was stopped during the change, once it starts.
  • Host firewall: the installer opens the new ports and closes the ones it had opened that are no longer used.
  • On the cloudSwXtch VM, swx-top and swx-cli use the installed ports by default.

Open the new ports in the cloud (Security Groups, Network Security Groups or firewall rules) before changing them.

Clusters and High Availability

Clusters and High Availability configurations store each cloudSwXtch as <ip>:<port>, and they are not updated when its control port changes. The OMNI also keeps the old address while a cluster still uses it. After changing the control port of a cloudSwXtch that is part of a cluster or a High Availability configuration, rebuild those clusters and the High Availability configuration with the new port, and reinstall the xNICs and swXtchBridges.

To avoid this, choose the ports when installing the cloudSwXtch.