前言:
在下载压缩包之后,先按照 README 进行使用,出现错误在看,以下是几个我遇到的问题:
无法找到网卡或系统未完成网卡初始化操作。请稍后再尝试认证
参考3.2的修改网卡名字。
用户MAC地址绑定错误
参考第二章,修改MAC地址。
一.环境:
ubuntu20.04, 双系统
二.永久修改MAC方法:
1.根据路径:
/lib/systemd/system/rc-local.service
找到 rc-local.service 文件,(此文件为只读文件,想要编辑可以使用下行命令):
sudo gedit rc-local.service
此文件为开机自启动文件,在20.04下次文件默认不执行,下面为文件内容:
cat > /lib/systemd/system/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
在最后面添加以下内容:
[Install]
WantedBy=multi-user.target
2.创建 /etc/rc.local
Ubuntu 20.04 默认不存在 /etc/rc.local,需要自己创建,注意第一行必须是 #!/bin/bash ,否则启动 rc-local 服务报错。
在 etc 文件夹下打开终端:(因20.04没有此文件,所以此命令会生成一个rc.local文档)
sudo gedit rc.local
在文件中输入:
#!/bin/bash
/usr/sbin/ifconfig eth0 down
/usr/sbin/ifconfig eth0 hw ether b6:f5:2c:0d:3d:16
/usr/sbin/ifconfig eth0 up
上述代码中:
eth0 为你的网卡名,可以在终端中使用 ifconfig 查看,安装 inconfig 在第 4 步,第三行后面的 b6:f5:2c:0d:3d:16 为你想改变的MAC地址(并不是必须我这个,根据你自己的来)。
编辑完成后保存。
3.修改 /etc/rc.local 权限
chmod 755 /etc/rc.local
4.安装ifconfig命令
apt-get install net-tools
5.设置rc-local为开机自启动
systemctl enable rc-local
6. 启动rc-local服务
systemctl daemon-reload
systemctl start rc-local
三.制作登陆脚本:
1.下载锐捷客户端:
我是在学校的官网下下载的压缩包,内容如下:
目录结构:
|-rjsupplicant.sh
|-x86
|-rjsuppliant
|-updateprodect
|-lib
|-libcrypto.so.6
|-libpcap.so
|-libssl.so.6
|-librt-2.6.so
|-librt-2.10.2.so
|-x64
|-rjsuppliant
|-updateprodect
|-lib
|-libcrypto.so.6
|-libpcap.so
|-libssl.so.6
|-librt-2.6.so
其中的 -rjsupplicant.sh 为脚本文件,接下来介绍使用方法:
在 home/ xx(你的用户名)/ 路径下新建脚本:
sudo gedit net.sh
在文件中添加:(第一句 cd 后面的内容是你的 rjsupplicant.sh 脚本文件的文件夹位置)
cd RG_Supplicant_For_Linux_V1.31/rjsupplicant
sudo ./rjsupplicant.sh -a 1 -n eth0 -d 1 -u 用户名 -p 密码
cd 之后的为 rjsupplicant.sh 的路径
此处如果发现错误,请使用 ifconfig 检查你的网卡名字是否是 eth0 。
2.修改网卡名字:
先修改grub文件:
sudo gedit /etc/default/grub
找到
GRUB_CMDLINE_LINUX=""
改成GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"
再输入sudo grub-mkconfig -o /boot/grub/grub.cfg
然后重启,再
ifconfig
,发现网卡名改成了"eth0"
3.登陆:
前面已经完成了MAC更改和制作登陆脚本文件,接下来执行脚本文件:
sudo bash net.sh
认证成功!
sysctl: 写入错误: 错误的文件描述符
sysctl: 写入错误: 错误的文件描述符
sysctl: 写入错误: 错误的文件描述符
认证方式 有线认证
认证网卡 eth0
用户名 xxxxxxxx(你的用户名)
服务 internet
2024-03-25 18:11:07 正在停止系统(network-manager)服务
2024-03-25 18:11:07 正在启用网卡
2024-03-25 18:11:08 正在初始化...
2024-03-25 18:11:08 寻找认证服务器...
2024-03-25 18:11:08 连接认证服务器...
2024-03-25 18:11:08 正在进行认证...
2024-03-25 18:11:08 正在获取IP地址...
2024-03-25 18:11:11 寻找认证服务器...
2024-03-25 18:11:11 连接认证服务器...
2024-03-25 18:11:11 正在进行认证...
2024-03-25 18:11:11 认证成功
参考文章:
linux下校园网用锐捷客户端如何上网_rg_supplicant_for_linux_v1.31,安装提示sysctl write err-CSDN博客