ubuntu 修改网卡名

ubuntu 修改网卡名

sudo nano /etc/default/grub
****
找到GRUB_CMDLINE_LINUX=""
改为GRUB_CMDLINE_LINUX=***"net.ifnames=0 biosdevname=0 "***
    **然后**
sudo grub-mkconfig -o /boot/grub/grub.cfg

重启后,网卡名称 变成了eth0和wlan0

重启后没有enth0 无法ping

问题
ifconfig 没有eth0 但 ifconfig -a 有。

解决方法:
是需要本地网卡驱动启动 ifconfig enth0 up

修改 /etc/network/interfaces 加入eth0配置

然后sudo /etc/init.d/networking restart 或在sudo systemclt networing restart
但有错误 :
[…] Restarting networking (via systemctl): networking.serviceJob for networking.service failed because the control process exited with error code.
See “systemctl status networking.service” and “journalctl -xe” for details

看提示输入 systemctl status networking.service
看状态详细信息 问题 :Unknown interface etho
要ifconfig看有没有eth0信息sudo ifup eth0 启动网卡
$ifconfig -a eth0 显示IP
sudo ifup eth0

**ii@ii-ThinkPad-Edge-E431:~$ sudo nano /etc/network/interfaces
ii@ii-ThinkPad-Edge-E431:~$ sudo /etc/init.d/networking restart**
[....] Restarting networking (via systemctl): networking.serviceJob for networking.service failed because the control process exited with error code.
See "systemctl status networking.service" and "journalctl -xe" for details.
 failed!
**ii@ii-ThinkPad-Edge-E431:~$ systemctl status networking.service**
● networking.service - Raise network interfaces
   Loaded: loaded (/lib/systemd/system/networking.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Tue 2022-04-05 10:34:38 CST; 3s ago
     Docs: man:interfaces(5)
  Process: 4413 ExecStart=/sbin/ifup -a --read-environment (code=exited, status=1/FAILURE)
  Process: 4411 ExecStartPre=/bin/sh -c [ "$CONFIGURE_INTERFACES" != "no" ] && [ -n "$(ifquery --read-environment --list --exclude=lo)" ] &&
 Main PID: 4413 (code=exited, status=1/FAILURE)

405 10:34:38 ii-ThinkPad-Edge-E431 systemd[1]: Starting Raise network interfaces...
405 10:34:38 ii-ThinkPad-Edge-E431 sh[4411]: Unknown interface etho
405 10:34:38 ii-ThinkPad-Edge-E431 ifup[4413]: Unknown interface etho
405 10:34:38 ii-ThinkPad-Edge-E431 systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE
405 10:34:38 ii-ThinkPad-Edge-E431 systemd[1]: networking.service: Failed with result 'exit-code'.
405 10:34:38 ii-ThinkPad-Edge-E431 systemd[1]: Failed to start Raise network interfaces.

**ii@ii-ThinkPad-Edge-E431:~$ sudo ifup eth0 
ii@ii-ThinkPad-Edge-E431:~$ sudo ifconfig**
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.22.10  netmask 255.255.255.0  broadcast 192.168.22.255
        inet6 fe80::2ad2:44ff:fe67:4443  prefixlen 64  scopeid 0x20<link>
        ether 28:d2:44:67:44:43  txqueuelen 1000  (以太网)
        RX packets 86  bytes 6293 (6.2 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 44  bytes 7153 (7.1 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (本地环回)
        RX packets 6912  bytes 597255 (597.2 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 6912  bytes 597255 (597.2 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

rename13: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.239.224  netmask 255.255.255.0  broadcast 192.168.239.255
        inet6 fe80::8b3a:df83:89e8:c9b0  prefixlen 64  scopeid 0x20<link>
        ether ea:58:32:4a:cf:53  txqueuelen 1000  (以太网)
        RX packets 16904  bytes 12967730 (12.9 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 16615  bytes 3110099 (3.1 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

**ii@ii-ThinkPad-Edge-E431:~$ systemctl status networking.service**
● networking.service - Raise network interfaces
   Loaded: loaded (/lib/systemd/system/networking.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Tue 2022-04-05 10:34:38 CST; 1min 32s ago
     Docs: man:interfaces(5)
  Process: 4413 ExecStart=/sbin/ifup -a --read-environment (code=exited, status=1/FAILURE)
  Process: 4411 ExecStartPre=/bin/sh -c [ "$CONFIGURE_INTERFACES" != "no" ] && [ -n "$(ifquery --read-environment --list --exclude=lo)" ] &&
 Main PID: 4413 (code=exited, status=1/FAILURE)

405 10:34:38 ii-ThinkPad-Edge-E431 systemd[1]: Starting Raise network interfaces...
405 10:34:38 ii-ThinkPad-Edge-E431 sh[4411]: Unknown interface etho
405 10:34:38 ii-ThinkPad-Edge-E431 ifup[4413]: Unknown interface etho
405 10:34:38 ii-ThinkPad-Edge-E431 systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE
405 10:34:38 ii-ThinkPad-Edge-E431 systemd[1]: networking.service: Failed with result 'exit-code'.
405 10:34:38 ii-ThinkPad-Edge-E431 systemd[1]: Failed to start Raise network interfaces.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值