0

I'm having trouble setting up my computer (running Ubuntu 18.04) as a hotspot with a manually fixed IP. I want devices to be able to connect to it via WiFi, and for them to be able to access my website hosted on the computer on port 80.

So I wanted to set the fixed IP of my computer as 192.168.10.1, so I set up the hotspot as such:

INTERFACE=wlan0 # My wifi card interface
CONNECTION_NAME=testhotspot
MY_IP="192.168.10.1"

sudo nmcli con add type wifi ifname $INTERFACE con-name $CONNECTION_NAME autoconnect yes ssid $CONNECTION_NAME
sudo nmcli con modify $CONNECTION_NAME 802-11-wireless.mode ap ipv4.method manual ipv4.addresses $MY_IP/24 ipv4.gateway $MY_IP
sudo nmcli con modify $CONNECTION_NAME wifi-sec.key-mgmt wpa-psk 
sudo nmcli con modify $CONNECTION_NAME wifi-sec.psk "somepassword"
# do I need to set ipv4.dns?

I then set up dnsmasq (in /etc/dnsmasq) as:

address=/#/127.0.0.1
interface=wlan0
except-interface=lo
listen-address=::1,127.0.0.1,192.168.10.1

# DHCP setup
dhcp-range=192.168.10.100,192.168.10.200,12h # lease out 192.168.10.100-200
dhcp-option=option:router,192.168.10.1
dhcp-option=option:dns-server,192.168.10.1
dhcp-option=option:netmask,255.255.255.0
dhcp-leasefile=/var/lib/misc/dnsmasq.leases
dhcp-authoritative

Startup dnsmasq and the hotspot:

sudo nmcli con up testhotspot
sudo systemctl restart dnsmasq.service

With this setup, I found that connecting to the wifi hotspot on another computer running Ubuntu (let's call this computer B), I could successfully ping 192.168.1.10 and access my website on 192.168.10.1:80.

However, I had issues trying to connect to it using an Android phone, with the connection continuously dropping. I had to change my Android wifi settings to "Static" instead of "DHCP", and specify the DNS to 192.168.10.1 for me to successfully ping 192.168.10.1. Thus, I guessed that I hadn't "announced" to clients properly about my DNS/DHCP server? I tried changing my hotspot settings as nmcli con modify testhotspot ipv4.dns 192.168.10.1. However, this did not solve the issue on my Android device (It stopped dropping the wifi connection, but I still could not ping 192.168.10.1?).

I also noticed that on computer B, while connected to both the wifi of my hotspot server, and an internet-providing router, some public websites (such as this askubuntu site) could not be reached until I turned off the wifi connection to the hotspot server. What did I do wrong in the setup above?

0

1 Answer 1

0

I figured out my mistake - I don't actually need a DNS, so I switched over to use isc-dhcp-server with dhcpd.conf as

default-lease-time 600;
max-lease-time 7200;
authoritative;
 
subnet 192.168.10.0 netmask 255.255.255.0 {
 range 192.168.10.100 192.168.10.200;
 option routers 192.168.10.1;
}

and the interface set in /etc/default/isc-dhcp-server.

Edit: I decided to go back to using dnsmasq - this dnsmasq.conf works for me:

no-resolv
bind-interfaces
interface=wlan0 # My hotspot interface
listen-address=192.168.10.1

dhcp-range=192.168.10.100,192.168.10.200,255.255.255.0,12h
dhcp-option=option:router,192.168.10.1
dhcp-leasefile=/var/lib/misc/dnsmasq.leases
dhcp-authoritative

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .