Address

Los Angeles, California

Phones

1-844-CLOUDLA 1-844-256-8352

Hours

Mon-Fri 8:00 am to 4:00 pm

SmartOS VM Change IP Address

The expected method for managing VM IP addresses in SmartOS is an orchestration system like Joyent SDC or Project FiFo, but both these systems have enough of a resource overhead that some people may choose to run SmartOS as a stand-alone hypervisor. As SmartOS is primarily a cloud platform it would be detrimental to the sytem to allow VMs to internally specify their own IPs via an API or direct networking, as you wouldn't want customers arbitrarily grabbing any IP they want. This all results in there not really being a quick way to manually set a SmartOS VM IP address.

The basic process isn't dissimilar from the manual VM provisioning process, you create a JSON file and use the vmadm command to apply it. Within the JSON file you can choose to update the vNIC (update_nics), or you can remove the existing vNIC and re-add it (remove_nics/add_nics). I find the whole process more reliable when I remove and re-add the vNIC so that's what I'll document here.


Enumerate your VMs so you know your VM UUID.

vmadm list
UUID                                  TYPE  RAM      STATE             ALIAS

a59abbdf-c35e-4ef4-a353-0776524a0511  OS    4096     running           site1

Enumerate your VM vNIC information.

vmadm get a59abbdf-c35e-4ef4-a353-0776524a0511 | json nics
[
  {
    "interface": "net0",
    "mac": "12:22:32:e0:a1:f2",
    "vlan_id": 1,
    "nic_tag": "admin",
    "gateway": "10.0.0.1"
    "ip": "10.0.0.11",
    "netmask": "255.255.0.0",
    "primary": true
  }
]

Create a JSON file in the format below using the values from your VM that you got in the previous step, and edit the values you want to change in your VMs vNIC.

vi /opt/add_nic.json
{
 "add_nics":[
 {
 "interface": "net0",
 "mac": "12:22:32:e0:a1:f2",
 "vlan_id": "2",
 "nic_tag": "admin",
 "gateway": "10.0.0.2",
 "ip": "10.0.0.12",
 "netmask": "255.255.0.0",
 "primary": "true"
 }
]
}

Note: If you're using an external text editor like TextEdit be careful it doesn't fix-up your quotes into “” (wavy quotes) as this will cause an error when processing the JSON file.

Invalid JSON payload: Unexpected token “

Remove the exiting vNIC.

echo '{"remove_nics": ["12:22:32:e0:a1:f2"]}' | vmadm update a59abbdf-c35e-4ef4-a353-0776524a0511
Successfully updated VM a59abbdf-c35e-4ef4-a353-0776524a0511

Re-add the vNIC using the JSON file you created earlier.

vmadm update a59abbdf-c35e-4ef4-a353-0776524a0511 -f /opt/add_nic.json
Successfully updated VM a59abbdf-c35e-4ef4-a353-0776524a0511

Now login to the VM and reboot it.

zlogin a59abbdf-c35e-4ef4-a353-0776524a0511
reboot

That should just about do it, when your VM comes back up it's new IP should be fully functional.

 

No Comments Yet.

Leave a comment