Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Is it possible to rename network devices?[SOLVED]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
donjames
Apprentice
Apprentice


Joined: 19 Dec 2004
Posts: 251
Location: 32°9'50" N 94°50'54" W

PostPosted: Thu Sep 03, 2020 4:31 am    Post subject: Is it possible to rename network devices?[SOLVED] Reply with quote

Hi,

I am trying to make a home router on an old hp low-power computer.

Network names are:
enp0s3f2u1 for the ethernet device connected to the internet.
enp0s10 for the device connected to my local area network.

I would like to rename the ethernet connection WAN and the LAN connector LAN.
Gentoo was installed using genkernel.

My /etc/conf.d/net settings are:
config_enp0s10="192.168.1.2 netmask 255.255.255.0 brd 192.168.1.255"
routes_enp0s10="default via 192.168.1.1"
config_enp0s3f2u1="dhcp"



Is this possible? If so, how is it done?

Thanks,
donjames


Last edited by donjames on Thu Sep 03, 2020 11:30 pm; edited 1 time in total
Back to top
View user's profile Send private message
alamahant
Guru
Guru


Joined: 23 Mar 2019
Posts: 555

PostPosted: Thu Sep 03, 2020 8:22 am    Post subject: Reply with quote

Hi
In /etc/default/grub in the kernel comand line append
Code:
net.ifnames=0 biosdevname=0

Update grub and reboot.
:D
Back to top
View user's profile Send private message
Whissi
Developer
Developer


Joined: 12 Jan 2011
Posts: 168

PostPosted: Thu Sep 03, 2020 8:49 am    Post subject: Reply with quote

If you are using (e)udev, create
Code:
# cat /etc/udev/rules.d/80-net-setup-link.rules
#eth0
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="AA:BB:CC:DD:EE:FF", NAME="lan0"
#eth1
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="AA:BB:CC:DD:EE:F2", NAME="internet0"

Replace "AA:BB:CC:DD:EE:FF" and "AA:BB:CC:DD:EE:F2" with the MAC address of the NIC you want to rename.
_________________
Regards,
Whissi
Back to top
View user's profile Send private message
donjames
Apprentice
Apprentice


Joined: 19 Dec 2004
Posts: 251
Location: 32°9'50" N 94°50'54" W

PostPosted: Thu Sep 03, 2020 11:28 pm    Post subject: Is it possible to rename network devices? Reply with quote

Hi folks,

Thanks for the help. I was able to rename the ethernet adapters.

Here's what I did:
The text below is from the /etc/default/grub. Notice that the line, GRUB_CMDLINE_LINUX="net.ifnames=0", has been uncommented. This is line 26. I set nano to display line numbers.

# Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3 #
4 # To populate all changes in this file you need to regenerate your
5 # grub configuration file afterwards:
6 # 'grub-mkconfig -o /boot/grub/grub.cfg'
7 #
8 # See the grub info page for documentation on possible variables and
9 # their associated values.
10
11 GRUB_DISTRIBUTOR="Gentoo"
12
13 # Default menu entry
14 #GRUB_DEFAULT=0
15
16 # Boot the default entry this many seconds after the menu is displayed
17 #GRUB_TIMEOUT=5
18 #GRUB_TIMEOUT_STYLE=menu
19
20 # Append parameters to the linux kernel command line
#GRUB_CMDLINE_LINUX=""
22 #
23 # Examples:
24 #
25 # Boot with network interface renaming disabled
26 GRUB_CMDLINE_LINUX="net.ifnames=0"
27 #
28 # Boot with systemd instead of sysvinit (openrc)
29 # GRUB_CMDLINE_LINUX="init=/usr/lib/systemd/systemd"
30
31 # Append parameters to the linux kernel command line for non-recovery entries
32 #GRUB_CMDLINE_LINUX_DEFAULT=""
33
34 # Uncomment to disable graphical terminal (grub-pc only)
35 #GRUB_TERMINAL=console
36
37 # The resolution used on graphical terminal.
38 # Note that you can use only modes which your graphic card supports via VBE.
39 # You can see them in real GRUB with the command `vbeinfo'.
#GRUB_GFXMODE=640x480
41
42 # Set to 'text' to force the Linux kernel to boot in normal text
43 # mode, 'keep' to preserve the graphics mode set using
44 # 'GRUB_GFXMODE', 'WIDTHxHEIGHT'['xDEPTH'] to set a particular
45 # graphics mode, or a sequence of these separated by commas or
46 # semicolons to try several modes in sequence.
47 #GRUB_GFXPAYLOAD_LINUX=
48
49 # Path to theme spec txt file.
50 # The starfield is by default provided with use truetype.
51 # NOTE: when enabling custom theme, ensure you have required font/etc.
52 #GRUB_THEME="/boot/grub/themes/starfield/theme.txt"
53
54 # Background image used on graphical terminal.
55 # Can be in various bitmap formats.
#GRUB_BACKGROUND="/boot/grub/mybackground.png"
57
58 # Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to kernel
59 #GRUB_DISABLE_LINUX_UUID=true
60
61 # Uncomment to disable generation of recovery mode menu entries
62 #GRUB_DISABLE_RECOVERY=true
63
64 # Uncomment to disable generation of the submenu and put all choices on
65 # the top-level menu.
66 # Besides the visual affect of no sub menu, this makes navigation of the
67 # menu easier for a user who can't see the screen.
68 #GRUB_DISABLE_SUBMENU=y
69
70 # Uncomment to play a tone when the main menu is displayed.
71 # This is useful, for example, to allow users who can't see the screen
72 # to know when they can make a choice on the menu.
73 #GRUB_INIT_TUNE="60 800 1"
74

After /etc/default/grub is saved and edited, I did:
# grub-install /dev/sda
# reboot
If this is not done, the change will not happen.

Next, I created the file, /etc/udev/rules.d/80-net-setup-link.rules
# nano /etc/udev/rules.d/80-net-setup-link.rules
The content of this file is as follows:
1 #eth0
2 SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="00:0a:e4:8c:83:b0", NAME="eth0"
3 #eth1
4 SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="3c:8c:f8:fb:4a:cf", NAME="eth1"
5
I had nano set to display line numbers -- the line numbers are not part of the file.

Then
#reboot
The ethernet adapters are now named eth0 and eth1.

Regards,
donjames
Back to top
View user's profile Send private message
x90e
n00b
n00b


Joined: 30 Sep 2020
Posts: 39

PostPosted: Wed Sep 30, 2020 7:55 pm    Post subject: Reply with quote

Instead of running grub-install /dev/sda after updating /etc/default/grub, you can simply (make sure /boot is mounted) run grub-mkconfig -o /boot/grub/grub.cfg (assuming you haven't changed the default config location of grub).
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum