2024-09-04 2024-09-04 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 sudo bash #切换root sudo apt install -y hostapd isc-dhcp-server ifupdown # 配置 hostapd sudo nano /etc/hostapd/hostapd.conf interface=wlan0 driver=nl80211 ssid=hostspot-name macaddr_acl=0 auth_algs=1 #auth_algs=3 ignore_broadcast_ssid=0 hw_mode=bgn channel=6 wpa=2 wpa_passphrase=password wpa_key_mgmt=WPA-PSK wpa_pairwise=CCMP #wpa_pairwise=TKIP #rsn_pairwise=CCMP # 修改 hostapd 默认配置文件路径 sudo nano /etc/default/hostapd DAEMON_CONF=/etc/hostapd/hostapd.conf # 重启 hostapd sudo service hostapd restart sudo 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-server INTERFACESv4="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=1 sudo iptables -t nat -A POSTROUTING -s 10.0.0.1/24 -o eth0 -j MASQUERADE sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT #设置开机启动自动设置 sudo iptables-save > /etc/iptables.ipv4.nat cat <<-EOF > /etc/systemd/system/armbian-restore-iptables.service [Unit] Description="Restore IP tables" [Timer] OnBootSec=20Sec [Service] Type=oneshot ExecStart=/sbin/iptables-restore /etc/iptables.ipv4.nat [Install] WantedBy=sysinit.target EOF systemctl enable armbian-restore-iptables.service # 启动 dhcp 服务 systemctl enable isc-dhcp-server systemctl start isc-dhcp-server 参考:https://gitee.com/xiayang0521/rk3399 前一篇 解决windterm莫名其妙输入ctrl+c的问题 后一篇 通过markdown表格批量生成格式化的word教学单元设计表格
说些什么吧!