SmartOS: Modify network/nic settings of a smartmachine with vmadm

Written by - 0 comments

Published on - Listed in Unix Solaris SmartOS


A few days ago I needed to change the IP address of a SmartOS smartmachine. As a smartmachine is a virtualization method (Solaris zones), the physical host (= compute node) should be aware of the changes and therefore be used to change the NIC settings of the smartmachine.

I expected some simple config file (like LXC) or command to change the IP. Turns out, it's a little bit more complicated.

First of all, let's get the current NIC configuration of the smartmachine you want to change (let's call it smartmachine412).
To be able to list the settings, we must use the UUID of the smartmachine, not it's alias name. With vmadm list you can see the UUID:

vmadm list -v

UUID                                  TYPE  RAM    STATE    ALIAS
5746bdfe-481f-4b11-b77c-f34ef10f1c61  OS    8192   running  smartmachine412
58306c2e-6cb3-4294-8a03-694af544461f  OS    8192   running  smartmachine410
03404289-c602-4550-a450-7f887e04be16  OS    16384  running  smartmachine402
da17d097-6a45-4a84-ba48-5306e784da7e  OS    65536  running  smartmachine995

So our smartmachine has the UUID 5746bdfe-481f-4b11-b77c-f34ef10f1c61. Let's list the current NIC settings:

vmadm get 5746bdfe-481f-4b11-b77c-f34ef10f1c61 | json nics
[
  {
    "interface": "net0",
    "mac": "72:1d:2c:f3:ca:b2",

    "vlan_id": 251,
    "nic_tag": "backend",
    "primary": true,
    "ip": "10.11.25.195",

    "netmask": "255.255.255.0"
  },
  {
    "interface": "net1",
    "mac": "72:1d:2c:f3:ca:b5",

    "vlan_id": 250,
    "nic_tag": "frontend",
    "ip": "10.10.25.195",
    "netmask": "255.255.255.0"
  }
]

The output is in json format and shows the current IP addresses, VLAN tags, interface naming, etc.

To change the settings, it is mandatory to create a new json file which contains the changes to apply.

So I want to add a default gateway to the "net1" interface with the virtual MAC address 72:1d:2c:f3:ca:b5. To make this gateway the default gateway, I also have to set this NIC as primary interface.
The following json file documents the two changes I want to apply:

cat update-nics.json
{
    "update_nics": [
        {
            "mac": "72:1d:2c:f3:ca:b5",

            "gateway": "10.0.250.1",
            "primary": true
        }
    ]
}

The content of this json file now needs to be sent as vmadm update command to the destination smartmachine:

cat update-nics.json | vmadm update 5746bdfe-481f-4b11-b77c-f34ef10f1c61

Let's check out the new settings:

vmadm get 5746bdfe-481f-4b11-b77c-f34ef10f1c61 | json nics
[
  {
    "interface": "net0",
    "mac": "72:1d:2c:f3:ca:b2",

    "vlan_id": 251,
    "nic_tag": "backend",
    "ip": "10.11.25.195",

    "netmask": "255.255.255.0"
  },
  {
    "interface": "net1",
    "mac": "72:1d:2c:f3:ca:b5",

    "vlan_id": 250,
    "nic_tag": "frontend",
    "gateway": "10.0.250.1",
    "primary": true,
    "ip": "10.10.25.195",
    "netmask": "255.255.255.0"
  }
]

Note that the net1 interface now contains the "gateway" definition and it was set as the "primary" interface.

To make these changes live, the smartmachine needs to be rebooted afterwards.


Add a comment

Show form to leave a comment

Comments (newest first)

No comments yet.

RSS feed

Blog Tags:

  AWS   Android   Ansible   Apache   Apple   Atlassian   BSD   Backup   Bash   Bluecoat   CMS   Chef   Cloud   Coding   Consul   Containers   CouchDB   DB   DNS   Database   Databases   Docker   ELK   Elasticsearch   Filebeat   FreeBSD   Galera   Git   GlusterFS   Grafana   Graphics   HAProxy   HTML   Hacks   Hardware   Icinga   Influx   Internet   Java   KVM   Kibana   Kodi   Kubernetes   LVM   LXC   Linux   Logstash   Mac   Macintosh   Mail   MariaDB   Minio   MongoDB   Monitoring   Multimedia   MySQL   NFS   Nagios   Network   Nginx   OSSEC   OTRS   Office   OpenSearch   PGSQL   PHP   Perl   Personal   PostgreSQL   Postgres   PowerDNS   Proxmox   Proxy   Python   Rancher   Rant   Redis   Roundcube   SSL   Samba   Seafile   Security   Shell   SmartOS   Solaris   Surveillance   Systemd   TLS   Tomcat   Ubuntu   Unix   VMWare   VMware   Varnish   Virtualization   Windows   Wireless   Wordpress   Wyse   ZFS   Zoneminder