Rename network interface ubuntu on instance boot cloud-init

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











up vote
-3
down vote

favorite












I have two network interfaces- eth0 and eth1 on the Ubuntu image I am building. I want to create cloud instances from that image. For every cloud instance it creates, every instance will have those two network interfaces. However, the requirement is that, the interfaces are renamed to, say, interface0 and interface1 respectively. How can I configure that using cloud-init on instance boot up?










share|improve this question

























    up vote
    -3
    down vote

    favorite












    I have two network interfaces- eth0 and eth1 on the Ubuntu image I am building. I want to create cloud instances from that image. For every cloud instance it creates, every instance will have those two network interfaces. However, the requirement is that, the interfaces are renamed to, say, interface0 and interface1 respectively. How can I configure that using cloud-init on instance boot up?










    share|improve this question























      up vote
      -3
      down vote

      favorite









      up vote
      -3
      down vote

      favorite











      I have two network interfaces- eth0 and eth1 on the Ubuntu image I am building. I want to create cloud instances from that image. For every cloud instance it creates, every instance will have those two network interfaces. However, the requirement is that, the interfaces are renamed to, say, interface0 and interface1 respectively. How can I configure that using cloud-init on instance boot up?










      share|improve this question













      I have two network interfaces- eth0 and eth1 on the Ubuntu image I am building. I want to create cloud instances from that image. For every cloud instance it creates, every instance will have those two network interfaces. However, the requirement is that, the interfaces are renamed to, say, interface0 and interface1 respectively. How can I configure that using cloud-init on instance boot up?







      linux ubuntu cloud cloud-init






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Aug 24 at 1:16









      user304255

      1




      1




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          The docs for cloud-init show the following examples in this section - Networking Config Version 2:



          # all cards on second PCI bus
          match:
          name: enp2*

          # fixed MAC address
          match:
          macaddress: 11:22:33:AA:BB:FF

          # first card of driver ``ixgbe``
          match:
          driver: ixgbe
          name: en*s0


          So long as the match is specific to a single device, you can use the set-name: to define whatever name you want for the interface.




          set-name: <(scalar)>



          When matching on unique properties such as path or MAC, or with additional assumptions such as “there will only ever be one wifi device”, match rules can be written so that they only match one device. Then this property can be used to give that device a more specific/desirable/nicer name than the default from udev’s ifnames. Any additional device that satisfies the match rules will then fail to get renamed and keep the original kernel name (and dmesg will show an error).




          For example:



          $ cat /etc/cloud/cloud.cfg.d/custom-networking.cfg
          network:
          version: 2
          ethernets:
          interface0:
          match:
          mac_address: "52:54:00:12:34:00"
          set-name: interface0
          addresses:
          - 192.168.1.10/255.255.255.0
          gateway4: 192.168.1.254





          share|improve this answer






















          • On boot, how will the instance have the mac_address information available? I am talking about the case when we want to spin instances from a VM image on a hypervisor. The NIC MAC address information will not be able to be hard coded.
            – user304255
            Aug 27 at 18:48










          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%2f464537%2frename-network-interface-ubuntu-on-instance-boot-cloud-init%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          The docs for cloud-init show the following examples in this section - Networking Config Version 2:



          # all cards on second PCI bus
          match:
          name: enp2*

          # fixed MAC address
          match:
          macaddress: 11:22:33:AA:BB:FF

          # first card of driver ``ixgbe``
          match:
          driver: ixgbe
          name: en*s0


          So long as the match is specific to a single device, you can use the set-name: to define whatever name you want for the interface.




          set-name: <(scalar)>



          When matching on unique properties such as path or MAC, or with additional assumptions such as “there will only ever be one wifi device”, match rules can be written so that they only match one device. Then this property can be used to give that device a more specific/desirable/nicer name than the default from udev’s ifnames. Any additional device that satisfies the match rules will then fail to get renamed and keep the original kernel name (and dmesg will show an error).




          For example:



          $ cat /etc/cloud/cloud.cfg.d/custom-networking.cfg
          network:
          version: 2
          ethernets:
          interface0:
          match:
          mac_address: "52:54:00:12:34:00"
          set-name: interface0
          addresses:
          - 192.168.1.10/255.255.255.0
          gateway4: 192.168.1.254





          share|improve this answer






















          • On boot, how will the instance have the mac_address information available? I am talking about the case when we want to spin instances from a VM image on a hypervisor. The NIC MAC address information will not be able to be hard coded.
            – user304255
            Aug 27 at 18:48














          up vote
          0
          down vote













          The docs for cloud-init show the following examples in this section - Networking Config Version 2:



          # all cards on second PCI bus
          match:
          name: enp2*

          # fixed MAC address
          match:
          macaddress: 11:22:33:AA:BB:FF

          # first card of driver ``ixgbe``
          match:
          driver: ixgbe
          name: en*s0


          So long as the match is specific to a single device, you can use the set-name: to define whatever name you want for the interface.




          set-name: <(scalar)>



          When matching on unique properties such as path or MAC, or with additional assumptions such as “there will only ever be one wifi device”, match rules can be written so that they only match one device. Then this property can be used to give that device a more specific/desirable/nicer name than the default from udev’s ifnames. Any additional device that satisfies the match rules will then fail to get renamed and keep the original kernel name (and dmesg will show an error).




          For example:



          $ cat /etc/cloud/cloud.cfg.d/custom-networking.cfg
          network:
          version: 2
          ethernets:
          interface0:
          match:
          mac_address: "52:54:00:12:34:00"
          set-name: interface0
          addresses:
          - 192.168.1.10/255.255.255.0
          gateway4: 192.168.1.254





          share|improve this answer






















          • On boot, how will the instance have the mac_address information available? I am talking about the case when we want to spin instances from a VM image on a hypervisor. The NIC MAC address information will not be able to be hard coded.
            – user304255
            Aug 27 at 18:48












          up vote
          0
          down vote










          up vote
          0
          down vote









          The docs for cloud-init show the following examples in this section - Networking Config Version 2:



          # all cards on second PCI bus
          match:
          name: enp2*

          # fixed MAC address
          match:
          macaddress: 11:22:33:AA:BB:FF

          # first card of driver ``ixgbe``
          match:
          driver: ixgbe
          name: en*s0


          So long as the match is specific to a single device, you can use the set-name: to define whatever name you want for the interface.




          set-name: <(scalar)>



          When matching on unique properties such as path or MAC, or with additional assumptions such as “there will only ever be one wifi device”, match rules can be written so that they only match one device. Then this property can be used to give that device a more specific/desirable/nicer name than the default from udev’s ifnames. Any additional device that satisfies the match rules will then fail to get renamed and keep the original kernel name (and dmesg will show an error).




          For example:



          $ cat /etc/cloud/cloud.cfg.d/custom-networking.cfg
          network:
          version: 2
          ethernets:
          interface0:
          match:
          mac_address: "52:54:00:12:34:00"
          set-name: interface0
          addresses:
          - 192.168.1.10/255.255.255.0
          gateway4: 192.168.1.254





          share|improve this answer














          The docs for cloud-init show the following examples in this section - Networking Config Version 2:



          # all cards on second PCI bus
          match:
          name: enp2*

          # fixed MAC address
          match:
          macaddress: 11:22:33:AA:BB:FF

          # first card of driver ``ixgbe``
          match:
          driver: ixgbe
          name: en*s0


          So long as the match is specific to a single device, you can use the set-name: to define whatever name you want for the interface.




          set-name: <(scalar)>



          When matching on unique properties such as path or MAC, or with additional assumptions such as “there will only ever be one wifi device”, match rules can be written so that they only match one device. Then this property can be used to give that device a more specific/desirable/nicer name than the default from udev’s ifnames. Any additional device that satisfies the match rules will then fail to get renamed and keep the original kernel name (and dmesg will show an error).




          For example:



          $ cat /etc/cloud/cloud.cfg.d/custom-networking.cfg
          network:
          version: 2
          ethernets:
          interface0:
          match:
          mac_address: "52:54:00:12:34:00"
          set-name: interface0
          addresses:
          - 192.168.1.10/255.255.255.0
          gateway4: 192.168.1.254






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Aug 24 at 2:41

























          answered Aug 24 at 2:31









          slm♦

          238k65494664




          238k65494664











          • On boot, how will the instance have the mac_address information available? I am talking about the case when we want to spin instances from a VM image on a hypervisor. The NIC MAC address information will not be able to be hard coded.
            – user304255
            Aug 27 at 18:48
















          • On boot, how will the instance have the mac_address information available? I am talking about the case when we want to spin instances from a VM image on a hypervisor. The NIC MAC address information will not be able to be hard coded.
            – user304255
            Aug 27 at 18:48















          On boot, how will the instance have the mac_address information available? I am talking about the case when we want to spin instances from a VM image on a hypervisor. The NIC MAC address information will not be able to be hard coded.
          – user304255
          Aug 27 at 18:48




          On boot, how will the instance have the mac_address information available? I am talking about the case when we want to spin instances from a VM image on a hypervisor. The NIC MAC address information will not be able to be hard coded.
          – user304255
          Aug 27 at 18:48

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f464537%2frename-network-interface-ubuntu-on-instance-boot-cloud-init%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