How do I assign an arbitrary name to a network interface based on hardware location? (CentOS 7)











up vote
0
down vote

favorite












I have multiple identical appliances runing CentOS 7 with four on-board NICs. To maintain a similar feel to an older version of the appliance running RHEL6 (i.e., ethX), I want to use the network naming scheme used by RHEL6. I also want to minimize the number of changes required after creating a generic system disk for use on each appliance.



If I understand the naming scheme in CentOS 7, the naming scheme is consistent based on hardware location so if the hardware is identical, I'll have the same network interface names for each instance of the appliance.



Due to customer demands, I need to make the appliance's network interfaces have the same name on the CentOS 7 and RHEL6 versions.



One approach is to extend the kernel command line with net.ifnames=0 as described here and then create my own ifcfg-ethX files. However, as near as I can tell, doing so requires manual modification of the configuration file. This is further complicated by the legacy ordering being fixed but arbitrary so I would have to modify these files for each system. :-/



One thought I had was to use the CentOS 7 naming scheme but then add an alias to each so that the arbitrary naming scheme could by applied based on hardware location. Is it possible to do this?



Any other ideas on how I can get two names to the same device and IP address?



NOTE: I am not asking how to add multiple IP addresses to the same device which is fairly straightforward.



EDIT:
I really need to rename it but would like to do so programatically.










share|improve this question




























    up vote
    0
    down vote

    favorite












    I have multiple identical appliances runing CentOS 7 with four on-board NICs. To maintain a similar feel to an older version of the appliance running RHEL6 (i.e., ethX), I want to use the network naming scheme used by RHEL6. I also want to minimize the number of changes required after creating a generic system disk for use on each appliance.



    If I understand the naming scheme in CentOS 7, the naming scheme is consistent based on hardware location so if the hardware is identical, I'll have the same network interface names for each instance of the appliance.



    Due to customer demands, I need to make the appliance's network interfaces have the same name on the CentOS 7 and RHEL6 versions.



    One approach is to extend the kernel command line with net.ifnames=0 as described here and then create my own ifcfg-ethX files. However, as near as I can tell, doing so requires manual modification of the configuration file. This is further complicated by the legacy ordering being fixed but arbitrary so I would have to modify these files for each system. :-/



    One thought I had was to use the CentOS 7 naming scheme but then add an alias to each so that the arbitrary naming scheme could by applied based on hardware location. Is it possible to do this?



    Any other ideas on how I can get two names to the same device and IP address?



    NOTE: I am not asking how to add multiple IP addresses to the same device which is fairly straightforward.



    EDIT:
    I really need to rename it but would like to do so programatically.










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I have multiple identical appliances runing CentOS 7 with four on-board NICs. To maintain a similar feel to an older version of the appliance running RHEL6 (i.e., ethX), I want to use the network naming scheme used by RHEL6. I also want to minimize the number of changes required after creating a generic system disk for use on each appliance.



      If I understand the naming scheme in CentOS 7, the naming scheme is consistent based on hardware location so if the hardware is identical, I'll have the same network interface names for each instance of the appliance.



      Due to customer demands, I need to make the appliance's network interfaces have the same name on the CentOS 7 and RHEL6 versions.



      One approach is to extend the kernel command line with net.ifnames=0 as described here and then create my own ifcfg-ethX files. However, as near as I can tell, doing so requires manual modification of the configuration file. This is further complicated by the legacy ordering being fixed but arbitrary so I would have to modify these files for each system. :-/



      One thought I had was to use the CentOS 7 naming scheme but then add an alias to each so that the arbitrary naming scheme could by applied based on hardware location. Is it possible to do this?



      Any other ideas on how I can get two names to the same device and IP address?



      NOTE: I am not asking how to add multiple IP addresses to the same device which is fairly straightforward.



      EDIT:
      I really need to rename it but would like to do so programatically.










      share|improve this question















      I have multiple identical appliances runing CentOS 7 with four on-board NICs. To maintain a similar feel to an older version of the appliance running RHEL6 (i.e., ethX), I want to use the network naming scheme used by RHEL6. I also want to minimize the number of changes required after creating a generic system disk for use on each appliance.



      If I understand the naming scheme in CentOS 7, the naming scheme is consistent based on hardware location so if the hardware is identical, I'll have the same network interface names for each instance of the appliance.



      Due to customer demands, I need to make the appliance's network interfaces have the same name on the CentOS 7 and RHEL6 versions.



      One approach is to extend the kernel command line with net.ifnames=0 as described here and then create my own ifcfg-ethX files. However, as near as I can tell, doing so requires manual modification of the configuration file. This is further complicated by the legacy ordering being fixed but arbitrary so I would have to modify these files for each system. :-/



      One thought I had was to use the CentOS 7 naming scheme but then add an alias to each so that the arbitrary naming scheme could by applied based on hardware location. Is it possible to do this?



      Any other ideas on how I can get two names to the same device and IP address?



      NOTE: I am not asking how to add multiple IP addresses to the same device which is fairly straightforward.



      EDIT:
      I really need to rename it but would like to do so programatically.







      linux networking centos






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 30 at 21:06

























      asked Nov 30 at 20:00









      MrMas

      1136




      1136






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          2
          down vote













          Can a name be both "arbitrary" and "based on hardware location" at the same time? These words contradict each other.





          • The eth# names are assigned by the kernel itself based on detection order on each boot – in other words, they're "first come, first serve", and have nothing to do with hardware location.



            Older udev versions used to automatically generate a file in /etc/udev/rules.d to bind these assignments to the cards' MAC addresses. You can probably copy that file to the new systems.



            You can also write custom udev rules to set the NAME= parameter based on the address or PCI location. (Note that in the future udev may refuse to rename an interface to eth*, if it doesn't already. And even if allowed, this renaming is very brittle and can fail if the devices are discovered in a different order.)




          • Although, as far as I know, RHEL 6 used biosdevname for generating the physical-based interface names (kernel switch biosdevname=0). RHEL 7 uses systemd-udevd's built-in net_id for this purpose (kernel switch net.ifnames=0).



            To get the p1p2 style names, you can yum install biosdevname, then enable it through the kernel command line (biosdevname=1 net.ifnames=0). See the Red Hat documentation.




          Network interfaces cannot have aliases.






          share|improve this answer























          • By arbitrary, I mean "not following a prescribed pattern"
            – MrMas
            Nov 30 at 21:55












          • This link headed in the right direction: unix.stackexchange.com/a/219277/88800 and, for persitence in a udev-like manner, this link shared important info: cyberciti.biz/faq/… So I created /etc/NetworkManager/dispatcher.d/99-ifup-local.sh to do this for each of my devices.
            – MrMas
            Nov 30 at 21:55













          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "3"
          };
          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: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          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%2fsuperuser.com%2fquestions%2f1379821%2fhow-do-i-assign-an-arbitrary-name-to-a-network-interface-based-on-hardware-locat%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          2
          down vote













          Can a name be both "arbitrary" and "based on hardware location" at the same time? These words contradict each other.





          • The eth# names are assigned by the kernel itself based on detection order on each boot – in other words, they're "first come, first serve", and have nothing to do with hardware location.



            Older udev versions used to automatically generate a file in /etc/udev/rules.d to bind these assignments to the cards' MAC addresses. You can probably copy that file to the new systems.



            You can also write custom udev rules to set the NAME= parameter based on the address or PCI location. (Note that in the future udev may refuse to rename an interface to eth*, if it doesn't already. And even if allowed, this renaming is very brittle and can fail if the devices are discovered in a different order.)




          • Although, as far as I know, RHEL 6 used biosdevname for generating the physical-based interface names (kernel switch biosdevname=0). RHEL 7 uses systemd-udevd's built-in net_id for this purpose (kernel switch net.ifnames=0).



            To get the p1p2 style names, you can yum install biosdevname, then enable it through the kernel command line (biosdevname=1 net.ifnames=0). See the Red Hat documentation.




          Network interfaces cannot have aliases.






          share|improve this answer























          • By arbitrary, I mean "not following a prescribed pattern"
            – MrMas
            Nov 30 at 21:55












          • This link headed in the right direction: unix.stackexchange.com/a/219277/88800 and, for persitence in a udev-like manner, this link shared important info: cyberciti.biz/faq/… So I created /etc/NetworkManager/dispatcher.d/99-ifup-local.sh to do this for each of my devices.
            – MrMas
            Nov 30 at 21:55

















          up vote
          2
          down vote













          Can a name be both "arbitrary" and "based on hardware location" at the same time? These words contradict each other.





          • The eth# names are assigned by the kernel itself based on detection order on each boot – in other words, they're "first come, first serve", and have nothing to do with hardware location.



            Older udev versions used to automatically generate a file in /etc/udev/rules.d to bind these assignments to the cards' MAC addresses. You can probably copy that file to the new systems.



            You can also write custom udev rules to set the NAME= parameter based on the address or PCI location. (Note that in the future udev may refuse to rename an interface to eth*, if it doesn't already. And even if allowed, this renaming is very brittle and can fail if the devices are discovered in a different order.)




          • Although, as far as I know, RHEL 6 used biosdevname for generating the physical-based interface names (kernel switch biosdevname=0). RHEL 7 uses systemd-udevd's built-in net_id for this purpose (kernel switch net.ifnames=0).



            To get the p1p2 style names, you can yum install biosdevname, then enable it through the kernel command line (biosdevname=1 net.ifnames=0). See the Red Hat documentation.




          Network interfaces cannot have aliases.






          share|improve this answer























          • By arbitrary, I mean "not following a prescribed pattern"
            – MrMas
            Nov 30 at 21:55












          • This link headed in the right direction: unix.stackexchange.com/a/219277/88800 and, for persitence in a udev-like manner, this link shared important info: cyberciti.biz/faq/… So I created /etc/NetworkManager/dispatcher.d/99-ifup-local.sh to do this for each of my devices.
            – MrMas
            Nov 30 at 21:55















          up vote
          2
          down vote










          up vote
          2
          down vote









          Can a name be both "arbitrary" and "based on hardware location" at the same time? These words contradict each other.





          • The eth# names are assigned by the kernel itself based on detection order on each boot – in other words, they're "first come, first serve", and have nothing to do with hardware location.



            Older udev versions used to automatically generate a file in /etc/udev/rules.d to bind these assignments to the cards' MAC addresses. You can probably copy that file to the new systems.



            You can also write custom udev rules to set the NAME= parameter based on the address or PCI location. (Note that in the future udev may refuse to rename an interface to eth*, if it doesn't already. And even if allowed, this renaming is very brittle and can fail if the devices are discovered in a different order.)




          • Although, as far as I know, RHEL 6 used biosdevname for generating the physical-based interface names (kernel switch biosdevname=0). RHEL 7 uses systemd-udevd's built-in net_id for this purpose (kernel switch net.ifnames=0).



            To get the p1p2 style names, you can yum install biosdevname, then enable it through the kernel command line (biosdevname=1 net.ifnames=0). See the Red Hat documentation.




          Network interfaces cannot have aliases.






          share|improve this answer














          Can a name be both "arbitrary" and "based on hardware location" at the same time? These words contradict each other.





          • The eth# names are assigned by the kernel itself based on detection order on each boot – in other words, they're "first come, first serve", and have nothing to do with hardware location.



            Older udev versions used to automatically generate a file in /etc/udev/rules.d to bind these assignments to the cards' MAC addresses. You can probably copy that file to the new systems.



            You can also write custom udev rules to set the NAME= parameter based on the address or PCI location. (Note that in the future udev may refuse to rename an interface to eth*, if it doesn't already. And even if allowed, this renaming is very brittle and can fail if the devices are discovered in a different order.)




          • Although, as far as I know, RHEL 6 used biosdevname for generating the physical-based interface names (kernel switch biosdevname=0). RHEL 7 uses systemd-udevd's built-in net_id for this purpose (kernel switch net.ifnames=0).



            To get the p1p2 style names, you can yum install biosdevname, then enable it through the kernel command line (biosdevname=1 net.ifnames=0). See the Red Hat documentation.




          Network interfaces cannot have aliases.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 30 at 21:03

























          answered Nov 30 at 20:49









          grawity

          230k35484544




          230k35484544












          • By arbitrary, I mean "not following a prescribed pattern"
            – MrMas
            Nov 30 at 21:55












          • This link headed in the right direction: unix.stackexchange.com/a/219277/88800 and, for persitence in a udev-like manner, this link shared important info: cyberciti.biz/faq/… So I created /etc/NetworkManager/dispatcher.d/99-ifup-local.sh to do this for each of my devices.
            – MrMas
            Nov 30 at 21:55




















          • By arbitrary, I mean "not following a prescribed pattern"
            – MrMas
            Nov 30 at 21:55












          • This link headed in the right direction: unix.stackexchange.com/a/219277/88800 and, for persitence in a udev-like manner, this link shared important info: cyberciti.biz/faq/… So I created /etc/NetworkManager/dispatcher.d/99-ifup-local.sh to do this for each of my devices.
            – MrMas
            Nov 30 at 21:55


















          By arbitrary, I mean "not following a prescribed pattern"
          – MrMas
          Nov 30 at 21:55






          By arbitrary, I mean "not following a prescribed pattern"
          – MrMas
          Nov 30 at 21:55














          This link headed in the right direction: unix.stackexchange.com/a/219277/88800 and, for persitence in a udev-like manner, this link shared important info: cyberciti.biz/faq/… So I created /etc/NetworkManager/dispatcher.d/99-ifup-local.sh to do this for each of my devices.
          – MrMas
          Nov 30 at 21:55






          This link headed in the right direction: unix.stackexchange.com/a/219277/88800 and, for persitence in a udev-like manner, this link shared important info: cyberciti.biz/faq/… So I created /etc/NetworkManager/dispatcher.d/99-ifup-local.sh to do this for each of my devices.
          – MrMas
          Nov 30 at 21:55




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Super User!


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





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • 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%2fsuperuser.com%2fquestions%2f1379821%2fhow-do-i-assign-an-arbitrary-name-to-a-network-interface-based-on-hardware-locat%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

          flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

          Mangá

           ⁒  ․,‪⁊‑⁙ ⁖, ⁇‒※‌, †,⁖‗‌⁝    ‾‸⁘,‖⁔⁣,⁂‾
”‑,‥–,‬ ,⁀‹⁋‴⁑ ‒ ,‴⁋”‼ ⁨,‷⁔„ ‰′,‐‚ ‥‡‎“‷⁃⁨⁅⁣,⁔
⁇‘⁔⁡⁏⁌⁡‿‶‏⁨ ⁣⁕⁖⁨⁩⁥‽⁀  ‴‬⁜‟ ⁃‣‧⁕‮ …‍⁨‴ ⁩,⁚⁖‫ ,‵ ⁀,‮⁝‣‣ ⁑  ⁂– ․, ‾‽ ‏⁁“⁗‸ ‾… ‹‡⁌⁎‸‘ ‡⁏⁌‪ ‵⁛ ‎⁨ ―⁦⁤⁄⁕