当前位置: 首页 > article >正文

RK3588配置成为路由器

文章目录

  • 前言
  • 一、配置netplan
  • 二、安装hostapd
    • 1.创建hostapd.conf文件
    • 2.安装软件
    • 3.修改启动文件
    • 4.修改/etc/default/hostapd 文件
  • 三、安装dnsmasq服务
  • 四、配置NET及重启验证
  • 五、常见问题
  • 总结


前言

RK3588开发板有两个网口,一个无线网卡。我需要配置为家用路由器模式,以方便后面做一些细致的开发。


一、配置netplan

#在/etc/netplan/ 下创建文件01-netcfg-init.yaml,并写入下面配置,然后执行netplan apply
network:
        version: 2
        renderer: NetworkManager
        ethernets:
                eth0:
                        dhcp4: yes
                eth1:
                        dhcp4: no
        bridges:
                br-lan:
                        interfaces: [eth1]
                        dhcp4: no
                        addresses: [192.168.4.1/24]

二、安装hostapd

1.创建hostapd.conf文件

文件/etc/hostapd.conf 内容如下

country_code=CN
interface=wlan0
bridge=br-lan
ssid=rk3588_ap
hw_mode=g
channel=11
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=zhongrui123
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

● country_code:国家码,中国使用CN
● interface:开启无线AP热点的无线网卡
● bridge:绑定到br-lan网桥,使得无线AP热点和以太网口在同一个局域网内
● hw_mode:设置无线模式
● channel:信道
● ssid:无线AP名称,这里设置rk3588_ap
● wpa_passphrase:无线AP密码,这里设置为zhongrui123

2.安装软件

指令如下:

apt install hostapd
systemctl unmask hostapd    #设置允许开机自启动
systemctl enable hostapd      #设置开机自启动
systemctl start hostapd   #启动指令 这一步放到修改完所有文件后启用

#这两步指令以防万一
cd /etc/hostapd/
ln -s ../hostapd.conf  .

3.修改启动文件

修改/etc/systemd/system/multi-user.target.wants/hostapd.service文件内容为下图所示
(这边加个延长是因为无线网卡没启动呢,这个程序启动了)

在这里插入图片描述

4.修改/etc/default/hostapd 文件

#增加下面内容
DAEMON_CONF="/etc/hostapd.conf"

三、安装dnsmasq服务

安装

apt update
apt install -y dnsmasq  #安装dhcp和dns服务端

修改配置文件

#修改/etc/dnsmasq.conf配置文件
# 下发网关为网桥的 ip
dhcp-option=option:router,192.168.4.1

# 下发的 dns 服务地址
dhcp-option=option:dns-server,114.114.114.114

# 分配 ip 范围 子网掩码 租期
dhcp-range=192.168.4.2,192.168.4.254,255.255.255.0,12h

# dns 服务端口
port=0

#监听的网卡
interface=br-lan
listen-address=192.168.4.1

# 严格按照 resolv-file 文件中的顺序从上到下进行 DNS 解析
strict-order

修改DNS解析文件

#配置上级 dns 服务器,打开 /etc/resolv.conf

nameserver 114.114.114.114
nameserver 8.8.8.8

配置开机启动

systemctl unmask dnsmasq 
systemctl enable dnsmasq 
systemctl start dnsmasq

四、配置NET及重启验证

打开 /etc/sysctl.conf, 在文件的最后加入
net.ipv4.ip_forward=1
执行sysctl -p 生效

#重启设备
reboot -f

#该命令执行内网地址转换外网地址的步骤,完成访问 注意这个是临时的,重启之后执行看效果
执行 iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

五、常见问题

配置软件后

查看服务是否启动
ps -ef |grep xxxx 
查看启动日志
 systemctl status xxxx
查看所有日志
journalctl -u xxx 
查看最新日志
journalctl -u xxx  -f

查看无线网卡情况

iwconfig wlan0(根据你的来定)

有网桥无IP

配置文件不要写错

总结

有问题评论区交流,目前看这个方法稳定


http://www.kler.cn/a/555198.html

相关文章:

  • 网络初始2:网络编程--基于UDP和TCP实现回显器
  • Python中常见库 PyTorch和Pydantic 讲解
  • [Linux]——进程控制(中)
  • SpringSecurity基于配置方法控制访问权限:MVC匹配器、Ant匹配器
  • 【git】提交修改、回撤、回滚、Tag 操作讲解,与reset (--soft、--mixed、--hard) 的区别
  • ArkTS与ArkUI深度解析:鸿蒙应用开发的未来之路
  • Aseprite绘画流程案例(1)——画相机图标
  • Linux-C/C++《C++/1、C++基础》(C++语言特性、面向对象等)
  • 哈希表模拟封装unordered_map和unordered_set
  • 嵌入式 Linux 设备树中的标准属性详解
  • VIE(可变利益实体)架构通俗解析 —— 以阿里巴巴为例(中英双语)
  • 51单片机学习——静态数码管显示
  • 深度学习模型应用场景全解析:CNN、Transformer、BERT、RNN与GAN
  • 在大语言模型(LLM)中调用(Function Calling) 自定义的结构化函数
  • oppo,汤臣倍健,康冠科技25届春招内推
  • Android init阶段loop回环设备的使用
  • 如何清理cache-loader生成的缓存目录?
  • 【时时三省】(C语言基础)用N-S流程图表示算法
  • 上位机知识篇---setuptools
  • 基于Linux平台的多实例RTSP|RTMP直播播放器深度解析与技术实现