Assigning static IP address using nmcli












12















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.










share|improve this question

























  • 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.

    – garethTheRed
    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?

    – Trent
    Jun 21 '16 at 8:08
















12















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.










share|improve this question

























  • 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.

    – garethTheRed
    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?

    – Trent
    Jun 21 '16 at 8:08














12












12








12


2






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.










share|improve this question
















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.







networking fedora nmcli






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jun 26 '16 at 19:55









guntbert

1,06111017




1,06111017










asked Jun 20 '16 at 14:56









Space BearSpace Bear

63115




63115













  • 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.

    – garethTheRed
    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?

    – Trent
    Jun 21 '16 at 8:08



















  • 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.

    – garethTheRed
    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?

    – Trent
    Jun 21 '16 at 8:08

















So it has to be over network manager at all costs?

– phk
Jun 20 '16 at 15:07





So it has to be over network manager at all costs?

– phk
Jun 20 '16 at 15:07




1




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





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.

– garethTheRed
Jun 20 '16 at 18:10





I hope you don't mind, but I've changed the title to be more generic.

– garethTheRed
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





@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?

– Trent
Jun 21 '16 at 8:08





Do you not have nmtui?

– Trent
Jun 21 '16 at 8:08










3 Answers
3






active

oldest

votes


















19














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" 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.






share|improve this answer
























  • 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



















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?






share|improve this answer
























  • nmcli wants the IP address with the subnet mask in CIDR notation.

    – garethTheRed
    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



















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.






share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "106"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f290938%2fassigning-static-ip-address-using-nmcli%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    19














    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" 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.






    share|improve this answer
























    • 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
















    19














    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" 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.






    share|improve this answer
























    • 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














    19












    19








    19







    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" 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.






    share|improve this answer













    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" 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.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jun 20 '16 at 15:56









    garethTheRedgarethTheRed

    24.3k36280




    24.3k36280













    • 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



















    • 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

















    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





    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













    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?






    share|improve this answer
























    • nmcli wants the IP address with the subnet mask in CIDR notation.

      – garethTheRed
      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
















    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?






    share|improve this answer
























    • nmcli wants the IP address with the subnet mask in CIDR notation.

      – garethTheRed
      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














    0












    0








    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?






    share|improve this answer













    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?







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jun 20 '16 at 15:13









    JohnJohn

    11.6k11830




    11.6k11830













    • nmcli wants the IP address with the subnet mask in CIDR notation.

      – garethTheRed
      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



















    • nmcli wants the IP address with the subnet mask in CIDR notation.

      – garethTheRed
      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

















    nmcli wants the IP address with the subnet mask in CIDR notation.

    – garethTheRed
    Jun 20 '16 at 15:59





    nmcli wants the IP address with the subnet mask in CIDR notation.

    – garethTheRed
    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





    I've played around with the CIDR notation with the /24 /16 and /32 neither worked.

    – Space Bear
    Jun 20 '16 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.






    share|improve this answer




























      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.






      share|improve this answer


























        0












        0








        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.






        share|improve this answer













        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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 19 at 22:41









        BobDoddsBobDodds

        212




        212






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f290938%2fassigning-static-ip-address-using-nmcli%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            How to reconfigure Docker Trusted Registry 2.x.x to use CEPH FS mount instead of NFS and other traditional...

            is 'sed' thread safe

            How to make a Squid Proxy server?