I'm running this project for creating access points which is built on top of hostapd.

Running this works as expected, my ethernet connection is available as wifi:

sudo create_ap wlan0 eth0 wifiname

I was hoping that port 80 on my host machine would automatically be exposed to the client but it isn't.

How can I create a hostapd hotspot that exposes port 80? I'm thinking I might need to use iptables or dnsmasq but I'm not sure.

I'm using the project linked as a starting point but my main goal is to broadcast a port over a wifi-hot spot.

Update: I found that by default the host is available at IP I'm now looking for a way to forward all (or at minimum localhost) traffic on the hotspot to this IP.

But I still need to be able to resolve other domains on the host itself.

  • 1
    You must bind the port to appropriate device (presumably wlan0). If you need it open on eth0 too - iptables / nftables is your answer. – NarūnasK Oct 20 '17 at 13:39
  • I just tried your script and it worked fine. I created hotspot on my laptop and connected my phone to it. Started a server on 443. In phone, opening worked as expected. – Arpit Agarwal Oct 28 '17 at 19:43

You cannot do that via hostapd because port 80 is at Layer4 of ISO/OSI stack, APs work at Layer2. So you need to identify your IP connected via WIFI and work with IPTABLES for that IP


I was able to get the behavior I wanted using dnsmasq. Originally I was confused because I was adding the following to the default dnsmasq.conf location:


It should forward all traffic to the IP but I found it wasn't working.

Later on while running top with the program running I found that create_ap had called dnsmasq but with a custom dnsmasq.conf in a /tmp/ folder.

Reading through the source I found this snippet:

    MTU=$(get_mtu $INTERNET_IFACE)
    [[ -n "$MTU" ]] && echo "dhcp-option-force=option:mtu,${MTU}" >> $CONFDIR/dnsmasq.conf
    [[ $ETC_HOSTS -eq 0 ]] && echo no-hosts >> $CONFDIR/dnsmasq.conf
    [[ -n "$ADDN_HOSTS" ]] && echo "addn-hosts=${ADDN_HOSTS}" >> $CONFDIR/dnsmasq.conf
    if [[ "$SHARE_METHOD" == "none" && "$REDIRECT_TO_LOCALHOST" == "1" ]]; then
        cat << EOF >> $CONFDIR/dnsmasq.conf

Inside that statement I added the following line to add my configuration to the temporary dnsmasq file:

echo "address=/#/${GATEWAY}" >> $CONFDIR/dnsmasq.conf

After adding that any http address on the AP was forwarding to the browser automatically assumes port 80 when one isn't provided so that became a non-issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.