How to Add Private Networking in CentOS 8/Ubuntu on Vultr (One-liners/AUTO)

Vultr uses ens7 as the private network interface name.

Your instances must be in the same location.

How to add private networking to Ubuntu in Vultr (netplan):

# centos 8

PRIVATE_IP='10.39.100.4'

echo 'TYPE="Ethernet" 
DEVICE="ens7" 
ONBOOT="yes" 
BOOTPROTO="none" 
IPADDR='"${PRIVATE_IP}"'
PREFIX=16
MTU=1450' > /etc/sysconfig/network-scripts/ifcfg-ens7

nmcli con load /etc/sysconfig/network-scripts/ifcfg-ens7
nmcli con up 'System ens7'


How to add private networking to Ubuntu in Vultr (netplan):

# ubuntu 18.04+

PRIVATE_IP='10.39.100.3'

MAC_ADDR=$(ifconfig -a | grep ens7 -A10 | grep -m1 -Eo '([0-9a-f]{2}:){5}[0-9a-f]{2}')

echo "network:
  version: 2
  renderer: networkd
  ethernets:
    ens7:
      match:
        macaddress: "${MAC_ADDR}"
      mtu: 1450
      dhcp4: no
      addresses: ["${PRIVATE_IP}"/16]"  >  /etc/netplan/10-ens7.yaml

netplan apply


Leave a Reply

Your email address will not be published. Required fields are marked *