So I'm trying to give a VM a static IP address, this case has been particularly stubborn.

The VM is running on a ESXi cluster with its own public IP range.

I had it (sorta) working with an IPv4 address, except it would be reassigned every boot, now after fiddling with nmcli I can't get any IPv4 address assigned to it.

The interface is ens32 and I've changed ipv4.addresses to XXX.XXX.120.44/24 (want it to have address 120.44), gateway to XXX.XXX.120.1 and set it to manual.

Does anyone have any insights to why this isn't working? all the online guides are for the older network service not NetworkManager.

  • So it has to be over network manager at all costs?
    – phk
    Jun 20 '16 at 15:07
  • 1
    Or is there DHCP available? That would push the complexity off onto the DHCP server, and only require that the node uses DHCP.
    – thrig
    Jun 20 '16 at 15:54
  • I hope you don't mind, but I've changed the title to be more generic. Jun 20 '16 at 18:10
  • @phk fedora 23 doesn't like you enabling network and thus you can't use the older configuration system
    – Space Bear
    Jun 20 '16 at 18:22
  • Do you not have nmtui? Jun 21 '16 at 8:08


# nmcli con add con-name "static-ens32" ifname ens32 type ethernet ip4 xxx.xxx.120.44/24 gw4 xxx.xxx.120.1
# nmcli con mod "static-ens32" ipv4.dns "xxx.xxx.120.1,"
# nmcli con up "static-ens32" iface ens32

Next, find the other connections and delete them. For example:

# nmcli con show
NAME         UUID                 TYPE           DEVICE
ens32        ff9804db5-........   802-3-ethernet --
static-ens32 a4b59cb4a-........   802-3-ethernet ens32
# nmcli con del ens32

On the next reboot, you should pick up the static-ens32 connection, as it is the only one available.

  • I am trying to do this from the raw starting point of a fresh installation, which requires a somewhat different sequence of commands. Are you willing to show how to do this from scratch with a fresh installation of CentOS 7? Here is the link: unix.stackexchange.com/questions/349607/…
    – CodeMed
    Mar 6 '17 at 23:03

An individual IPv4 address is /32. /24 designates a network, which in this case would be XXX.XXX.120.[0-255]. Try changing the ipv4.address entry to XXX.XXX.120.44/32 and see what happens. If that doesn't work, I have to then ask the same question asked in comments - is NetworkManager a requirement, or can we configure the address using other means?

  • nmcli wants the IP address with the subnet mask in CIDR notation. Jun 20 '16 at 15:59
  • I've played around with the CIDR notation with the /24 /16 and /32 neither worked.
    – Space Bear
    Jun 20 '16 at 16:04

Changing /32(single) to /24(network) fixed my problem with ipv4.addresses assigning range and first ip address.

I think "manual" could be a problem in your case. Manual may tell nm to not manage at all, or not handle dhcp. Have you tried "shared", and then ipv4.addresses rather than ipv4.address1? Or, if manual, then ipv4.address1 might be correct instead of ipv4.addresses.

Have you looked in /var/log/syslog? dnsmasq said in mine that 32 was too small, and nmcli reported back "too small" in the error output.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.