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

相关文章

Java设计模式---迭代器模式(Iterator)解读

《Java设计模式---迭代器模式(Iterator)解读》:本文主要介绍Java设计模式---迭代器模式(Iterator),具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,... 目录1、迭代器(Iterator)1.1、结构1.2、常用方法1.3、本质1、解耦集合与遍历逻辑2、统一

Java 线程安全与 volatile与单例模式问题及解决方案

《Java线程安全与volatile与单例模式问题及解决方案》文章主要讲解线程安全问题的五个成因(调度随机、变量修改、非原子操作、内存可见性、指令重排序)及解决方案,强调使用volatile关键字... 目录什么是线程安全线程安全问题的产生与解决方案线程的调度是随机的多个线程对同一个变量进行修改线程的修改操

Linux中SSH服务配置的全面指南

《Linux中SSH服务配置的全面指南》作为网络安全工程师,SSH(SecureShell)服务的安全配置是我们日常工作中不可忽视的重要环节,本文将从基础配置到高级安全加固,全面解析SSH服务的各项参... 目录概述基础配置详解端口与监听设置主机密钥配置认证机制强化禁用密码认证禁止root直接登录实现双因素

嵌入式数据库SQLite 3配置使用讲解

《嵌入式数据库SQLite3配置使用讲解》本文强调嵌入式项目中SQLite3数据库的重要性,因其零配置、轻量级、跨平台及事务处理特性,可保障数据溯源与责任明确,详细讲解安装配置、基础语法及SQLit... 目录0、惨痛教训1、SQLite3环境配置(1)、下载安装SQLite库(2)、解压下载的文件(3)、

Linux如何快速检查服务器的硬件配置和性能指标

《Linux如何快速检查服务器的硬件配置和性能指标》在运维和开发工作中,我们经常需要快速检查Linux服务器的硬件配置和性能指标,本文将以CentOS为例,介绍如何通过命令行快速获取这些关键信息,... 目录引言一、查询CPU核心数编程(几C?)1. 使用 nproc(最简单)2. 使用 lscpu(详细信

Nginx 重写与重定向配置方法

《Nginx重写与重定向配置方法》Nginx重写与重定向区别:重写修改路径(客户端无感知),重定向跳转新URL(客户端感知),try_files检查文件/目录存在性,return301直接返回永久重... 目录一.try_files指令二.return指令三.rewrite指令区分重写与重定向重写: 请求

Nginx 配置跨域的实现及常见问题解决

《Nginx配置跨域的实现及常见问题解决》本文主要介绍了Nginx配置跨域的实现及常见问题解决,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来... 目录1. 跨域1.1 同源策略1.2 跨域资源共享(CORS)2. Nginx 配置跨域的场景2.1

gitlab安装及邮箱配置和常用使用方式

《gitlab安装及邮箱配置和常用使用方式》:本文主要介绍gitlab安装及邮箱配置和常用使用方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录1.安装GitLab2.配置GitLab邮件服务3.GitLab的账号注册邮箱验证及其分组4.gitlab分支和标签的

MySQL MCP 服务器安装配置最佳实践

《MySQLMCP服务器安装配置最佳实践》本文介绍MySQLMCP服务器的安装配置方法,本文结合实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下... 目录mysql MCP 服务器安装配置指南简介功能特点安装方法数据库配置使用MCP Inspector进行调试开发指

Redis Cluster模式配置

《RedisCluster模式配置》:本文主要介绍RedisCluster模式配置,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧... 目录分片 一、分片的本质与核心价值二、分片实现方案对比 ‌三、分片算法详解1. ‌范围分片(顺序分片)‌2. ‌哈希分片3. ‌虚