Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save SwagDevOps/b2daafd7a5ece37e11d5624f927be708 to your computer and use it in GitHub Desktop.

Select an option

Save SwagDevOps/b2daafd7a5ece37e11d5624f927be708 to your computer and use it in GitHub Desktop.

Revisions

  1. SwagDevOps revised this gist Jun 15, 2020. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion predictable_network_interfaces_with_systemd.md
    Original file line number Diff line number Diff line change
    @@ -16,7 +16,7 @@ source: [PredictableNetworkInterfaceNames](https://www.freedesktop.org/wiki/Soft
    ## ``/lib/systemd/network/99-default.link``

    ```sh
    # sudo vim /lib/systemd/network/99-default.link
    # less /lib/systemd/network/99-default.link
    ```
    ### Original

    @@ -34,6 +34,8 @@ source: [PredictableNetworkInterfaceNames](https://www.freedesktop.org/wiki/Soft
    NamePolicy=kernel database onboard slot path
    MACAddressPolicy=persistent
    ```
    You SHOULD NOT modify this file, it COULD be regularly reverted by packages updates.

    ### Edited

    ```ini
  2. SwagDevOps revised this gist Jun 15, 2020. 1 changed file with 9 additions and 1 deletion.
    10 changes: 9 additions & 1 deletion predictable_network_interfaces_with_systemd.md
    Original file line number Diff line number Diff line change
    @@ -38,6 +38,10 @@ MACAddressPolicy=persistent

    ```ini
    # /etc/systemd/network/99-default.link

    [Match]
    OriginalName=*

    [Link]
    NamePolicy=mac path
    MACAddressPolicy=none
    @@ -85,4 +89,8 @@ Sample output:
    ID_NET_NAME_MAC=enx9c5c8e538309
    ID_NET_NAME_ONBOARD=eno1
    ID_NET_NAME_PATH=enp0s25
    ```
    ```

    ## See also

    * [General Network Configuration = Linux From Scratch](http://www.linuxfromscratch.org/lfs/view/9.1-systemd/chapter07/network.html)
  3. SwagDevOps revised this gist Jan 4, 2020. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions predictable_network_interfaces_with_systemd.md
    Original file line number Diff line number Diff line change
    @@ -37,6 +37,7 @@ MACAddressPolicy=persistent
    ### Edited

    ```ini
    # /etc/systemd/network/99-default.link
    [Link]
    NamePolicy=mac path
    MACAddressPolicy=none
  4. SwagDevOps revised this gist Jul 10, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion predictable_network_interfaces_with_systemd.md
    Original file line number Diff line number Diff line change
    @@ -74,7 +74,7 @@ GRUB_CMDLINE_LINUX="net.ifnames=1"
    ```sh
    (cd /sys/class/net && find * -maxdepth 1) | grep -Ev '^lo$' | \
    head -1 | \
    perl -pe 's/:$//'| \
    perl -pe "s/\n//" | \
    xargs -r0I {} sudo udevadm test /sys/class/net/{} 2> /dev/null | grep NAME
    ```

  5. SwagDevOps revised this gist Jul 10, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion predictable_network_interfaces_with_systemd.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    # Names incorporating the interfaces's MAC address

    > With ``systemd 197`` we have added native support for a number of different naming policies into ``systemd``/``udevd``
    > proper and made a scheme similar to biosdevname's (but generally more powerful,
    > proper and made a scheme similar to ``biosdevname``'s (but generally more powerful,
    > and closer to kernel-internal device identification schemes) the default.
    > The following different naming schemes for network interfaces are now supported by ``udev`` natively:
    >
  6. SwagDevOps revised this gist Jul 10, 2019. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions predictable_network_interfaces_with_systemd.md
    Original file line number Diff line number Diff line change
    @@ -10,10 +10,8 @@
    > 3. Names incorporating physical/geographical location of the connector of the hardware (example: ``enp2s0``)
    > 4. Names incorporating the interfaces's MAC address (example: ``enx78e7d1ea46da``)
    > 5. Classic, unpredictable kernel-native ethX naming (example: ``eth0``)
    >
    > source: [PredictableNetworkInterfaceNames](https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/)
    Names incorporating the interfaces's MAC address (example: ``enx78e7d1ea46da``)
    source: [PredictableNetworkInterfaceNames](https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/)

    ## ``/lib/systemd/network/99-default.link``

    @@ -53,6 +51,8 @@ MACAddressPolicy=none
    > * ``path`` The name is set based on the device's physical location, as exported by the ``udev`` property ``ID_NET_NAME_PATH``.
    > * ``mac`` The name is set based on the device's persistent MAC address, as exported by the ``udev`` property ``ID_NET_NAME_MAC``.
    source: [systemd.link — Network device configuration](https://www.freedesktop.org/software/systemd/man/systemd.link.html)

    ## ``/etc/default/grub``

    ```sh
  7. SwagDevOps revised this gist Jul 10, 2019. 1 changed file with 17 additions and 0 deletions.
    17 changes: 17 additions & 0 deletions predictable_network_interfaces_with_systemd.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,20 @@
    # Names incorporating the interfaces's MAC address

    > With ``systemd 197`` we have added native support for a number of different naming policies into ``systemd``/``udevd``
    > proper and made a scheme similar to biosdevname's (but generally more powerful,
    > and closer to kernel-internal device identification schemes) the default.
    > The following different naming schemes for network interfaces are now supported by ``udev`` natively:
    >
    > 1. Names incorporating Firmware/BIOS provided index numbers for on-board devices (example: ``eno1``)
    > 2. Names incorporating Firmware/BIOS provided PCI Express hotplug slot index numbers (example: ``ens1``)
    > 3. Names incorporating physical/geographical location of the connector of the hardware (example: ``enp2s0``)
    > 4. Names incorporating the interfaces's MAC address (example: ``enx78e7d1ea46da``)
    > 5. Classic, unpredictable kernel-native ethX naming (example: ``eth0``)
    >
    > source: [PredictableNetworkInterfaceNames](https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/)
    Names incorporating the interfaces's MAC address (example: ``enx78e7d1ea46da``)

    ## ``/lib/systemd/network/99-default.link``

    ```sh
  8. SwagDevOps revised this gist Jul 10, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions predictable_network_interfaces_with_systemd.md
    Original file line number Diff line number Diff line change
    @@ -31,8 +31,8 @@ MACAddressPolicy=none
    > An ordered, space-separated list of policies by which the interface name should be set.
    > ``NamePolicy=`` may be disabled by specifying ``net.ifnames=0`` on the kernel command line.
    > Each of the policies may fail, and the first successful one is used.
    > The name is not set directly, but is exported to udev as the property ``ID_NET_NAME``,
    > which is, by default, used by a udev(7), rule to set ``NAME``. The policies used above are:
    > The name is not set directly, but is exported to ``udev`` as the property ``ID_NET_NAME``,
    > which is, by default, used by a ``udev(7)``, rule to set ``NAME``. The policies used above are:
    > * ``path`` The name is set based on the device's physical location, as exported by the ``udev`` property ``ID_NET_NAME_PATH``.
    > * ``mac`` The name is set based on the device's persistent MAC address, as exported by the ``udev`` property ``ID_NET_NAME_MAC``.
  9. SwagDevOps revised this gist Jul 10, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions predictable_network_interfaces_with_systemd.md
    Original file line number Diff line number Diff line change
    @@ -33,8 +33,8 @@ MACAddressPolicy=none
    > Each of the policies may fail, and the first successful one is used.
    > The name is not set directly, but is exported to udev as the property ``ID_NET_NAME``,
    > which is, by default, used by a udev(7), rule to set ``NAME``. The policies used above are:
    > * ``path`` The name is set based on the device's physical location, as exported by the udev property ``ID_NET_NAME_PATH``.
    > * ``mac`` The name is set based on the device's persistent MAC address, as exported by the udev property ``ID_NET_NAME_MAC``.
    > * ``path`` The name is set based on the device's physical location, as exported by the ``udev`` property ``ID_NET_NAME_PATH``.
    > * ``mac`` The name is set based on the device's persistent MAC address, as exported by the ``udev`` property ``ID_NET_NAME_MAC``.
    ## ``/etc/default/grub``

  10. SwagDevOps revised this gist Jul 10, 2019. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions predictable_network_interfaces_with_systemd.md
    Original file line number Diff line number Diff line change
    @@ -55,9 +55,10 @@ GRUB_CMDLINE_LINUX="net.ifnames=1"
    ```

    ```sh
    ls /sys/class/net/* | grep -Ev '^lo$' | head -1 | \
    perl -pe 's/:$//'| perl -pe "s/\n//" | \
    xargs -r0I {} sudo udevadm test {} 2> /dev/null | grep NAME
    (cd /sys/class/net && find * -maxdepth 1) | grep -Ev '^lo$' | \
    head -1 | \
    perl -pe 's/:$//'| \
    xargs -r0I {} sudo udevadm test /sys/class/net/{} 2> /dev/null | grep NAME
    ```

    Sample output:
  11. SwagDevOps revised this gist Jul 10, 2019. 1 changed file with 21 additions and 0 deletions.
    21 changes: 21 additions & 0 deletions predictable_network_interfaces_with_systemd.md
    Original file line number Diff line number Diff line change
    @@ -45,4 +45,25 @@ GRUB_CMDLINE_LINUX="net.ifnames=1"
    ```sh
    # sudo update-grub
    # sudo update-initramfs -u
    # sudo reboot
    ```

    ## Check/ensure

    ```sh
    # ls /sys/class/net/
    ```

    ```sh
    ls /sys/class/net/* | grep -Ev '^lo$' | head -1 | \
    perl -pe 's/:$//'| perl -pe "s/\n//" | \
    xargs -r0I {} sudo udevadm test {} 2> /dev/null | grep NAME
    ```

    Sample output:

    ```
    ID_NET_NAME_MAC=enx9c5c8e538309
    ID_NET_NAME_ONBOARD=eno1
    ID_NET_NAME_PATH=enp0s25
    ```
  12. SwagDevOps revised this gist Jul 10, 2019. 1 changed file with 15 additions and 2 deletions.
    17 changes: 15 additions & 2 deletions predictable_network_interfaces_with_systemd.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    ## ``/lib/systemd/network/99-default.link``

    ```sh
    sudo vim /lib/systemd/network/99-default.link
    # sudo vim /lib/systemd/network/99-default.link
    ```
    ### Original

    @@ -32,4 +32,17 @@ MACAddressPolicy=none
    > ``NamePolicy=`` may be disabled by specifying ``net.ifnames=0`` on the kernel command line.
    > Each of the policies may fail, and the first successful one is used.
    > The name is not set directly, but is exported to udev as the property ``ID_NET_NAME``,
    > which is, by default, used by a udev(7), rule to set ``NAME``. The available policies are:
    > which is, by default, used by a udev(7), rule to set ``NAME``. The policies used above are:
    > * ``path`` The name is set based on the device's physical location, as exported by the udev property ``ID_NET_NAME_PATH``.
    > * ``mac`` The name is set based on the device's persistent MAC address, as exported by the udev property ``ID_NET_NAME_MAC``.
    ## ``/etc/default/grub``

    ```sh
    GRUB_CMDLINE_LINUX="net.ifnames=1"
    ```

    ```sh
    # sudo update-grub
    # sudo update-initramfs -u
    ```
  13. SwagDevOps revised this gist Jul 10, 2019. 1 changed file with 8 additions and 1 deletion.
    9 changes: 8 additions & 1 deletion predictable_network_interfaces_with_systemd.md
    Original file line number Diff line number Diff line change
    @@ -25,4 +25,11 @@ MACAddressPolicy=persistent
    [Link]
    NamePolicy=mac path
    MACAddressPolicy=none
    ```
    ```

    > ``NamePolicy=``
    > An ordered, space-separated list of policies by which the interface name should be set.
    > ``NamePolicy=`` may be disabled by specifying ``net.ifnames=0`` on the kernel command line.
    > Each of the policies may fail, and the first successful one is used.
    > The name is not set directly, but is exported to udev as the property ``ID_NET_NAME``,
    > which is, by default, used by a udev(7), rule to set ``NAME``. The available policies are:
  14. SwagDevOps revised this gist Jul 10, 2019. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions predictable_network_interfaces_with_systemd.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,9 @@
    ## ``/lib/systemd/network/99-default.link``

    ```sh
    sudo vim /lib/systemd/network/99-default.link
    ```
    ### Original

    ```ini
    # SPDX-License-Identifier: LGPL-2.1+
    @@ -16,6 +19,8 @@ sudo vim /lib/systemd/network/99-default.link
    NamePolicy=kernel database onboard slot path
    MACAddressPolicy=persistent
    ```
    ### Edited

    ```ini
    [Link]
    NamePolicy=mac path
  15. SwagDevOps created this gist Jul 10, 2019.
    23 changes: 23 additions & 0 deletions predictable_network_interfaces_with_systemd.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    ```sh
    sudo vim /lib/systemd/network/99-default.link
    ```

    ```ini
    # SPDX-License-Identifier: LGPL-2.1+
    #
    # This file is part of systemd.
    #
    # systemd is free software; you can redistribute it and/or modify it
    # under the terms of the GNU Lesser General Public License as published by
    # the Free Software Foundation; either version 2.1 of the License, or
    # (at your option) any later version.

    [Link]
    NamePolicy=kernel database onboard slot path
    MACAddressPolicy=persistent
    ```
    ```ini
    [Link]
    NamePolicy=mac path
    MACAddressPolicy=none
    ```