arch创建ap热点

First Post:

Last Update:

Word Count:
562

Read Time:
3 min

首先安装create_ap

1
sudo pacman -S create_ap

使用ip adrr查询网卡

1
ip addr
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
30
31
32
33
34
35
36
37
38
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
3: wlo1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 1a:5b:3d:79:ae:a9 brd ff:ff:ff:ff:ff:ff permaddr ac:67:5d:56:3d:1c
altname wlp0s20f3
4: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
link/ether 02:42:80:ed:05:ab brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
valid_lft forever preferred_lft forever
inet6 fe80::42:80ff:feed:5ab/64 scope link proto kernel_ll
valid_lft forever preferred_lft forever
6: veth1c27a56@if5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP group de
fault
link/ether ce:94:2a:2d:bd:83 brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet6 fe80::cc94:2aff:fe2d:bd83/64 scope link proto kernel_ll
valid_lft forever preferred_lft forever
7: utun: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 9000 qdisc mq state UNKNOWN group default qlen 500
link/none
inet 198.18.0.1/16 scope global utun
valid_lft forever preferred_lft forever
inet6 fe80::86d:2369:2a6e:9c5b/64 scope link stable-privacy proto kernel_ll
valid_lft forever preferred_lft forever
10: enp0s20f0u6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:e0:4c:36:85:7b brd ff:ff:ff:ff:ff:ff
inet 192.168.1.51/24 brd 192.168.1.255 scope global dynamic noprefixroute enp0s20f0u6
valid_lft 13079sec preferred_lft 13079sec
inet6 fe80::4ea7:6c93:4d72:8bd3/64 scope link noprefixroute
valid_lft forever preferred_lft forever
11: ap0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether ac:67:5d:56:3d:1d brd ff:ff:ff:ff:ff:ff
inet 192.168.12.1/24 brd 192.168.12.255 scope global ap0
valid_lft forever preferred_lft forever
inet6 fe80::ae67:5dff:fe56:3d1d/64 scope link proto kernel_ll
valid_lft forever preferred_lft forever

wlo1为无线网卡,enp0s20f0u6为有线网卡

创建热点

有线网卡创建

1
sudo create_ap wlo1 enp0s20f0u1 wifiname wifipwd

无线网卡创建

1
sudo create_ap wlo1 wlo1 wifiname wifipwd

wifiname:热点名称

wifipwd:热点密码(如果不需要密码可以不加)

ps:

写了个脚本开热点,但是有点bug

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash
wifiname=$1
wifipwd=$2
para=$(cat /proc/net/dev | awk '{i++; if(i>2){print $1}}' | sed 's/^[\t]*//g' | sed 's/[:]*$//g')
wifi=$(echo $*"$para")
wol=""
enp=""
for i in $wifi
do
if [[ $i =~ ^[w]\w* ]];
then
wol=$i
elif [[ $i =~ ^[e]\w* ]];
then
enp=$i
fi
done
if [[ $# -gt 0 && $# -le 2 ]]
then
create_ap $wol $enp $wifiname $wifipwd
fi