Start Hotspot

  • RK3568 or RK3588

  • Ubuntu, Debian systems

  • Wi-Fi: AP6275S

Other configurations can also be referenced and verified.

Configure AP Mode

Install hostapd

sudo apt install hostapd

Configure hostapd

Create the /etc/hostapd/hostapd.conf file with the following content:

interface=wlan0
driver=nl80211
ssid=neardi_rk3568
hw_mode=a
channel=36
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=12345678
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

Modify /etc/default/hostapd with the following content:

# Defaults for hostapd initscript
#
# WARNING: The DAEMON_CONF setting has been deprecated and will be removed
#          in future package releases.
#
# See /usr/share/doc/hostapd/README.Debian for information about alternative
# methods of managing hostapd.
#
# Uncomment and set DAEMON_CONF to the absolute path of a hostapd configuration
# file and hostapd will be started during system boot. An example configuration
# file can be found at /usr/share/doc/hostapd/examples/hostapd.conf.gz
#
#DAEMON_CONF=""

# Additional daemon options to be appended to hostapd command:-
#       -d   show more debug messages (-dd for even more)
#       -K   include key data in debug messages
#       -t   include timestamps in some debug messages
#
# Note that -B (daemon mode) and -P (pidfile) options are automatically
# configured by the init.d script and must not be added to DAEMON_OPTS.
#
#DAEMON_OPTS=""
DAEMON_CONF="/etc/hostapd/hostapd.conf"

Finally, execute the following commands:

sudo systemctl unmask hostapd
sudo systemctl restart hostapd

Configure DHCP Server

Install DHCP Server

sudo apt install isc-dhcp-server

Configure wlan0

First, set the IPv4 address of wlan0 with the following command:

sudo ifconfig wlan0 192.168.200.1

Then modify /etc/default/isc-dhcp-server with the following content:

# Defaults for isc-dhcp-server (sourced by /etc/init.d/isc-dhcp-server)

# Path to dhcpd's config file (default: /etc/dhcp/dhcpd.conf).
#DHCPDv4_CONF=/etc/dhcp/dhcpd.conf
#DHCPDv6_CONF=/etc/dhcp/dhcpd6.conf

# Path to dhcpd's PID file (default: /var/run/dhcpd.pid).
#DHCPDv4_PID=/var/run/dhcpd.pid
#DHCPDv6_PID=/var/run/dhcpd6.pid

# Additional options to start dhcpd with.
#       Don't use options -cf or -pf here; use DHCPD_CONF/ DHCPD_PID instead
#OPTIONS=""

# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
#       Separate multiple interfaces with spaces, e.g. "eth0 eth1".
INTERFACESv4="wlan0"
INTERFACESv6=""

Next, modify /etc/dhcp/dhcpd.conf with the following content:

# dhcpd.conf                                                         
#                                                                      
# Sample configuration file for ISC dhcpd                             
#                                                                      
                                                                         
# option definitions common to all supported networks...             
option domain-name "example.org";                                      
option domain-name-servers 8.8.8.8;     
                                                       
default-lease-time 600;                      
max-lease-time 7200;                                               
                                      
# The ddns-updates-style parameter controls whether or not the server will

...
...

#shared-network 224-29 {                                             
#  subnet 10.17.224.0 netmask 255.255.255.0 {                          
#    option routers rtr-224.example.org;
#  }                                                   
#  subnet 10.0.29.0 netmask 255.255.255.0 {  
#    option routers rtr-29.example.org;                            
#  }                                  
#  pool {                                                                 
#    allow members of "foo";                                             
#    range 10.17.224.10 10.17.224.250;                             
#  }                                                                  
#  pool {                                                           
#    deny members of "foo";                                         
#    range 10.0.29.10 10.0.29.230;                                      
#  }                                                                  
#}             
                   
subnet 192.168.200.0 netmask 255.255.255.0 {                          
	range 192.168.200.100 192.168.200.200;                  
	option routers 192.168.200.1;           
	option domain-name-servers 8.8.8.8, 8.8.4.4;           
}       

Finally, start the DHCP SERVER with the following command:

sudo systemctl restart isc-dhcp-server

Successful startup:

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.200.1  netmask 255.255.255.0  broadcast 192.168.200.255
        ether 70:f7:54:87:08:76  txqueuelen 1000  (Ethernet)
        RX packets 19895  bytes 4527795 (4.3 MiB)
        RX errors 0  dropped 6  overruns 0  frame 0
        TX packets 196  bytes 16517 (16.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Enable Internet Sharing

Share the network from eth1 via the wlan0 hotspot by following these steps:

# Enable IP forwarding
sudo echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf
# Apply the IP forwarding configuration
sudo sysctl -p
# Masquerade the outgoing packets from eth1 to allow other devices to access the external network via eth1
sudo iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
# Allow incoming packets on eth1 to be forwarded to wlan0 if they are in a RELATED or ESTABLISHED state
sudo iptables -A FORWARD -i eth1 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
# Allow incoming packets on wlan0 to be forwarded to eth1 unconditionally
sudo iptables -A FORWARD -i wlan0 -o eth1 -j ACCEPT