Layer 7 API Management

Expand all | Collapse all

How can I configure a static IP with the cloud-init config with Portal EE?

Jump to Best Answer
  • 1.  How can I configure a static IP with the cloud-init config with Portal EE?

    Posted 05-26-2017 10:30 AM

    We been trying to modify the cloud-init configuration for Portal EE 4.0 to assign a static IP on first boot. Each attempt that has been successful in updating the IP address has resulted in blocking the remaining cloud-init scripts and, as a result, does not create any users. Is there a way to configure a static IP that doesn't break the cloud-init config? Below is a sample config of what is placed in the meta-data. Looks like version Cloud-init 0.7.5 is in use here. The internet has similar stories regarding Ubuntu and upstart, but don't seem to apply 1 to 1 to this Centos 7.2 image. Any thoughts or assistance would be appreciated.

     

    instance-id: iid-local01
    network-interfaces: |
      iface eth0 inet static
      address 10.10.10.2
      network 10.10.10.0
      netmask 255.255.255.0
      broadcast 10.0.0.255
      gateway 10.10.10.1
    hostname: myhostname


  • 2.  Re: How can I configure a static IP with the cloud-init config with Portal EE?
    Best Answer

    Posted 05-30-2017 05:02 PM

    Hi Rob,

    Append the following scripts in the “bootcmd:” section of “user-data” file.

      - set -x; echo 'user-data/bootcmd:'

      - set -x; sed -i -e 's/BOOTPROTO=dhcp/BOOTPROTO=static/g' /etc/sysconfig/network-scripts/ifcfg-eth0

      - set -x; echo 'IPADDR=155.35.128.180' >> /etc/sysconfig/network-scripts/ifcfg-eth0

      - set -x; echo 'GATEWAY=155.35.128.1' >> /etc/sysconfig/network-scripts/ifcfg-eth0

      - set -x; echo 'NETMASK=255.255.255.0' >> /etc/sysconfig/network-scripts/ifcfg-eth0

      - set -x; echo 'ONBOOT="yes"' >> /etc/sysconfig/network-scripts/ifcfg-eth0

      - set -x; echo 'NM_CONTROLLED=no' >> /etc/sysconfig/network-scripts/ifcfg-eth0



  • 3.  Re: How can I configure a static IP with the cloud-init config with Portal EE?

    Posted 06-03-2017 07:41 AM

    This works well, but take into account the bootcmd section is run each time the vm is started from the cloudinit iso. As a result of this the echo commands will be appended for each reboot with the iso attached, creating duplicate lines. If moved to the runcmd section it will be run only the first time.