Managing logical networks on the platform

The hosting infrastructure on the device creates multiple logical networks based on the platform configuration.

Refer network related documentation for your platform for more details.

ioxclient provides commands to manage these logical networks.

$ ./ioxclient  platform network
NAME:
   ioxclient platform network - Manage logical networks on the platform

USAGE:
   ioxclient platform network command [command options] [arguments...]

COMMANDS:
   list, li			List all available networks
   info, inf			View information pertaining a network
   getconfig, gconf		Get Network Configuration
   setconfig, sconf		Set Network Configuration. Pass a json file containing new config
   getmacregistry, macreg	View Current MAC/Hardware address allocation information
   getportregistry, portreg	View Current Port allocation information
   getdefaultnetwork, gdn	View the current default network in the system
   setdefaultnetwork, sdn	Set default network in the system. Pass a file with appropriate JSON payload
   bridge, br			Manage network bridges on the platform
   help, h			Shows a list of commands or help for one command

OPTIONS:
   --help, -h			show help
   --generate-bash-completion

Listing networks available on the device

$ ./ioxclient  platform network list
Currently active profile :  local
Command Name: plt-network-list
List of networks:
 1. name=>iox-bridge0     :: type=>bridge, source_bridge=>svcbr_0
 2. name=>iox-nat0        :: type=>nat, source_bridge=>svcbr_0

Get information pertaining to a network

$ ./ioxclient  platform network info iox-nat0
Currently active profile :  local
Command Name: plt-network-info
Details of the network: iox-nat0
-----------------------------
{
 "app_ip_map": {},
 "description": "Maja Maja Network - nat",
 "external_interface": "VPG0",
 "gateway_ip": "192.168.40.33",
 "ip_end": "192.168.40.62",
 "ip_start": "192.168.40.34",
 "name": "iox-nat0",
 "nat_range_cidr": "192.168.40.32/27",
 "network_type": "nat",
 "private_route_table": "10",
 "repofolder": "/sw/opt/cisco/caf/work/network",
 "source_linux_bridge": "svcbr_0",
 "subnet_mask": "255.255.255.224"
}

List hosting bridges on the system

Logical networks are created based on the bridges configured for application hosting. To list:

$ ./ioxclient  platform network bridge list
Currently active profile :  local
Command Name: plt-network-bridge-list
List of hosting bridges:
[
 {
  "bridge_ip": {
   "mode": "dhcp"
  },
  "default_mode": "bridge",
  "description": "Maja Maja Network",
  "dynamically_created": false,
  "external_interface": "VPG0",
  "interface": "svcbr_0",
  "interface_info": {
   "interface_name": "svcbr_0",
   "ipv4_address": "192.168.196.128",
   "ipv6_address": "fe80::20c:29ff:fe2d:27ab/64",
   "mac_address": "00:0c:29:2d:27:ab",
   "status": "UP",
   "subnet_mask": "255.255.255.0"
  },
  "lease_info": {
   "dns": "192.168.196.2",
   "domain_name": "\"cisco.com\"",
   "fixed_address": "192.168.196.128",
   "routers": "192.168.196.2",
   "subnet_mask": "255.255.255.0"
  },
  "logical_network_info": {
   "iox-bridge0": {
    "type": "bridge"
   },
   "iox-nat0": {
    "gateway_ip": "192.168.40.33",
    "ip_end": "192.168.40.62",
    "ip_range": "192.168.40.34-192.168.40.62",
    "ip_start": "192.168.40.34",
    "nat_range_cidr": "192.168.40.32/27",
    "subnet_mask": "255.255.255.224",
    "type": "nat"
   }
  },
  "supported_modes": [
   "nat",
   "bridge"
  ],
  "vlan_id": null
 }
]

Get information from a bridge

$ ./ioxclient  platform network bridge info svcbr_0
Currently active profile :  local
Command Name: plt-network-bridge-info
Bridge Details:
-----------------------------
{
 "bridge_ip": {
  "mode": "dhcp"
 },
 "default_mode": "bridge",
 "description": "Maja Maja Network",
 "dynamically_created": false,
 "external_interface": "VPG0",
 "interface": "svcbr_0",
 "interface_info": {
  "interface_name": "svcbr_0",
  "ipv4_address": "192.168.196.128",
  "ipv6_address": "fe80::20c:29ff:fe2d:27ab/64",
  "mac_address": "00:0c:29:2d:27:ab",
  "status": "UP",
  "subnet_mask": "255.255.255.0"
 },
 "lease_info": {
  "dns": "192.168.196.2",
  "domain_name": "\"cisco.com\"",
  "fixed_address": "192.168.196.128",
  "routers": "192.168.196.2",
  "subnet_mask": "255.255.255.0"
 },
 "logical_network_info": {
  "iox-bridge0": {
   "type": "bridge"
  },
  "iox-nat0": {
   "gateway_ip": "192.168.40.33",
   "ip_end": "192.168.40.62",
   "ip_range": "192.168.40.34-192.168.40.62",
   "ip_start": "192.168.40.34",
   "nat_range_cidr": "192.168.40.32/27",
   "subnet_mask": "255.255.255.224",
   "type": "nat"
  }
 },
 "supported_modes": [
  "nat",
  "bridge"
 ],
 "vlan_id": null
}

Creating new networks

If your platform supports, new networks can be created and configured. To do so, you will need to create a bridge on an appropriate physical interface by passing the right JSON payload.

Here is the command help:

$ ./ioxclient  platform network bridge create
NAME:
   create - Create logical networks

USAGE:
   command create <json_file_with_input>

DESCRIPTION:

To create a network, pass a JSON file containing appropriate payload.
Below is a sample payload.
{
    "description": "Dynamic Network",
    "vlan_id": "10",
    "external_interface": "intsvc0",
    "supported_modes": ["nat", "bridge"],
    "bridge_ip": {
        "mode": "static",
        "ip": "192.168.0.15",
        "subnet_mask": "255.255.255.0",
        "bridge_gw_ip": "192.168.0.1",
        "dns": "8.8.4.4",
        "domain": "abc.com"
    },
    "nat": {
        "nat_range_cidr": "192.168.10.32/27"
    }
}
*vlan_id is optional
*mode can be static or dhcp. In case of dhcp, ip, bridge_gw_ip, dns, domain etc., are not needed.

Here is a sample CLI interaction to create a new bridge. This will result in automatic creation of bridge svcbr_1 and bridge and nat logical networks on top of it.

Sample payload:

$ cat test_resources/br_create.json
{
    "description": "Dynamic Network",
    "vlan_id": "10",
    "external_interface": "eth0",
    "supported_modes": ["nat", "bridge"],
    "bridge_ip": {
        "mode": "static",
        "ip": "192.168.0.15",
        "subnet_mask": "255.255.255.0",
        "bridge_gw_ip": "192.168.0.1",
        "dns": "8.8.4.4",
        "domain": "abc.com"
    },
    "nat": {
        "nat_range_cidr": "192.168.10.32/27"
    }
}
$ ./ioxclient  platform network bridge create test_resources/br_create.json
Currently active profile :  local
Command Name: plt-network-bridge-create
Payload file : test_resources/br_create.json. Will pass it as application/json in request body..
Network creation successful. Bridge is available at :  https://127.0.0.1:8443/iox/api/v2/hosting/platform/networks/hosting_bridges/svcbr_1

$ ./ioxclient  platform network list
Currently active profile :  local
Command Name: plt-network-list
List of networks:
 1. name=>iox-bridge1     :: type=>bridge, source_bridge=>svcbr_1
 2. name=>iox-bridge0     :: type=>bridge, source_bridge=>svcbr_0
 3. name=>iox-nat0        :: type=>nat, source_bridge=>svcbr_0
 4. name=>iox-nat1        :: type=>nat, source_bridge=>svcbr_1

Edit networks

It is possible to edit network configuration. Refer to the help below:

$ ./ioxclient  platform network bridge edit
Insufficient Args.

NAME:
   edit - Edit information pertaining a bridge

USAGE:
   command edit <bridge_id> <json_file_with_input>

DESCRIPTION:

Currently it is allowed only to change description and nat range of a network.
Below is a sample JSON payload.
{
    "description": "Dynamic Network",
    "nat": {
        "nat_range_cidr": "192.168.10.32/27"
    }
}

Deleting networks

Dynamically created/configured networks can be deleted. Below, we delete svcbr_1, which causes the iox-bridge1 and iox-nat1 to be deleted.

$ ./ioxclient  platform network bridge delete svcbr_1
Currently active profile :  local
Command Name: plt-network-bridge-delete
Networks on bridge %s deleted successfully! svcbr_1

$ ./ioxclient  platform network list
Currently active profile :  local
Command Name: plt-network-list
List of networks:
 1. name=>iox-bridge0     :: type=>bridge, source_bridge=>svcbr_0
 2. name=>iox-nat0        :: type=>nat, source_bridge=>svcbr_0

Get network configuration

To view the current network configuration of the platform:

~$ ioxclient  platform network getconfig
Currently using profile :  default
Command Name: plt-network-getconfig
Current Network Configuration:
-------------------------------------
{
 "default_bridge": "svcbr_0",
 "enabled": true,
 "host_mode": false,
 "hosting_bridges": {
  "svcbr_0": {
   "default_mode": "bridge",
   "dhcp_lease_file": "/var/lib/dhcp/dhclient.svcbr_0.leases",
   "external_interface": "VPG0",
   "nat": {
    "gateway_ip": "192.168.223.1",
    "ip_range": "192.168.223.10-192.168.223.254",
    "setup_private_routing": false,
    "subnet_mask": "255.255.255.0"
   },
   "supported_modes": [
    "nat",
    "bridge"
   ]
  }
 },
 "local_mac_registry": true,
 "network_name_prefix": "iox",
 "tcp_pat_port_range": "40000-41000",
 "udp_pat_port_range": "42000-43000"
}

Setting network configuration

Currently setting network configuration is not allowed. This section will be updated when it is supported.

Get MAC registry mapping

You can view the MAC Registry maintained by the platform that associates an app with a MAC address.

~$ ioxclient  platform network getmacregistry
Currently using profile :  default
Command Name: plt-network-getmacregistry
Mac Registry:
-------------------------------------
{
 "generated_addresses": [
  "52:54:99:99:00:00"
 ],
 "registry": {
  "nettest": {
   "eth0": {
    "mac_address": "52:54:99:99:00:00",
    "network_name": "iox-nat0"
   }
  }
 }
}

Get port registry mapping

You can view the port registry metadata that maintains port mapping for apps.

~$ ioxclient  platform network getportregistry
Currently using profile :  default
Command Name: plt-network-getportregistry
Port Registry:
-------------------------------------
{
 "PORT_REGISTRY": {
  "nettest": {
   "eth0": {
    "mappings": {
     "tcp": [
      [
       9000,
       40003
      ]
     ],
     "udp": [
      [
       10000,
       42003
      ]
     ]
    },
    "network_type": "nat"
   }
  },
 }
}

Get default network on the platform

Out of the available logical networks, one of them will be used as a default network.

To view this information:

~$ ioxclient  platform network getdefaultnetwork
Currently using profile :  default
Command Name: plt-network-getdefaultnetwork
Default Network:
-------------------------------------
{
 "default_network": "iox-bridge0"
}

Set default network on the platform

The default network can also be set by supplying the right payload. In the below case, we are sending a json file that has the following:

# File:
{
    "default_network": "iox-nat0"
}

Use :

~$ ioxclient  platform network setdefaultnetwork dn.json
Currently using profile :  default
Command Name: plt-network-setdefaultnetwork
Payload file : dn.json. Will pass it as application/json in request body..
Default Network:
-------------------------------------
{
 "default_network": "iox-nat0"
}