【记录】Linux 设置个人热点

Last updated on March 20, 2024 pm

实在受不了虚拟机的性能损失了,再加上 Win11 上跑虚拟机对 SSD 的损耗过大,因此还是将系统换成了 ubuntu,只要注意选无网络安装,不要去更新,基本还是很好换系统的。另外清华源不错!

换系统后,需要重新折腾一下 AP 设置,因此记录一下折腾过程。

无线网卡是垃圾的 mediatek mt7921e

更新内核

因为网卡垃圾,不得不更新到最新的内核才支持 AP 设置

1
2
3
4
5
6
7
proxychains wget https://raw.githubusercontent.com/pimlie/ubuntu-mainline-kernel.sh/master/ubuntu-mainline-kernel.sh
chmod +x ubuntu-mainline-kernel.sh
sudo gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv 17C622B0 # 网络错误,需要绕过某个东西
sudo proxychains ./ubuntu-mainline-kernel.sh -i
sudo reboot
uname -r
sudo apt --fix-broken install

解决 53 端口占用

1
2
sudo systemctl stop systemd-resolved
sudo nano /etc/systemd/resolved.conf
1
2
3
[Resolve]
DNS=8.8.8.8 #取消注释,增加dns
DNSStubListener=no #取消注释,把yes改为no
1
sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf

安装 create_ap

1
2
3
4
5
cd /dev/shm/
proxychains git clone https://github.com/oblique/create_ap
cd create_ap
sudo make install
sudo apt-get install util-linux procps hostapd iproute2 iw haveged dnsmasq

测试 create_ap

1
sudo create_ap wlp2s0 enp1s0 ser5 <密码> --country CN -c 157 --freq-band 5 --no-virt

启用 create_ap

1
2
3
4
nano create_ap.service
sudo mv create_ap.service /etc/systemd/system/create_ap.service
sudo systemctl enable create_ap
sudo systemctl start create_ap
1
2
3
4
5
6
7
8
9
[Unit]
Description=create_ap
After=network.target docker.service
[Service]
ExecStart=/usr/bin/create_ap wlp2s0 enp1s0 ser5 <密码> --country CN -c 157 --freq-band 5 --no-virt
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
[Install]
WantedBy=multi-user.target

增加稳定性

1
2
sudo crontab -e
# 5 4 * * * /usr/bin/systemctl restart create_ap

踩坑花絮

  • lnxrouter 虽然在 create_ap 上进行了更新,但是实际体验在所有信道上都报错,折腾了半天,放弃
  • 搜到一些老旧的教程,自己去折腾 hostapd,然后自己去配置网桥的时候把服务器弄断网好几次,不得不到处找显示器和键盘
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
sudo su
cat << EOF > /etc/hostapd/hostapd.conf
interface=wlp2s0
bridge=br-ap
driver=nl80211
ssid=ser5
hw_mode=a
channel=165
country_code=CN
macaddr_acl=0
auth_algs=3
wpa=2
wpa_passphrase=<密码>
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP CCMP
rsn_pairwise=TKIP CCMP
EOF
  • 收获教训:没事别碰 /etc/netplan/00-installer-config.yaml,特别是没显示器和键盘的时候
  • 获取网卡型号和驱动型号,查看支持的信道
1
2
3
sudo ethtool -i wlp2s0
sudo lspci -nn | grep "Network"
iwlist wlp2s0 channel
  • 另外新内核似乎不需要 haveged 来增加熵了
1
2
3
4
5
cat /proc/sys/kernel/random/entropy_avail
systemctl status haveged
apt install haveged
systemctl enable haveged
systemctl start haveged

【记录】Linux 设置个人热点
https://hexo.limour.top/Linux-Setting-AP
Author
Limour
Posted on
March 20, 2024
Updated on
March 20, 2024
Licensed under