前言


本文的原文连接是:
https://blog.csdn.net/freewebsys/article/details/126297257

未经博主允许不得转载。
博主地址是:http://blog.csdn.net/freewebsys

1,关于create_ap


使用的设备,这边使用的设备是 intel的AX200 8265/8275 wifi 芯片。

$  lspci | grep -i net
00:1f.6 Ethernet controller: Intel Corporation Ethernet Connection (13) I219-LM (rev 20)
02:00.0 Network controller: Intel Corporation Wireless 8265 / 8275 (rev 78)
04:00.0 Ethernet controller: Intel Corporation I210 Gigabit Network Connection (rev 03)

需要使用到github的一个项目:
https://github.com/oblique/create_ap/

还需要 hostapd 库。一起安装下。需要 make 命令,使用 build-essential 把相关依赖都安装了。

需要安装:

sudo apt install build-essential hostapd
git clone https://github.com/oblique/create_ap
cd create_ap
make install 

安装结果会直接安装到库中:

$ sudo make install
install -Dm755 create_ap /usr/bin/create_ap
install -Dm644 create_ap.conf /etc/create_ap.conf
[ ! -d /lib/systemd/system ] || install -Dm644 create_ap.service /usr/lib/systemd/system/create_ap.service
[ ! -e /sbin/openrc-run ] || install -Dm755 create_ap.openrc /etc/init.d/create_ap
install -Dm644 bash_completion /usr/share/bash-completion/completions/create_ap
install -Dm644 README.md /usr/share/doc/create_ap/README.md

然后就可以查看 create_ap 命令了。

$ create_ap 
Usage: create_ap [options] <wifi-interface> [<interface-with-internet>] [<access-point-name> [<passphrase>]]

Options:
  -h, --help              Show this help
  --version               Print version number
  -c <channel>            Channel number (default: 1)
  -w <WPA version>        Use 1 for WPA, use 2 for WPA2, use 1+2 for both (default: 1+2)
  -n                      Disable Internet sharing (if you use this, don't pass
                          the <interface-with-internet> argument)
  -m <method>             Method for Internet sharing.
                          Use: 'nat' for NAT (default)
                               'bridge' for bridging
                               'none' for no Internet sharing (equivalent to -n)
  --psk                   Use 64 hex digits pre-shared-key instead of passphrase
  --hidden                Make the Access Point hidden (do not broadcast the SSID)
  --mac-filter            Enable MAC address filtering
  --mac-filter-accept     Location of MAC address filter list (defaults to /etc/hostapd/hostapd.accept)
  --redirect-to-localhost If -n is set, redirect every web request to localhost (useful for public information networks)
  --hostapd-debug <level> With level between 1 and 2, passes arguments -d or -dd to hostapd for debugging.
  --isolate-clients       Disable communication between clients
  --ieee80211n            Enable IEEE 802.11n (HT)
  --ieee80211ac           Enable IEEE 802.11ac (VHT)
  --ht_capab <HT>         HT capabilities (default: [HT40+])
  --vht_capab <VHT>       VHT capabilities
  --country <code>        Set two-letter country code for regularity (example: US)
  --freq-band <GHz>       Set frequency band. Valid inputs: 2.4, 5 (default: 2.4)
  --driver                Choose your WiFi adapter driver (default: nl80211)
  --no-virt               Do not create virtual interface
  --no-haveged            Do not run 'haveged' automatically when needed
  --fix-unmanaged         If NetworkManager shows your interface as unmanaged after you
                          close create_ap, then use this option to switch your interface
                          back to managed
  --mac <MAC>             Set MAC address
  --dhcp-dns <IP1[,IP2]>  Set DNS returned by DHCP
  --daemon                Run create_ap in the background
  --pidfile <pidfile>     Save daemon PID to file
  --logfile <logfile>     Save daemon messages to file
  --stop <id>             Send stop command to an already running create_ap. For an <id>
                          you can put the PID of create_ap or the WiFi interface. You can
                          get them with --list-running
  --list-running          Show the create_ap processes that are already running
  --list-clients <id>     List the clients connected to create_ap instance associated with <id>.
                          For an <id> you can put the PID of create_ap or the WiFi interface.
                          If virtual WiFi interface was created, then use that one.
                          You can get them with --list-running
  --mkconfig <conf_file>  Store configs in conf_file
  --config <conf_file>    Load configs from conf_file

Non-Bridging Options:
  --no-dns                Disable dnsmasq DNS server
  --no-dnsmasq            Disable dnsmasq server completely
  -g <gateway>            IPv4 Gateway for the Access Point (default: 192.168.12.1)
  -d                      DNS server will take into account /etc/hosts
  -e <hosts_file>         DNS server will take into account additional hosts file

Useful informations:
  * If you're not using the --no-virt option, then you can create an AP with the same
    interface you are getting your Internet connection.
  * You can pass your SSID and password through pipe or through arguments (see examples).
  * On bridge method if the <interface-with-internet> is not a bridge interface, then
    a bridge interface is created automatically.

Examples:
  create_ap wlan0 eth0 MyAccessPoint MyPassPhrase
  echo -e 'MyAccessPoint\nMyPassPhrase' | create_ap wlan0 eth0
  create_ap wlan0 eth0 MyAccessPoint
  echo 'MyAccessPoint' | create_ap wlan0 eth0
  create_ap wlan0 wlan0 MyAccessPoint MyPassPhrase
  create_ap -n wlan0 MyAccessPoint MyPassPhrase
  create_ap -m bridge wlan0 eth0 MyAccessPoint MyPassPhrase
  create_ap -m bridge wlan0 br0 MyAccessPoint MyPassPhrase
  create_ap --driver rtl871xdrv wlan0 eth0 MyAccessPoint MyPassPhrase
  create_ap --daemon wlan0 eth0 MyAccessPoint MyPassPhrase
  create_ap --stop wlan0

2,使用方法:


需要编写一个脚本就可以,

create-ap.sh

# 加虚拟网络接口并设置网卡地址
sudo iw dev wlp2s0 interface add wlan0 type __ap
sudo ip link set dev wlan0 address aa:bb:cc:dd:11:22

# 使用create_ap开启热点,工具可在获取:
# https://github.com/oblique/create_ap/
sudo create_ap -c 11 wlan0 wlp2s0 wifi-sid password

其中 wlp2s0 是老的上网的wifi地址,使用 ifconfig 查看自己是哪个wifi。

然后看到这样的信息就说明 ap 创建成功了,设备可以链接到创建的wifi当中了。

Config dir: /tmp/create_ap.wlan1.conf.6CUzBekF
PID: 60892
Network Manager found, set ap0 as unmanaged device... DONE
Creating a virtual WiFi interface... ap0 created.
Sharing Internet using method: nat
hostapd command-line interface: hostapd_cli -p /tmp/create_ap.wlan1.conf.6CUzBekF/hostapd_ctrl
WARN: Low entropy detected. We recommend you to install `haveged'
ap0: interface state UNINITIALIZED->ENABLED
ap0: AP-ENABLED 

或者修改配置文件:
配置create_ap, 路径:/etc/create_ap.conf

至少修改这四项,其他的可以不用更改

WIFI_IFACE=wlp2s0 #网卡名称
INTERNET_IFACE=wlan0 #网卡名称
SSID=AP_TEST #热点名称
PASSPHRASE=test123456 #热点密码

3,总结


使用linux 创建wifi 热点,之后可以非常方便的把各种无线设备弄过来,然后做抓包测试,进行研究啥的。
还是不错的技能的。同时在边缘计算上也节约了单独购买一个 wifi 路由器的成本。
还是非常的不错的。

本文的原文连接是:
https://blog.csdn.net/freewebsys/article/details/126297257

博主地址是:https://blog.csdn.net/freewebsys

Logo

更多推荐