Introduction
In this article, we will guide you through the process of setting up a hotspot with proxy support using Ubuntu 24.04. We assume that you have a basic understanding of the Linux operating system and networking concepts. We will be using the following interfaces: ethernet (ens144fd7c333e3) and wifi (wlp1s0). Additionally, we have a shadow-socks (socks5) proxy server running on localhost (127.0.0.1).
Prerequisites
- Ubuntu 24.04 installed
- Internet connection via ethernet or wifi
- Shadow-socks (socks5) proxy server installed and running
Setting up the Hotspot
Step 1: Install Hostapd
Hostapd is a Linux IEEE 802.11 access point and authenticator. We will use it to create and manage our hotspot. Install it using the following command:
sudo apt-get update
sudo apt-get install hostapd
Step 2: Configure Hostapd
Create a new file called wpa_supplicant.conf in the /etc/wpa_supplicant directory with the following content:
country=US
network={
ssid="YourHotspotName"
psk="YourHotspotPassword"
key_mgmt=WPA-PSK
}
Create another file called hostapd.conf in the /etc/hostapd directory with the following content:
interface=wlp1s0
driver=nl80211
ssid=YourHotspotName
wpa_passphrase=YourHotspotPassword
wpa_key_mgmt=WPA-PSK
wpa_psk=YourHotspotPassword
Replace "YourHotspotName" and "YourHotspotPassword" with your desired hotspot name and password. Save and close both files.
Step 3: Start Hostapd
Start the hostapd service using the following command:
sudo systemctl start hostapd
To ensure that the service starts automatically on boot, use:
sudo systemctl enable hostapd
Setting up the Proxy
Step 1: Install iptables
Iptables is a user-space utility program that allows you to configure the Linux kernel firewall. We will use it to forward traffic through the proxy. Install it using the following command:
sudo apt-get install iptables
Step 2: Configure iptables
Add the following rules to the iptables-forwarding.conf file:
# Allow traffic to the proxy server
iptables -A INPUT -p tcp --dport 1080 -j ACCEPT
# Allow traffic from the hotspot to the proxy server
iptables -A FORWARD -i wlp1s0 -o ens144fd7c333e3 -p tcp --dport 1080 -j ACCEPT
# Allow traffic from the proxy server to the hotspot
iptables -A FORWARD -i ens144fd7c333e3 -o wlp1s0 -p tcp --dport 80 -j ACCEPT
# Allow traffic from the proxy server to the internet
iptables -A FORWARD -i ens144fd7c333e3 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
# Allow traffic from the internet to the proxy server
iptables -A INPUT -i ens144fd7c333e3 -p tcp --dport 80 -j ACCEPT
# Allow traffic from the internet to the hotspot
iptables -A FORWARD -i eth0 -o wlp1s0 -m state --state ESTABLISHED,RELATED -j ACCEPT
Save and close the file. Apply the rules using:
sudo iptables-save > /etc/iptables/rules.v4
In this article, we have shown you how to set up a hotspot with proxy support using Ubuntu 24.04. We used the hostapd package to create and manage the hotspot, and iptables to forward traffic through the proxy server. This setup allows devices connected to the hotspot to access the internet via the proxy server.