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 Authenticator
   Loaded: 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 ago
  Process: 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 server
   Loaded: 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 ago
  Process: 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 server
   Loaded: 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 ago
  Process: 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中换一个端口即可

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/589593.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

39 死锁

目录 1.死锁 2.线程同步 3.条件变量 4.案例 死锁 概念 死锁是指在一组进程中的各个进程均占有不会释放的资源,但因互相申请被其他进程所占用不会释放的资源而处于的一种永久等待状态 四个必要条件 互斥条件:一个资源每次只能被一个执行流使用 请求…

MFC 列表控件修改实例(源码下载)

1、本程序基于前期我的博客文章《MFC下拉菜单打钩图标存取实例(源码下载)》 2、程序功能选中列表控件某一项,修改这一项的按钮由禁止变为可用,双击这个按钮弹出对话框可对这一项的记录数据进行修改,点击确定保存修改数…

SpirngBoot整合快递100

目录 一、注册快递100 二、技术文档地址 三、需要认证的key和comcumer 四、spring boot 整合快递 100使用 4.1 引入快递100和hutool的依赖 4.2 将key和comcumer写入application.properties文件中 4.3 新建一个modle,用于将查出来的json数据转成对象 4.4 新建一个controll…

golang 基础知识细节回顾

之前学习golang的速度过于快,部分内容有点囫囵吞枣的感觉,写gorm过程中有很多违反我常识的地方,我通过复习去修正了我之前认知错误和遗漏的地方。 itoa itoa自增的作用在编辑error code时候作用很大,之前编辑springboot的error c…

python从0开始学习

目录 前言 1、print函数 2、input函数 3、保留字和标识符 总结 前言 本篇文章我们开辟一个新的学习模块:python。python是一个十分简洁实用的编程语言,我们将从0开始学习python 1、print函数 print(*args, sep , end\n, fileNone, flushFalse) pytho…

2024五一数学建模C题煤矿深部开采冲击地压危险预测原创论文分享

大家好,从昨天肝到现在,终于完成了2024五一数学建模竞赛C题的完整论文啦。 实在精力有限,具体的讲解大家可以去讲解视频: 2024五一数学建模C题完整原创论文讲解,手把手保姆级教学!_哔哩哔哩_bilibili 202…

[1678]旅游景点信息Myeclipse开发mysql数据库web结构java编程计算机网页项目

一、源码特点 JSP 旅游景点信息管理系统是一套完善的java web信息管理系统,对理解JSP java编程开发语言有帮助,系统具有完整的源代码和数据库,系统主要采用B/S模式开发。开发环境为TOMCAT7.0,Myeclipse8.5开发,数据库为Mysql…

在idea中连接mysql

IDE(集成开发环境)是一种软件应用程序,它为开发者提供编程语言的开发环境,通常集成了编码、编译、调试和运行程序的多种功能。一个好的IDE可以大幅提高开发效率,尤其是在进行大型项目开发时。IDE通常包括以下几个核心组…

酒水门店私域流量运营搭建执行规划方案

【干货资料持续更新,以防走丢】 酒水门店私域流量运营搭建执行规划方案 部分资料预览 资料部分是网络整理,仅供学习参考。 PPT可编辑(完整资料包含以下内容) 目录 精酿啤酒品牌私域执行运营的内容策划,涉及以下几个…

在做题中学习(48):朴素的二分查找

. - 力扣(LeetCode) 解法一: 暴力求解 for循环中,从nums[0]枚举到nums[n-1],依次判断,返回 target的值。 时间复杂度 : O(N) :因为要遍历一遍数组 解法二:二分查找 因为此数组为有序的…

利用Github发现优质的学习项目网址

1. 直接搜索,star的数量越多的项目质量越高 2.Github Trending 地址: https://github.com/trending 3. Gitstar Ranking 地址: https://gistar-ranking.com/ 4. Awesome Topic 地址: https://github.com/topics/awesome

FIFO Generate IP核使用——Data Counts页详解

在Vivado IDE中,当看到一个用于设置数据计数选项的选项卡时,需要注意的是,尽管某些选项值可能因为当前的配置而显示为灰色(即不可选或已禁用),但IDE中显示的有效范围值实际上是你可以选择的真实值。即使某些…

静态库、动态库回顾

回顾一下库相关的知识点&#xff0c;总结备忘一下。在某种情况下&#xff0c;你有了如下的代码&#xff0c;结构如下 //pra.h #include <stdio.h> void test_01(); //pra.c #include "pra.h" void test_01() {printf("xxxxxxx----->%s %s()\n",…

莫比乌斯变换的数学原理

一、说明 关于莫比乌斯变换&#xff0c;是一个代数几何变换的重要概念。也是双曲几何的重要理论&#xff0c;比如庞加莱盘就是建立在这个理论上&#xff0c;那么这个变换到底有哪些内容&#xff1f;本文将做出详细的解读。 二、线性变换和逆变换 在本节中&#xff0c;我们研…

# notepad++ 编辑器英文版,如何打开自动换行

notepad 编辑器英文版&#xff0c;如何打开自动换行 在Notepad中&#xff0c;如果你想要开启自动换行功能&#xff0c;可以按照以下步骤操作&#xff1a; 1、打开 Notepad 编辑器。 1.1. 依次点击菜单栏中的【视图】&#xff0c;英文版对应【View】。1.2. 在【视图】下拉菜单…

css---浮动知识点精炼汇总

前言 欢迎来到我的博客 个人主页:北岭敲键盘的荒漠猫-CSDN博客 浮动简单理解与介绍 这是我们普通的页面标签效果。 每个标签从上到下依次排列。 浮动顾名思义就是让这个标签飞翔起来。 他飞起来后&#xff0c;后面的标签来到他的位置上。 而浮动的标签就会显示在标签的上面。…

【译】Celery文档1:First Steps with Celery——安装和配置Celery

https://docs.celeryq.dev/en/stable/getting-started/first-steps-with-celery.html#first-steps Celery的第一步 Celery时一个自带电池的任务队列。 本教程内容&#xff1a; 安装消息传输代理(broker)安装Celery并创建第一个任务(task)启动Celery工作进程(worker)并执行任务…

2021-10-21 51单片机两位数码管显示0-99循环

缘由单片机两位数码管显示0-99循环-编程语言-CSDN问答 #include "REG52.h" #include<intrins.h> sbit K1 P3^0; sbit K2 P3^1; sbit K3 P3^2; sbit K4 P3^3; sbit bpP3^4; bit k1,wk10,wk20; unsigned char code SmZiFu[]{63,6,91,79,102,109,125,7,127,1…

Java高阶私房菜:JVM分代收集算法介绍和各垃圾收集器原理分解

目录 什么是分代收集算法 GC的分类和专业术语 什么是垃圾收集器 垃圾收集器的分类及组合 ​编辑 应关注的核心指标 Serial和ParNew收集器原理 Serial收集器 ParNew收集器 Parallel和CMS收集器原理 Parallel 收集器 CMS收集器 新一代垃圾收集器G1和ZGC G1垃圾收集器…

设计模式之MVC模式

在编程江湖闯荡多年&#xff0c;我手中打磨过的设计模式多如繁星&#xff0c;但论及经典与实用&#xff0c; MVC&#xff08;Model-View-Controller&#xff09;模式 绝对是个中翘楚&#xff01;它不仅是Web应用的骨架&#xff0c;更是软件架构的智慧结晶。今天&#xff0c;咱们…
最新文章