Ubuntu下启动后网卡没有服务没有启动的问题

参照了很多帖子,两个典型的帖子分别是
https://blog.csdn.net/ErErFei/article/details/98205463
Ubuntu 18.04设置开机自动启动
https://blog.csdn.net/weixin_42116341/article/details/81410805
Ubuntu输入ifconfig找不到IP地址,只有lo问题

和第二个帖子里面不同的是,我的每次重启都要敲一遍这个命令

sudo dhclient ens33
sudo ifconfig ens33

所以就参照第一个帖子吧这两条命令在启动时候执行。
添加内容:

#以下为添加项
sudo dhclient eno1
sudo ifconfig eno1
#添加log输出,以确认命令正确执行
sudo echo “the enthernet boot information!” > /usr/local/text1.log
#以上为添加项

具体如下:

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

#以下为添加项
sudo dhclient eno1
sudo ifconfig eno1
# 添加log输出,以确认命令正确执行
sudo echo "the enthernet boot information!" > /usr/local/text1.log
#以上为添加项

sudo echo "just test" > /usr/local/text.log
exit 0

reboot后ifconfig,网卡显示出来了

eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.101.103  netmask 255.255.255.0  broadcast 192.168.101.255
        inet6 fe80::4639:c4ff:fe54:757e  prefixlen 64  scopeid 0x20<link>
        ether 44:39:c4:54:75:7e  txqueuelen 1000  (以太网)
        RX packets 221  bytes 27984 (27.9 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 245  bytes 48380 (48.3 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 20  memory 0xf7e00000-f7e20000  

结束,收工。

你可能感兴趣的:(Linux)