33

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.

6
  • 1
    So it has to be over network manager at all costs? Commented Jun 20, 2016 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. Commented Jun 20, 2016 at 15:54
  • I hope you don't mind, but I've changed the title to be more generic. Commented Jun 20, 2016 at 18:10
  • @phk fedora 23 doesn't like you enabling network and thus you can't use the older configuration system Commented Jun 20, 2016 at 18:22
  • Do you not have nmtui? Commented Jun 21, 2016 at 8:08

3 Answers 3

47

Try:

# 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,8.8.8.8"
# nmcli con up "static-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.

2
  • 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/… Commented Mar 6, 2017 at 23:03
  • Change "iface" by "ifname" when starting the connection again. Commented Feb 7, 2024 at 12:13
0

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?

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

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.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.