2024-09-04 2026-01-25 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980sudo bash#切换rootsudo apt install -y hostapd isc-dhcp-server ifupdown# 配置 hostapdsudo nano /etc/hostapd/hostapd.confinterface=wlan0driver=nl80211ssid=hostspot-namemacaddr_acl=0auth_algs=1#auth_algs=3ignore_broadcast_ssid=0hw_mode=bgnchannel=6wpa=2wpa_passphrase=passwordwpa_key_mgmt=WPA-PSKwpa_pairwise=CCMP#wpa_pairwise=TKIP#rsn_pairwise=CCMP# 修改 hostapd 默认配置文件路径sudo nano /etc/default/hostapdDAEMON_CONF=/etc/hostapd/hostapd.conf# 重启 hostapdsudo service hostapd restartsudo service hostapd status# dhcp 配置sudo nano /etc/dhcp/dhcpd.conf#option domain-name "example.org";#option domain-name-servers ns1.example.org, ns2.example.org;authoritative;subnet 10.0.0.0 netmask 255.255.255.0 { range 10.0.0.10 10.0.0.200; option broadcast-address 10.0.0.255; option routers 10.0.0.1; default-lease-time 600; max-lease-time 7200; option domain-name "local"; option domain-name-servers 223.5.5.5, 8.8.4.4;}# 设置 dhcp 网口# 不进行操作会出现错误:Not configured to listen on any interfaces!sudo nano /etc/default/isc-dhcp-serverINTERFACESv4="wlan0"INTERFACESv6="wlan0"# 设置 wlan0 地址# 不进行操作会出现错误:Not configured to listen on any interfaces!sudo ip addr add 10.0.0.1/24 dev wlan0# 设置开机自动设置mkdir /etc/network/interfaces.d/echo -e "# armbian NAT hostapd\nallow-hotplug wlan0\niface wlan0 inet static\n \taddress 10.0.0.1\n\tnetmask 255.255.255.0\n\tnetwork 10.0.0.0\n\tbroadcast 10.0.0.255" > /etc/network/interfaces.d/armbian.ap.nat# 开启转发sudo sysctl -w net.ipv4.ip_forward=1sudo iptables -t nat -A POSTROUTING -s 10.0.0.1/24 -o eth0 -j MASQUERADEsudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPTsudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT#设置开机启动自动设置sudo iptables-save > /etc/iptables.ipv4.natcat <<-EOF > /etc/systemd/system/armbian-restore-iptables.service[Unit]Description="Restore IP tables"[Timer]OnBootSec=20Sec[Service]Type=oneshotExecStart=/sbin/iptables-restore /etc/iptables.ipv4.nat[Install]WantedBy=sysinit.targetEOFsystemctl enable armbian-restore-iptables.service# 启动 dhcp 服务systemctl enable isc-dhcp-server systemctl start isc-dhcp-server 参考:https://gitee.com/xiayang0521/rk3399 前一篇 通过markdown表格批量生成格式化的word教学单元设计表格 后一篇 解决windterm莫名其妙输入ctrl+c的问题
说些什么吧!