如何将Ubuntu16.4.0的接口名改成传统的eth0 /etc/default/grub

vi /etc/default/grub



# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"
julian@julian-virtual-machine:~$






##############################################################

  1. Edit /etc/default/grub
  2. At the end of GRUB_CMDLINE_LINUX line append "net.ifnames=0biosdevname=0"
  3. Save the file
  4. Type "grub-mkconfig -o /boot/grub/grub.cfg"
  5. Type "reboot"

### 配置或访问 `eth0` 网卡 对于希望在 Ubuntu 中配置或访问为 `eth0` 的网卡,可以按照如下方式操作: #### 修改GRUB引导加载程序以更改网卡命规则 为了确保网卡称被命为 `eth0` 而不是现代的可预测网络接口(如 `ens33`),可以通过编辑 GRUB 文件来实现这一目标。具体来说,在文件 `/etc/default/grub` 中添加特定的内核命令行选项[^3]。 ```bash sudo vim /etc/default/grub ``` 找到并修改下列两行内容: ```plaintext GRUB_CMDLINE_LINUX_DEFAULT="" GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0" ``` 保存更改后更新 GRUB 并重启计算机以便应用新的设置: ```bash sudo update-grub sudo reboot ``` #### 编辑网络接口配置文件 一旦确认网卡已被重命为 `eth0` 或者即使它仍然保持默认称,也可以通过调整相应的网络接口配置来进行进一步定制化设定。通常情况下,这些配置位于 `/etc/netplan/` 目录下的 YAML 文件中。如果该目录不存在任何文件,则可能需要创建一个新的配置文件[^1]。 假设要为 `eth0` 设定静态 IP 地址,那么可以在 Netplan 配置文件中加入以下内容作为例子: ```yaml network: version: 2 renderer: networkd ethernets: eth0: dhcp4: no addresses: - 192.168.1.100/24 gateway4: 192.168.1.1 nameservers: search: [mydomain, otherdomain] addresses: [8.8.8.8, 8.8.4.4] ``` 完成上述配置之后,执行下面这条指令让改动生效: ```bash sudo netplan apply ``` #### 处理可能出现的问题 有时可能会遇到网卡丢失的情况,这可能是由于 NetworkManager 服务出现问题所致。此时可通过停止、清理状态数据再启动此服务的方式尝试解决问题[^2]。 ```bash sudo systemctl stop NetworkManager.service sudo rm /var/lib/NetworkManager/NetworkManager.state sudo systemctl start NetworkManager.service ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值