ubuntu ens33网卡掉线问题配置系统重启后自动加载网卡驱动

 

cd /lib/systemd/system

 

进入system目录 找到 rc-local.service 文件

cat rc-local.service
#  SPDX-License-Identifier: LGPL-2.1-or-later
#
#  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.

# This unit gets pulled automatically into multi-user.target by
# systemd-rc-local-generator if /etc/rc.local is executable.
[Unit]
Description=/etc/rc.local Compatibility
Documentation=man:systemd-rc-local-generator(8)
ConditionFileIsExecutable=/etc/rc.local
After=network.target

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
RemainAfterExit=yes
GuessMainPID=no

可以看到ExecStart指向了/etc/rc.local,去到 etc目录找到rc.local,没有则创建(sudo touch rc.local),添加以下内容:

#!/bin/bash
sudo dhclient ens33

保存后退出。

sudo systemctl enable rc-local
sudo systemctl start rc-local
sudo systemctl status rc-local
sudo systemctl restart rc-local

 

posted @ 2022-10-09 09:42  浮生如梦--心猿  阅读(228)  评论(0编辑  收藏  举报