Skip to content

swx-where

Last validated:
View as Markdown

WHAT TO EXPECT

swx-where tells in which cloud a VM is running. With --format json it also reports the region, the instance type and the network interfaces of the VM, and which of them it considers the control and the data interface.

In this article, users will learn about the arguments of swx-where and the output they should expect.

Where swx-where is installed

swx-where is installed with the xNIC, on Linux (/usr/bin/swx-where) and on Windows (swx-where.exe in the xNIC folder, on the PATH), and on the cloudSwXtch VM. On Linux it runs without sudo.

swx-where Cloud Type

Called with no arguments, swx-where prints the cloud type only:

$ swx-where
AWS

On Windows:

PS C:\> swx-where
AWS

The cloud types are AWS, AZURE, GCP, OCI and ALIBABA. swx-where finds the cloud by querying the instance metadata service of each cloud, so the VM must be able to reach it (for example, 169.254.169.254).

NOTE

On Linux, the short output does not end with a new line, so the shell prompt appears right after the cloud name. Use echo $(swx-where) if that is a problem in a script.

NOTE

To run swx-where on a swXtchBridge, use: docker exec -it swx-bridge swx-where.

swx-where Format

--format json (-f json) returns the full information. json is the only format:

Example: Detailed output on an AWS VM with an xNIC (control and data interfaces)

$ swx-where -f json
{
  "cloudType": "AWS",
  "imdsProbeResults": {
    "ALIBABA": 0,
    "AWS": 200,
    "AZURE": 401,
    "GCP": 401,
    "OCI": 401
  },
  "instanceType": "c7a.xlarge",
  "nics": [
    {
      "computed": {
        "isPreferredControlNic": true,
        "isPreferredDataNic": false,
        "isSRIOV": false
      },
      "meta": {
        "ipAddress": "172.31.85.32",
        "ipBroadcast": "172.31.95.255",
        "ipSubnet": "172.31.80.0",
        "mac": "06:42:b7:fa:58:99",
        "subnetMask": "255.255.240.0",
        "vpc": "vpc-0dd3720d5088eadf6"
      },
      "os": {
        "driver": "ena",
        "ifIndex": 2,
        "ipAddress": "172.31.85.32",
        "ipBroadcast": "172.31.95.255",
        "ipSubnet": "172.31.80.0",
        "mac": "06:42:b7:fa:58:99",
        "mtu": 9001,
        "name": "enp39s0",
        "pciAddress": "0000:27:00.0",
        "state": "up",
        "subnetMask": "255.255.240.0"
      }
    },
    {
      "computed": {
        "isPreferredControlNic": false,
        "isPreferredDataNic": true,
        "isSRIOV": false
      },
      "meta": {
        "ipAddress": "172.31.101.242",
        "ipBroadcast": "172.31.111.255",
        "ipSubnet": "172.31.96.0",
        "mac": "06:b5:f5:70:2e:67",
        "subnetMask": "255.255.240.0",
        "vpc": "vpc-0dd3720d5088eadf6"
      },
      "os": {
        "driver": "ena",
        "ifIndex": 3,
        "ipAddress": "172.31.101.242",
        "ipBroadcast": "172.31.111.255",
        "ipSubnet": "172.31.96.0",
        "mac": "06:b5:f5:70:2e:67",
        "mtu": 3900,
        "name": "enp40s0",
        "pciAddress": "0000:28:00.0",
        "state": "up",
        "subnetMask": "255.255.240.0"
      }
    }
  ],
  "region": "us-east-2",
  "version": "a966e92fabb019088be5492e717e84eb87fe7fb0/2026-09-28T00:57:18Z"
}
Field Description
cloudType The cloud the VM runs in
imdsProbeResults The HTTP code returned by the metadata service of each cloud. In the example, only AWS answered 200
instanceType The VM size, as the cloud names it (for example c7a.xlarge)
region The cloud region (for example us-east-2)
nics One entry per network interface of the VM (see below)
version Build information of swx-where

Each entry in nics has three parts:

Part Description
meta What the cloud metadata service reports for the interface: IP address, subnet, broadcast address, MAC address and virtual network (vpc)
os What the operating system reports: interface name, index, driver, PCI address, MTU and state
computed isPreferredControlNic and isPreferredDataNic mark the interfaces that swx-where considers the control and the data interface; isSRIOV tells whether the interface uses SR-IOV

This helps to check that a VM has the expected interfaces, in the expected subnets, before installing an xNIC or a cloudSwXtch, and to confirm which interface is the data interface.

NOTE

On a cloudSwXtch, the data interface is bound to the DPDK driver, so the operating system no longer sees it as a network interface. Its os part shows only the driver (for example igb_uio) and the PCI address.

NOTE

The output can be saved to a file with the > redirector. For example, to save the JSON report to a file named report.json:

swx-where -f json > report.json

Region display names

--regionsFile (-r) adds a regionDisplayName field with a friendly name for the region. The file maps each cloud type to its regions:

{
    "AWS":   { "us-east-2": "US East (Ohio)", "us-east-1": "US East (N. Virginia)" },
    "AZURE": { "eastus": "East US" }
}

Example: Detailed output with the region display name (trimmed)

$ swx-where -f json -r regions.json
{
  "cloudType": "AWS",
  ...
  ],
  "region": "us-east-2",
  "regionDisplayName": "US East (Ohio)",
  "version": "a966e92fabb019088be5492e717e84eb87fe7fb0/2026-09-28T00:57:18Z"
}

PLEASE NOTE

--regionsFile only works together with --format json, and the file must be valid JSON. Otherwise swx-where stops with an error.

Arguments

$ swx-where -h
Usage: swx-where [--help] [--version] [--format VAR] [--regionsFile VAR]

swx-where utility.
Calling with no arguments simply returns the cloud type.

Optional arguments:
  -h, --help         shows help message and exits
  -v, --version      prints version information and exits
  -f, --format       output format (example: "json")
  -r, --regionsFile  Path to a JSON file containing the cloud regions display names. [nargs=0..1] [default: ""]

-v (--version) prints the version of the tool.