Updating NIC properties in SmartOS

A long time ago I provisioned a container for development processes but I used static ip address instead of just using dhcp.

UUID                                  TYPE  RAM      STATE             ALIAS
f86adbd1-f00d-45f9-bbff-326206f13264  LX    256      running           minecraft_bedrock
2d1bd872-ff7b-423f-a4c0-5a7e8767bb14  OS    1024     running           bcontrol
a234ec28-2af2-4640-890b-185210f8fc7b  OS    8192     running           illumos-dev

Luckily updating attributes for a container is easy in SmartOS. In my case I just want to update the ip address and gateway for the container. To accomplish that we just need to pass the tag 'update_nics' to vmadm and specify the attributes that are going to change. But first we need to validate that our update object is properly defined, using vmadm validate.

echo ' {"update_nics": [ {"gateways": ["192.168.0.3"], "ips": ["192.168.0.155/24"] , "mac": "72:75:cc:10:d7:81" } ] }' | vmadm validate  update joyent

My zone is of type joyent so I'm using that so the validate function will use that container type spec to validate against my proposed update. The result should be:

VALID 'update' payload for joyent brand VMs.

Now we can confidently apply our change

[root@dev01 ~]# echo ' {"update_nics": [ {"gateways": ["192.168.0.3"], "ips": ["192.168.0.155/24"] , "mac": "72:75:cc:10:d7:81" } ] }' | vmadm update a234ec28-2af2-4640-890b-185210f8fc7b
Successfully updated VM a234ec28-2af2-4640-890b-185210f8fc7b

The next time the container is started, the changes will be applied. As I'm not doing anything at this moment on that zone I'll rebooted.

[root@dev01 ~]# vmadm reboot a234ec28-2af2-4640-890b-185210f8fc7b
Successfully completed reboot for VM a234ec28-2af2-4640-890b-185210f8fc7b

Now let's check if the update worked.

[root@dev01 ~]# zlogin a234ec28-2af2-4640-890b-185210f8fc7b
[Connected to zone 'a234ec28-2af2-4640-890b-185210f8fc7b' pts/3]
Last login: Mon Mar  4 12:08:57 on pts/3
   __        .                   .
 _|  |_      | .-. .  . .-. :--. |-
|_    _|     ;|   ||  |(.-' |  | |
  |__|   `--'  `-' `;-| `-' '  ' `-'
                   /  ; Instance (base-64-lts 21.4.0)
                   `-'  https://docs.joyent.com/images/smartos/base

[root@a234ec28-2af2-4640-890b-185210f8fc7b ~]# ifconfig -a
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
        inet 127.0.0.1 netmask ff000000
net0: flags=40001000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4,L3PROTECT> mtu 1500 index 2
        inet 192.168.0.155 netmask ffffff00 broadcast 192.168.0.255
        ether 72:75:cc:10:d7:81
lo0: flags=2002000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv6,VIRTUAL> mtu 8252 index 1
        inet6 ::1/128
[root@a234ec28-2af2-4640-890b-185210f8fc7b ~]#

There are more examples like this in VMADM(8) manpage.

Bordsdelacote.png

Figure 1: Bords de la côte à Saint-Jean-du-Doigt, Bretagne (1895)

powered64.png

References