ubuntu外置网卡配置AP模式

2024-05-03 07:52

本文主要是介绍ubuntu外置网卡配置AP模式,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

外置网卡RTL8811CU设置

UBUNTU使用RTL8811CU网卡(包含树莓派)

外置网卡配置AP模式流程

1. 检查网卡支持情况(是否支持AP模式)

iw list

在这里插入图片描述
找到以上部分,发现支持AP

2. 安装依赖

sudo apt-get update
sudo apt-get install hostapd dnsmasq 

3. 配置hostapd

创建和编辑hostapd配置文件

sudo gedit /etc/hostapd/hostapd.conf

更改配置文件如下,其中interface是ifconfig确定的模式,driver后面的驱动是固定的,不因为外置网卡下载不同驱动而改变

interface=wlx90de803014a8 #interface 参数定义了无线接口的名称
driver=nl80211  #driver 参数定义了使用的驱动程序,固定,不因为外置网卡设备名而改变
ssid=WL1             #wifi名称
channel=6           #channel 参数定义了网络所在的频道
auth_algs=1       #auth_algs 参数定义了用于身份验证的算法
hw_mode=g       #hw_mode 参数定义了硬件模式
ignore_broadcast_ssid=0   #ignore_broadcast_ssid 参数决定是否忽略广播的 SSID
wpa=3
wpa_passphrase=123456789    #密码
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP#wpa 参数定义了是否使用 WPA 加密
#wpa_passphrase 参数定义了 WPA 的密码
#wpa_key_mgmt 参数定义了 WPA 的密钥管理方式
#wpa_pairwise 参数定义了 WPA 的对等加密方式
#rsn_pairwise 参数定义了 RSN 的对等加密方式

查看无线接口名称如下,插拔外置网卡判断具体是哪个

ifconfig

在这里插入图片描述

4. 配置hostapd配置文件
编辑/etc/default/hostapd文件

sudo gedit /etc/default/hostapd

找到DAEMON_CONF=""这一行,并替换为

DAEMON_CONF="/etc/hostapd/hostapd.conf"

5. 配置dnsmasq

sudo gedit /etc/dnsmasq.conf

文件末尾加入

interface=wlan0
dhcp-range=192.168.10.2,192.168.10.20,255.255.255.0,24h
port=5353

6. 配置网络接口

sudo gedit /etc/network/interfaces

添加以下配置

auto wlx90de803014a8
iface wlx90de803014a8 inet static
address 192.168.10.1
netmask 255.255.255.0

7. 重启服务

sudo systemctl restart hostapd
sudo systemctl restart dnsmasq

报错处理

sudo systemctl restart hostapd出现以下报错:

Job for dnsmasq.service failed because the control process exited with error code.
See "systemctl status dnsmasq.service" and "journalctl -xe" for detail

可以通过sudo systemctl status hostapd这个命令来查看具体错误原因

● hostapd.service - Advanced IEEE 802.11 AP and IEEE 802.1X/WPA/WPA2/EAP AuthenticatorLoaded: loaded (/lib/systemd/system/hostapd.service; disabled; vendor preset: enabled)Active: failed (Result: exit-code) since Tue 2024-04-30 16:42:09 CST; 3s agoProcess: 15958 ExecStart=/usr/sbin/hostapd -P /run/hostapd.pid -B $DAEMON_OPTS ${DAEMON_CONF} (code=exited, status=1/FAILURE)430 16:42:09 pc-NUC11TNKi7 systemd[1]: Starting Advanced IEEE 802.11 AP and IEEE 802.1X/WPA/WPA2/EAP Authenticator...
430 16:42:09 pc-NUC11TNKi7 hostapd[15958]: Configuration file: /etc/hostapd/hostapd.conf
430 16:42:09 pc-NUC11TNKi7 hostapd[15958]: Line 2: invalid/unknown driver 'rtl8821cu'
430 16:42:09 pc-NUC11TNKi7 hostapd[15958]: 1 errors found in configuration file '/etc/hostapd/hostapd.conf'
430 16:42:09 pc-NUC11TNKi7 hostapd[15958]: Failed to set up interface with /etc/hostapd/hostapd.conf
430 16:42:09 pc-NUC11TNKi7 hostapd[15958]: Failed to initialize interface
430 16:42:09 pc-NUC11TNKi7 systemd[1]: hostapd.service: Control process exited, code=exited status=1
430 16:42:09 pc-NUC11TNKi7 systemd[1]: hostapd.service: Failed with result 'exit-code'.
430 16:42:09 pc-NUC11TNKi7 systemd[1]: Failed to start Advanced IEEE 802.11 AP and IEEE 802.1X/WPA/WPA2/EAP Authenticator.
pc@pc-NUC11TNKi7:~$ 

以上报错是因为驱动使用了错误的rtl8821cu,修改驱动即可

sudo systemctl restart dnsmasq同样出现报错

Job for dnsmasq.service failed because the control process exited with error code.
See "systemctl status dnsmasq.service" and "journalctl -xe" for details.

同样通过这个查看报错信息sudo systemctl status dnsmasq.service

● dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS serverLoaded: loaded (/lib/systemd/system/dnsmasq.service; enabled; vendor preset: enabled)Active: failed (Result: exit-code) since Tue 2024-04-30 16:46:19 CST; 1min 36s agoProcess: 16137 ExecStart=/etc/init.d/dnsmasq systemd-exec (code=exited, status=1/FAILURE)Process: 16136 ExecStartPre=/usr/sbin/dnsmasq --test (code=exited, status=0/SUCCESS)430 16:46:19 pc-NUC11TNKi7 systemd[1]: Starting dnsmasq - A lightweight DHCP and caching DNS server...
430 16:46:19 pc-NUC11TNKi7 dnsmasq[16136]: dnsmasq: syntax check OK.
430 16:46:19 pc-NUC11TNKi7 dnsmasq[16137]: dnsmasq: bad option at line 2 of /etc/dnsmasq.d/wlan0-ap.conf.save
430 16:46:19 pc-NUC11TNKi7 dnsmasq[16137]: bad option at line 2 of /etc/dnsmasq.d/wlan0-ap.conf.save
430 16:46:19 pc-NUC11TNKi7 systemd[1]: dnsmasq.service: Control process exited, code=exited status=1
430 16:46:19 pc-NUC11TNKi7 dnsmasq[16137]: 启动失败
430 16:46:19 pc-NUC11TNKi7 systemd[1]: dnsmasq.service: Failed with result 'exit-code'.
430 16:46:19 pc-NUC11TNKi7 systemd[1]: Failed to start dnsmasq - A lightweight DHCP and caching DNS server.

以上报错是因为在/etc/dnsmasq.d/wlan0-ap.conf.save这个文件的第二行出现错误字符

● dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS serverLoaded: loaded (/lib/systemd/system/dnsmasq.service; enabled; vendor preset: enabled)Active: failed (Result: exit-code) since Thu 2024-05-02 11:59:37 CST; 13s agoProcess: 5591 ExecStart=/etc/init.d/dnsmasq systemd-exec (code=exited, status=2)Process: 5590 ExecStartPre=/usr/sbin/dnsmasq --test (code=exited, status=0/SUCCESS)5月 02 11:59:37 pc-NUC11TNKi7 systemd[1]: Starting dnsmasq - A lightweight DHCP and caching DNS server...
5月 02 11:59:37 pc-NUC11TNKi7 dnsmasq[5590]: dnsmasq: syntax check OK.
5月 02 11:59:37 pc-NUC11TNKi7 dnsmasq[5591]: dnsmasq: failed to create listening socket for port 53: 地址已在使用
5月 02 11:59:37 pc-NUC11TNKi7 dnsmasq[5591]: failed to create listening socket for port 53: 地址已在使用
5月 02 11:59:37 pc-NUC11TNKi7 dnsmasq[5591]: 启动失败
5月 02 11:59:37 pc-NUC11TNKi7 systemd[1]: dnsmasq.service: Control process exited, code=exited status=2
5月 02 11:59:37 pc-NUC11TNKi7 systemd[1]: dnsmasq.service: Failed with result 'exit-code'.
5月 02 11:59:37 pc-NUC11TNKi7 systemd[1]: Failed to start dnsmasq - A lightweight DHCP and caching DNS server

以上报错是因为端口53被同时占用,在 /etc/dnsmasq.conf中换一个端口即可

这篇关于ubuntu外置网卡配置AP模式的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/956214

相关文章

SpringBoot3.4配置校验新特性的用法详解

《SpringBoot3.4配置校验新特性的用法详解》SpringBoot3.4对配置校验支持进行了全面升级,这篇文章为大家详细介绍了一下它们的具体使用,文中的示例代码讲解详细,感兴趣的小伙伴可以参考... 目录基本用法示例定义配置类配置 application.yml注入使用嵌套对象与集合元素深度校验开发

IntelliJ IDEA 中配置 Spring MVC 环境的详细步骤及问题解决

《IntelliJIDEA中配置SpringMVC环境的详细步骤及问题解决》:本文主要介绍IntelliJIDEA中配置SpringMVC环境的详细步骤及问题解决,本文分步骤结合实例给大... 目录步骤 1:创建 Maven Web 项目步骤 2:添加 Spring MVC 依赖1、保存后执行2、将新的依赖

SpringBoot基于配置实现短信服务策略的动态切换

《SpringBoot基于配置实现短信服务策略的动态切换》这篇文章主要为大家详细介绍了SpringBoot在接入多个短信服务商(如阿里云、腾讯云、华为云)后,如何根据配置或环境切换使用不同的服务商,需... 目录目标功能示例配置(application.yml)配置类绑定短信发送策略接口示例:阿里云 & 腾

如何为Yarn配置国内源的详细教程

《如何为Yarn配置国内源的详细教程》在使用Yarn进行项目开发时,由于网络原因,直接使用官方源可能会导致下载速度慢或连接失败,配置国内源可以显著提高包的下载速度和稳定性,本文将详细介绍如何为Yarn... 目录一、查询当前使用的镜像源二、设置国内源1. 设置为淘宝镜像源2. 设置为其他国内源三、还原为官方

Nginx location匹配模式与规则详解

《Nginxlocation匹配模式与规则详解》:本文主要介绍Nginxlocation匹配模式与规则,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、环境二、匹配模式1. 精准模式2. 前缀模式(不继续匹配正则)3. 前缀模式(继续匹配正则)4. 正则模式(大

CentOS7更改默认SSH端口与配置指南

《CentOS7更改默认SSH端口与配置指南》SSH是Linux服务器远程管理的核心工具,其默认监听端口为22,由于端口22众所周知,这也使得服务器容易受到自动化扫描和暴力破解攻击,本文将系统性地介绍... 目录引言为什么要更改 SSH 默认端口?步骤详解:如何更改 Centos 7 的 SSH 默认端口1

Maven的使用和配置国内源的保姆级教程

《Maven的使用和配置国内源的保姆级教程》Maven是⼀个项目管理工具,基于POM(ProjectObjectModel,项目对象模型)的概念,Maven可以通过一小段描述信息来管理项目的构建,报告... 目录1. 什么是Maven?2.创建⼀个Maven项目3.Maven 核心功能4.使用Maven H

SpringBoot多数据源配置完整指南

《SpringBoot多数据源配置完整指南》在复杂的企业应用中,经常需要连接多个数据库,SpringBoot提供了灵活的多数据源配置方式,以下是详细的实现方案,需要的朋友可以参考下... 目录一、基础多数据源配置1. 添加依赖2. 配置多个数据源3. 配置数据源Bean二、JPA多数据源配置1. 配置主数据

Spring 基于XML配置 bean管理 Bean-IOC的方法

《Spring基于XML配置bean管理Bean-IOC的方法》:本文主要介绍Spring基于XML配置bean管理Bean-IOC的方法,本文给大家介绍的非常详细,对大家的学习或工作具有一... 目录一. spring学习的核心内容二. 基于 XML 配置 bean1. 通过类型来获取 bean2. 通过

如何使用Nginx配置将80端口重定向到443端口

《如何使用Nginx配置将80端口重定向到443端口》这篇文章主要为大家详细介绍了如何将Nginx配置为将HTTP(80端口)请求重定向到HTTPS(443端口),文中的示例代码讲解详细,有需要的小伙... 目录1. 创建或编辑Nginx配置文件2. 配置HTTP重定向到HTTPS3. 配置HTTPS服务器