1

I have a vm lab with CentOS 7.5 servers. There's no dhcp and each server in the lab has its IP address manually assigned. Each machine has NetworkManager stopped and disabled.

I add the IP by using # ip addr add 192.168.1.100/24 dev ens192 followed by # ip link set ens192 up

Everything works fine, except when the machine reboot it loses the IP address and I have to manually set it again.

I assume there's some systemctl command or somethng I have to run besides these two commands that makes it permanent, but I don't know what. Hopefully you can help. Thanks

  • do you have a startup job that runs those commands? because their results will not be preserved across a reboot – thrig Jun 20 '18 at 19:31
  • No, I've been doing it manually after reboot so far, but I'm about to add them to rc.local as a stopgap. – Kefka Jun 20 '18 at 19:48
  • In /etc/sysconfig/network-scripts/ you should see your config file for ens192. If you vim into it, can you confirm what the ONBOOT is set to? – ryekayo Jun 20 '18 at 19:49
  • @ryekayo It was set to NO, and I changed it to YES and everything is good now. Thanks – Kefka Jun 20 '18 at 21:12
2

The IP command is by definition not persistent and you must put the IP addresses configuration in the ifcfg-<connection name> to keep it between reboots. These files are typically under /etc/sysconfig/network-scripts.

You might also want to look at using NetworkManager instead, you can configure persistent network settings through NetworkManagers GUI or command-line tool, nmcli. See man nmcli for more details and examples.

  • Thanks, I thought IP was supposed to be used for everything relating to host networking. I edited my ifcfg script appropriately, and now I think everything is all set. – Kefka Jun 20 '18 at 21:13

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.