DHCP is the default method for IP addres allocation for the Avi Conversion Tool. To configure static IP address on the Avi Conversion Tool, follow the steps mentioned in this section.

First proceed to backup the original cloud init files.

It is highly recommended to temporarily add an IP address to the host and access it via SSH instead of using vSphere’s web console. This procedure adds an IP address to an interface, but the IP address will not be persistent, meaning it will disappear after a reboot. Complete the steps in this chapter to add a persistent IP address to the interface.

To add an IP address ,execute the following command:

sudo ip addr add <IP-ADDRESS>/<NETMASK-Bits> ens192
sudo ip route add default via <GATEWAY-IP>

For more details on temporary IP address assignment, see https://ubuntu.com/server/docs/configuring-networks.

After adding an IP address to the host, use any SSH client to access the Avi Conversion Tool's VM.

ubuntu@migrationtools:~$ sudo -i
root@migrationtools:~# cp /etc/netplan/50-cloud-init.yaml /etc/netplan/50-cloud-init.yaml.old
root@migrationtools:~# echo network: {config: disabled} > /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg.test

To disable cloud-init's network configuration capabilities, follow the below steps.

root@migrationtools:~# echo network: {config: disabled} > /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg

Edit /etc/netplan/50-cloud-init.yaml using your preferred editor. In the below example, the vim editor is used.

Change dhcp4 from 'true' to 'false':

root@migrationtools:~# vim /etc/netplan/50-cloud-init.yaml
before:  dhcp4: true
after:   dhcp4: false

Add IPv4 address details (replace what is inside of the brackets).

 addresses:
         - [ip]/[netmask-bits]
 routes:
         - to: default
           via:[next-hop]
 nameservers:
         addresses: 
- [dns]

Below is an example file:

network:
    ethernets:
        ens192:
            dhcp4: false
            match:
                macaddress: 00:50:56:8c:05:60
            set-name: ens192
            addresses:
                    - 192.168.110.51/24
            routes:
                    - to: default
                      via: 192.168.110.1
            nameservers:
                    addresses:
                        - 8.8.8.8
    version: 2

Apply the changes

root@migrationtools:~# netplan apply

Procedure to add static IP address configuration from the UI

Use Encoded user-data field to add encoded user-data during deployment with static IP configuration.

Steps to generate Encoded user-data field value are as follows:

Create a cloud-init userdata file for network configuration:

$ cat <<EOF >> cloud-config-static-ip.yaml
#cloud-config
write_files:
- path: /etc/cloud/cloud.cfg.d/99-custom-networking.cfg
  permissions: '0644'
  content: |
    network: {config: disabled}
- path: /etc/netplan/00-installer-config.yaml
  permissions: '0644'
  content: |
    network:
      version: 2
      renderer: networkd
      ethernets:
        ####BEGIN: Configure the network section####
        ens192:   # replace this interface name to match your system
          dhcp4: false
          addresses: 
            - <static-ip>/<mask>  # replace with your desired static IP address and subnet mask
          nameservers:
            addresses: [10.214.129.198, 10.214.129.199]   # replace with your DNS server addresses
          routes:
            - to: default
              via: <gateway-ip> # replace with your gateway IP address
        ####END: Configure the network section####
runcmd:
 - rm /etc/netplan/50-cloud-init.yaml
 - netplan generate
 - netplan apply
EOF

Encode the contents to base64 format:

$ openssl base64 -in cloud-config-static-ip.yaml -out cloud-config-static-ip-base64-encoded.yaml

Pass the encoded contents to 'Encoded user-data' during deployment of avi-migration-tools from vCenter UI:

$ cat cloud-config-static-ip-base64-encoded.yaml

Add above encoded content to Encoded user-data and perform remaining steps for the same.