嵌入式Linux设备如何链接校园网
嵌入式Linux设备如何链接校园网
CzrTuringB:
2023年9月15日:主要实现:1、嵌入式设备通过网线链接校园网实现锐捷客户端认证。2、嵌入式设备通过USB WIFI模块将校园网进行共享,进而解决校园网的登录设备限制。
第一部分 开启热点
-
下载create_ap源码,并编译:
1
2
3
4
5
6
7
8cd /usr/local
如果git速度太慢的话可以用电脑翻墙下载,并使用winscp软件传递到NanoPi上
git clone https://github.com/oblique/create_ap
cd create_ap
编译
make install
安装依赖库
apt-get install util-Linux procps hostapd iproute2 iw haveged dnsmasq -
创建热点:
1
2
3sudo create_ap wlx90de808a346b eth0 Nano 1542453296
sudo nohup create_ap wlx90de808a346b eth0 Nano 1542453296 &
可以查看输出文件nohup.out来判断热点的创建情况 -
设置开机启动:
1
21、打开/etc/rc.local
2、在exit 0之前添加:sudo create_ap 无线网卡名称 有线网卡名称 热点名 密码
第二部分 校园网有线认证
-
mentohust并没有基于armv7的软件包,需要我们自行从源码编译。
-
下载mentohust源码并进行安装编译:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25cd /usr/local
mkdir mentohust
cd mentohust
wget http://www.tcpdump.org/release/libpcap-1.0.0.tar.gz
配置libpcap编译环境:
apt-get install gcc libc6-dev m4 flex bison
编译libocap:
tar zxvf libpcap-1.0.0.tar.gz
cd libpcap-1.0.0/
./configure
make
下载mentohust:
ls
cd ..
wget https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/mentohust/mentohust-0.3.1.tar.gz
配置编译环境:
apt-get install build-essential bison flex zlib1g-dev libncurses5-dev subversion quilt intltool ruby fastjar unzip gawk
配置编译mentohust:若文件名不同,则自行修改
tar zxvf mentohust-0.3.1.tar.gz
cd mentohust-0.3.1/
./configure --disable-encodepass --disable-arp --disable-notify --disable-nls --with-pcap=/usr/local/mentohust/libpcap-1.0.0/libpcap.a
make
将mentohust的可执行文件复制到/usr/bin文件夹下
cd src/
cp mentohust /usr/bin -
配置连接信息:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29欢迎使用MentoHUST 版本: 0.3.3
Copyright (C) 2009 HustMoon Studio
人到华中大,有甜亦有辣。明德厚学地,求是创新家。
Bug report to http://code.google.com/p/mentohust/issues/list
用法: mentohust [-选项][参数]
选项: -h 显示本帮助信息
-k 退出程序
-w 保存参数到配置文件
-u 用户名
-p 密码
-n 网卡名
-i IP[默认本机IP]
-m 子网掩码[默认本机掩码]
-g 网关[默认0.0.0.0]
-s DNS[默认0.0.0.0]
-o Ping主机[默认0.0.0.0,表示关闭该功能]
-t 认证超时(秒)[默认8]
-e 响应间隔(秒)[默认30]
-r 失败等待(秒)[默认15]
-a 组播地址: 0(标准) 1(锐捷) 2(赛尔) [默认0]
-d DHCP方式: 0(不使用) 1(二次认证) 2(认证后) 3(认证前) [默认0]
-b 是否后台运行: 0(否) 1(是,关闭输出) 2(是,保留输出) 3(是,输出到文件) [默认0]
-y 是否显示通知: 0(否) 1~20(是)[默认5]
-f 自定义数据文件[默认不使用]
-c DHCP脚本[默认dhclient]
例如: mentohust -uusername -ppassword -neth0 -i192.168.0.1 -m255.255.255.0 -g0.0.0.0 -s0.0.0.0 -o0.0.0.0 -t8 -e30 -r15 -a0 -d1 -b0 -fdefault.mpf -cdhclient
使用时请确保是以root权限运行!
我的:
mentohust -uSG202301005 -p070017 -neth0 -i192.168.0.1 -m255.255.255.0 -g0.0.0.0 -s0.0.0.0 -o0.0.0.0 -t8 -e30 -r15 -a0 -d1 -b1 -fdefault.mpf -cdhclient -
开机自启:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20sudo vim /etc/init.d/mentohust
文件内容如下
!/bin/sh
# chkconfig: 2345 80 20
description: mentohust
./usr/bin/mentohust
设置文件权限
chmod 755 /etc/init.d/mentohust
下载sysv-rc-conf
sudo apt-get install sysv-rc-conf
查看服务列表:
sudo sysv-rc-conf
添加服务
sudo sysv-rc-conf --add mentohust
开启服务
sudo sysv-rc-conf mentohust on
查看是否添加
sudo sysv-rc-conf --list mentohust
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 CzrTuringB的博客!