how do I use nmcli to add an IP-address to an interface?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












On a CentOS 7 virtual machine, I have an interface called ens7, as shown here:



[root@localhost ~]# nmcli con show
NAME UUID TYPE DEVICE
Wired connection 1 448101d7-1f8f-4b78-ad90-7efd5be23b08 802-3-ethernet ens7
eth0 d976f7ca-ab7f-4fd0-ab2b-6213815bd1a1 802-3-ethernet eth0


How do I get nmcli to assign the 10.1.1.1 ip address to the ens7 interface?



I tried typing nmcli con modify 'Wired connection 1' ipv4.addresses "10.1.1.2" from within the virtual machine, but it did not take, as seen in the results of `` as follows:



[root@localhost ~]# nmcli con modify 'Wired connection 1' ipv4.addresses "10.1.1.2"
[root@localhost ~]# nmcli device show
GENERAL.DEVICE: eth0
...lots of stuff related to eth0

GENERAL.DEVICE: ens7
GENERAL.TYPE: ethernet
GENERAL.HWADDR: 52:54:00:8F:3B:14
GENERAL.MTU: 1500
GENERAL.STATE: 70 (connecting (getting IP configuration))
GENERAL.CONNECTION: Wired connection 1
GENERAL.CON-PATH: /org/freedesktop/NetworkManager/ActiveConnection/64
WIRED-PROPERTIES.CARRIER: on

GENERAL.DEVICE: lo
...lots of stuff related to lo
[root@localhost ~]#


What syntax do I use to get the IP-address to show up in the nmcli device show results? So that I will be able to ping the new IP-address from an authorized outsider?










share|improve this question



























    up vote
    2
    down vote

    favorite












    On a CentOS 7 virtual machine, I have an interface called ens7, as shown here:



    [root@localhost ~]# nmcli con show
    NAME UUID TYPE DEVICE
    Wired connection 1 448101d7-1f8f-4b78-ad90-7efd5be23b08 802-3-ethernet ens7
    eth0 d976f7ca-ab7f-4fd0-ab2b-6213815bd1a1 802-3-ethernet eth0


    How do I get nmcli to assign the 10.1.1.1 ip address to the ens7 interface?



    I tried typing nmcli con modify 'Wired connection 1' ipv4.addresses "10.1.1.2" from within the virtual machine, but it did not take, as seen in the results of `` as follows:



    [root@localhost ~]# nmcli con modify 'Wired connection 1' ipv4.addresses "10.1.1.2"
    [root@localhost ~]# nmcli device show
    GENERAL.DEVICE: eth0
    ...lots of stuff related to eth0

    GENERAL.DEVICE: ens7
    GENERAL.TYPE: ethernet
    GENERAL.HWADDR: 52:54:00:8F:3B:14
    GENERAL.MTU: 1500
    GENERAL.STATE: 70 (connecting (getting IP configuration))
    GENERAL.CONNECTION: Wired connection 1
    GENERAL.CON-PATH: /org/freedesktop/NetworkManager/ActiveConnection/64
    WIRED-PROPERTIES.CARRIER: on

    GENERAL.DEVICE: lo
    ...lots of stuff related to lo
    [root@localhost ~]#


    What syntax do I use to get the IP-address to show up in the nmcli device show results? So that I will be able to ping the new IP-address from an authorized outsider?










    share|improve this question

























      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      On a CentOS 7 virtual machine, I have an interface called ens7, as shown here:



      [root@localhost ~]# nmcli con show
      NAME UUID TYPE DEVICE
      Wired connection 1 448101d7-1f8f-4b78-ad90-7efd5be23b08 802-3-ethernet ens7
      eth0 d976f7ca-ab7f-4fd0-ab2b-6213815bd1a1 802-3-ethernet eth0


      How do I get nmcli to assign the 10.1.1.1 ip address to the ens7 interface?



      I tried typing nmcli con modify 'Wired connection 1' ipv4.addresses "10.1.1.2" from within the virtual machine, but it did not take, as seen in the results of `` as follows:



      [root@localhost ~]# nmcli con modify 'Wired connection 1' ipv4.addresses "10.1.1.2"
      [root@localhost ~]# nmcli device show
      GENERAL.DEVICE: eth0
      ...lots of stuff related to eth0

      GENERAL.DEVICE: ens7
      GENERAL.TYPE: ethernet
      GENERAL.HWADDR: 52:54:00:8F:3B:14
      GENERAL.MTU: 1500
      GENERAL.STATE: 70 (connecting (getting IP configuration))
      GENERAL.CONNECTION: Wired connection 1
      GENERAL.CON-PATH: /org/freedesktop/NetworkManager/ActiveConnection/64
      WIRED-PROPERTIES.CARRIER: on

      GENERAL.DEVICE: lo
      ...lots of stuff related to lo
      [root@localhost ~]#


      What syntax do I use to get the IP-address to show up in the nmcli device show results? So that I will be able to ping the new IP-address from an authorized outsider?










      share|improve this question















      On a CentOS 7 virtual machine, I have an interface called ens7, as shown here:



      [root@localhost ~]# nmcli con show
      NAME UUID TYPE DEVICE
      Wired connection 1 448101d7-1f8f-4b78-ad90-7efd5be23b08 802-3-ethernet ens7
      eth0 d976f7ca-ab7f-4fd0-ab2b-6213815bd1a1 802-3-ethernet eth0


      How do I get nmcli to assign the 10.1.1.1 ip address to the ens7 interface?



      I tried typing nmcli con modify 'Wired connection 1' ipv4.addresses "10.1.1.2" from within the virtual machine, but it did not take, as seen in the results of `` as follows:



      [root@localhost ~]# nmcli con modify 'Wired connection 1' ipv4.addresses "10.1.1.2"
      [root@localhost ~]# nmcli device show
      GENERAL.DEVICE: eth0
      ...lots of stuff related to eth0

      GENERAL.DEVICE: ens7
      GENERAL.TYPE: ethernet
      GENERAL.HWADDR: 52:54:00:8F:3B:14
      GENERAL.MTU: 1500
      GENERAL.STATE: 70 (connecting (getting IP configuration))
      GENERAL.CONNECTION: Wired connection 1
      GENERAL.CON-PATH: /org/freedesktop/NetworkManager/ActiveConnection/64
      WIRED-PROPERTIES.CARRIER: on

      GENERAL.DEVICE: lo
      ...lots of stuff related to lo
      [root@localhost ~]#


      What syntax do I use to get the IP-address to show up in the nmcli device show results? So that I will be able to ping the new IP-address from an authorized outsider?







      centos networking rhel network-interface nmcli






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Oct 15 '15 at 8:55









      Thomas Dickey

      51.1k593162




      51.1k593162










      asked Oct 14 '15 at 21:09









      CodeMed

      1,738216898




      1,738216898




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          3
          down vote













          nmcli con modify "Wired connection 1" ifname ens7 type ethernet ip4 10.1.1.2/24 





          share|improve this answer






















          • If you downvote, please leave a comment why. Then, the reader can evaluate more easily whether the answer is helpful for them or not. Thanks!
            – Torsten Bronger
            Dec 8 '16 at 7:42


















          up vote
          2
          down vote













          Your conn modify looks mostly right, but need to put a netmask on the address otherwise it'll get the default (probably /8, which may or may not be what you want). For instance, if you needed a class-c network (254 hosts, 10.1.1.1 through 254 in your case), you'd:



          nmcli con modify 'Wired connection 1' ipv4.addresses "10.1.1.2/24"


          You also need to apply the config to the running interface. I usually:



          nmcli conn down "Wired Connection 1"
          nmcli conn up !$


          You may be able to just use conn up with out taking the interface down first.



          Other note: you can run "nmcli conn show "Wired Connection 1" to get all the settings for that device. At the end of that, it'll also show the current settings in all caps.



          connection.id: virbr0
          connection.stable-id: --
          connection.type: bridge
          connection.interface-name: virbr0


          [SNIP]



          IP4.ADDRESS[1]: 192.168.122.1/24
          IP4.GATEWAY: --
          IP4.ROUTE[1]: dst = 192.168.122.0/24, nh = 0.0.0.0, mt = 0
          IP6.GATEWAY: --





          share|improve this answer






















          • If someone else wants to validate this answer independently and leave comments on results, then I will mark this or the other answer as accepted. But I cannot validate myself as I am on to other things.
            – CodeMed
            Aug 5 at 6:59










          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',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          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%2f236220%2fhow-do-i-use-nmcli-to-add-an-ip-address-to-an-interface%23new-answer', 'question_page');

          );

          Post as a guest






























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          3
          down vote













          nmcli con modify "Wired connection 1" ifname ens7 type ethernet ip4 10.1.1.2/24 





          share|improve this answer






















          • If you downvote, please leave a comment why. Then, the reader can evaluate more easily whether the answer is helpful for them or not. Thanks!
            – Torsten Bronger
            Dec 8 '16 at 7:42















          up vote
          3
          down vote













          nmcli con modify "Wired connection 1" ifname ens7 type ethernet ip4 10.1.1.2/24 





          share|improve this answer






















          • If you downvote, please leave a comment why. Then, the reader can evaluate more easily whether the answer is helpful for them or not. Thanks!
            – Torsten Bronger
            Dec 8 '16 at 7:42













          up vote
          3
          down vote










          up vote
          3
          down vote









          nmcli con modify "Wired connection 1" ifname ens7 type ethernet ip4 10.1.1.2/24 





          share|improve this answer














          nmcli con modify "Wired connection 1" ifname ens7 type ethernet ip4 10.1.1.2/24 






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Oct 15 '15 at 3:20









          G-Man

          12.1k92860




          12.1k92860










          answered Oct 15 '15 at 3:15









          unix

          311




          311











          • If you downvote, please leave a comment why. Then, the reader can evaluate more easily whether the answer is helpful for them or not. Thanks!
            – Torsten Bronger
            Dec 8 '16 at 7:42

















          • If you downvote, please leave a comment why. Then, the reader can evaluate more easily whether the answer is helpful for them or not. Thanks!
            – Torsten Bronger
            Dec 8 '16 at 7:42
















          If you downvote, please leave a comment why. Then, the reader can evaluate more easily whether the answer is helpful for them or not. Thanks!
          – Torsten Bronger
          Dec 8 '16 at 7:42





          If you downvote, please leave a comment why. Then, the reader can evaluate more easily whether the answer is helpful for them or not. Thanks!
          – Torsten Bronger
          Dec 8 '16 at 7:42













          up vote
          2
          down vote













          Your conn modify looks mostly right, but need to put a netmask on the address otherwise it'll get the default (probably /8, which may or may not be what you want). For instance, if you needed a class-c network (254 hosts, 10.1.1.1 through 254 in your case), you'd:



          nmcli con modify 'Wired connection 1' ipv4.addresses "10.1.1.2/24"


          You also need to apply the config to the running interface. I usually:



          nmcli conn down "Wired Connection 1"
          nmcli conn up !$


          You may be able to just use conn up with out taking the interface down first.



          Other note: you can run "nmcli conn show "Wired Connection 1" to get all the settings for that device. At the end of that, it'll also show the current settings in all caps.



          connection.id: virbr0
          connection.stable-id: --
          connection.type: bridge
          connection.interface-name: virbr0


          [SNIP]



          IP4.ADDRESS[1]: 192.168.122.1/24
          IP4.GATEWAY: --
          IP4.ROUTE[1]: dst = 192.168.122.0/24, nh = 0.0.0.0, mt = 0
          IP6.GATEWAY: --





          share|improve this answer






















          • If someone else wants to validate this answer independently and leave comments on results, then I will mark this or the other answer as accepted. But I cannot validate myself as I am on to other things.
            – CodeMed
            Aug 5 at 6:59














          up vote
          2
          down vote













          Your conn modify looks mostly right, but need to put a netmask on the address otherwise it'll get the default (probably /8, which may or may not be what you want). For instance, if you needed a class-c network (254 hosts, 10.1.1.1 through 254 in your case), you'd:



          nmcli con modify 'Wired connection 1' ipv4.addresses "10.1.1.2/24"


          You also need to apply the config to the running interface. I usually:



          nmcli conn down "Wired Connection 1"
          nmcli conn up !$


          You may be able to just use conn up with out taking the interface down first.



          Other note: you can run "nmcli conn show "Wired Connection 1" to get all the settings for that device. At the end of that, it'll also show the current settings in all caps.



          connection.id: virbr0
          connection.stable-id: --
          connection.type: bridge
          connection.interface-name: virbr0


          [SNIP]



          IP4.ADDRESS[1]: 192.168.122.1/24
          IP4.GATEWAY: --
          IP4.ROUTE[1]: dst = 192.168.122.0/24, nh = 0.0.0.0, mt = 0
          IP6.GATEWAY: --





          share|improve this answer






















          • If someone else wants to validate this answer independently and leave comments on results, then I will mark this or the other answer as accepted. But I cannot validate myself as I am on to other things.
            – CodeMed
            Aug 5 at 6:59












          up vote
          2
          down vote










          up vote
          2
          down vote









          Your conn modify looks mostly right, but need to put a netmask on the address otherwise it'll get the default (probably /8, which may or may not be what you want). For instance, if you needed a class-c network (254 hosts, 10.1.1.1 through 254 in your case), you'd:



          nmcli con modify 'Wired connection 1' ipv4.addresses "10.1.1.2/24"


          You also need to apply the config to the running interface. I usually:



          nmcli conn down "Wired Connection 1"
          nmcli conn up !$


          You may be able to just use conn up with out taking the interface down first.



          Other note: you can run "nmcli conn show "Wired Connection 1" to get all the settings for that device. At the end of that, it'll also show the current settings in all caps.



          connection.id: virbr0
          connection.stable-id: --
          connection.type: bridge
          connection.interface-name: virbr0


          [SNIP]



          IP4.ADDRESS[1]: 192.168.122.1/24
          IP4.GATEWAY: --
          IP4.ROUTE[1]: dst = 192.168.122.0/24, nh = 0.0.0.0, mt = 0
          IP6.GATEWAY: --





          share|improve this answer














          Your conn modify looks mostly right, but need to put a netmask on the address otherwise it'll get the default (probably /8, which may or may not be what you want). For instance, if you needed a class-c network (254 hosts, 10.1.1.1 through 254 in your case), you'd:



          nmcli con modify 'Wired connection 1' ipv4.addresses "10.1.1.2/24"


          You also need to apply the config to the running interface. I usually:



          nmcli conn down "Wired Connection 1"
          nmcli conn up !$


          You may be able to just use conn up with out taking the interface down first.



          Other note: you can run "nmcli conn show "Wired Connection 1" to get all the settings for that device. At the end of that, it'll also show the current settings in all caps.



          connection.id: virbr0
          connection.stable-id: --
          connection.type: bridge
          connection.interface-name: virbr0


          [SNIP]



          IP4.ADDRESS[1]: 192.168.122.1/24
          IP4.GATEWAY: --
          IP4.ROUTE[1]: dst = 192.168.122.0/24, nh = 0.0.0.0, mt = 0
          IP6.GATEWAY: --






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 5 mins ago

























          answered Aug 1 at 22:22









          MattPie

          212




          212











          • If someone else wants to validate this answer independently and leave comments on results, then I will mark this or the other answer as accepted. But I cannot validate myself as I am on to other things.
            – CodeMed
            Aug 5 at 6:59
















          • If someone else wants to validate this answer independently and leave comments on results, then I will mark this or the other answer as accepted. But I cannot validate myself as I am on to other things.
            – CodeMed
            Aug 5 at 6:59















          If someone else wants to validate this answer independently and leave comments on results, then I will mark this or the other answer as accepted. But I cannot validate myself as I am on to other things.
          – CodeMed
          Aug 5 at 6:59




          If someone else wants to validate this answer independently and leave comments on results, then I will mark this or the other answer as accepted. But I cannot validate myself as I am on to other things.
          – CodeMed
          Aug 5 at 6:59

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f236220%2fhow-do-i-use-nmcli-to-add-an-ip-address-to-an-interface%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Bahrain

          Postfix configuration issue with fips on centos 7; mailgun relay