Routen in Zonen

Dieser Beitrag ist im Dezember 2017 erschienen


Nur damit ich weiss, wo ich es künftig nachschlagen kann: Es kann notwendig sein, in SmartOS Zonen statische Routen zu setzen (z. B. damit die CNS-Instanzen von Triton über das Admin-Netz zu ihren DNS-Servern finden oder damit die ufds-Instanzen ihr Master-DC finden). Wenn man das "per Hand" macht, sind diese Routen beim nächsten Update wieder weg. Insbesondere bei verknüpften Datacentern führt das dann dazu, das z. B. das Update der cloudapi-Zone "hängt", weil das ufds des Master-DCs ohne die statische Route über das Netz nicht erreicht werden kann. Aber zum Glück hält SmartOS auch dafür eine Lösung bereit:

[root@headnode (de-gt-1) ~]# echo '{"set_routes": {"10.64.64.252/32":"10.64.244.1"}}' | vmadm update d3a942fb-4012-47cd-99a5-0cc6b7382e1e

Damit wird eine Host-Route für 10.64.64.252 gesetzt. In der Konfiguration der Zone sieht das dann so aus (unter "routes" findet man den Eintrag):

[root@headnode (de-gt-1) ~]# vmadm get d3a942fb-4012-47cd-99a5-0cc6b7382e1e
{
  "zonename": "d3a942fb-4012-47cd-99a5-0cc6b7382e1e",
  "autoboot": true,
  "brand": "joyent-minimal",
  "limit_priv": "default",
  "v": 1,
  "create_timestamp": "2017-08-08T12:49:24.590Z",
  "cpu_shares": 8,
  "max_lwps": 1000,
  "max_msg_ids": 4096,
  "max_sem_ids": 4096,
  "max_shm_ids": 4096,
  "max_shm_memory": 1024,
  "zfs_io_priority": 10,
  "max_physical_memory": 1024,
  "max_locked_memory": 1024,
  "max_swap": 2048,
  "cpu_cap": 300,
  "billing_id": "4769a8f9-de51-4c1e-885f-c3920cc68137",
  "tmpfs": 1024,
  "dns_domain": "local",
  "archive_on_delete": true,
  "maintain_resolvers": true,
  "alias": "cns0",
  "datasets": [
    "zones/d3a942fb-4012-47cd-99a5-0cc6b7382e1e/data"
  ],
  "owner_uuid": "930896af-bf8c-48d4-885c-6573a94b1853",
  "resolvers": [
    "10.64.244.9",
    "8.8.8.8",
    "8.8.4.4"
  ],
  "nics": [
    {
      "interface": "net0",
      "mac": "90:b8:d0:56:3a:b0",
      "vlan_id": 0,
      "nic_tag": "admin",
      "netmask": "255.255.255.0",
      "ip": "10.64.244.36",
      "ips": [
        "10.64.244.36/24"
      ],
      "network_uuid": "79891760-0cc4-4f8f-bc38-91db6ce8641e",
      "mtu": 1500
    },
    {
      "interface": "net1",
      "mac": "90:b8:d0:7b:45:f5",
      "vlan_id": 0,                     
      "nic_tag": "external",                                 
      "gateway": "10.64.243.1",                             
      "gateways": [                                         
        "10.64.243.1"                                       
      ],                                                     
      "netmask": "255.255.255.0",                           
      "ip": "10.64.243.11",                                 
      "ips": [                         
        "10.64.243.11/24"                                   
      ],                                                     
      "network_uuid": "ef52869b-07cc-41b9-9458-9ddebe883e89",  
      "mtu": 1500,                                           
      "primary": true                                       
    }                                                       
  ],                                                         
  "image_uuid": "bd9188a2-8369-11e7-b625-b77991ba0370",     
  "uuid": "d3a942fb-4012-47cd-99a5-0cc6b7382e1e",           
  "zone_state": "running",                                   
  "zonepath": "/zones/d3a942fb-4012-47cd-99a5-0cc6b7382e1e",  
  "zoneid": 76,                                             
  "last_modified": "2017-08-18T16:37:43.000Z",               
  "firewall_enabled": false,                                 
  "server_uuid": "c4435f5a-3606-4210-9a0a-93f09eb8577a",     
  "datacenter_name": "de-gt-1",                             
  "platform_buildstamp": "20170719T235533Z",                 
  "state": "running",                                       
  "boot_timestamp": "2017-08-18T13:14:49.000Z",             
  "pid": 9396,                                               
  "customer_metadata": {                                     
    "sapi-url": "http://10.64.244.29",                       
    "user-script": "#!/usr/bin/bash\n#\n# This Source Code Form is subject to the terms of the Mozilla Public\n# License, v. 2.0. If a copy of the MPL was not distributed with this\n# file, You can obtain one at http://mozilla.org/MPL/2.0/.\n#\n\n#\n# Copyright (c) 2014, Joyent, Inc.\n#\n\nexport PS4='[\\D{%FT%TZ}] ${BASH_SOURCE}:${LINENO}: ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'\n\nset -o xtrace\nset -o errexit\nset -o pipefail\n\n#\n# The presence of the /var/svc/.ran-user-script file indicates that the\n# instance has already been setup (i.e. the instance has booted previously).\n#\n# Upon first boot, run the setup.sh script if present. On all boots including\n# the first one, run the configure.sh script if present.\n#\n\nSENTINEL=/var/svc/.ran-user-script\n\nDIR=/opt/smartdc/boot\n\nif [[ ! -e ${SENTINEL} ]]; then\n    if [[ -f ${DIR}/setup.sh ]]; then\n        ${DIR}/setup.sh 2>&1 | tee /var/svc/setup.log\n    fi\n\n    touch ${SENTINEL}\nfi\n\nif [[ ! -f ${DIR}/configure.sh ]]; then\n    echo \"Missing ${DIR}/configure.sh cannot configure.\"\n    exit 1\nfi\n\nexec ${DIR}/configure.sh\n", 
    "assets-ip": "10.64.244.6"                               
  },                                                         
  "internal_metadata": {},                                   
  "routes": {                                               
    "10.64.64.125/32": "10.64.244.1",                       
    "10.64.64.252/32": "10.64.244.1"                         
  },                                                         
  "tags": {                                                 
    "smartdc_role": "cns",                                   
    "smartdc_type": "core"                                   
  },                                                         
  "quota": 25,                                               
  "zfs_root_compression": "lz4",                             
  "zfs_root_recsize": 131072,                               
  "zfs_filesystem": "zones/d3a942fb-4012-47cd-99a5-0cc6b7382e1e",  
  "zpool": "zones",                                         
  "zfs_data_compression": "lz4",                             
  "zfs_data_recsize": 131072,                               
  "snapshots": []                                           
}

Falls man sich vertippt oder einfach eine Route wieder löschen will, funktioniert das z. B. wie folgt:

[root@headnode (de-gt-2) ~]# echo '{"remove_routes": ["10.64.244.0/24"]}' | vmadm update ceaca4fa-49d1-4614-982a-a246dffc8315