A server has two WiFi interfaces, both configured via Network Manager to be hotspots.

Connected clients get IPs in ranges and (AFAICS via dnsmasq invoked by NM). I need to be able to assign a specific range to a specific interface. Unfortunately, Network Manager assigns them unpredictably (so wlan0 may get today and tomorrow; then wlan1 gets the remaining range) which messes up my iptables because the routing rules are different for these interfaces.

I tried dhcp-range= option in /etc/dnsmasq.conf (which wasn't present as NM configures dnsmasq via command line) and some other ideas but can't find a workable solution.

Any thoughts on how I can control which IP range gets assigned to which interface?

  • Why didn't dhcp-range not work? Just ignored your settings? – user508889 Nov 3 '16 at 0:51
  • I used "dhcp-range=wlan0,,,72h" in dnsmasq.conf (and similar for wlan1). That did not have any effect. I presume Network Manager runs dnsmasq via cmd-line which takes precedence. – David Radu Nov 3 '16 at 11:01
  • Also tried placing dnsmasq.conf in /etc and in /etc/NetworkManager/dnsmasq.d but DHCP ranges are still assigned unpredictably. Forgot to mention that it is 16.04.1 LTS. – David Radu Nov 3 '16 at 13:07
  • Have you tried /etc/NetworkManager/dnsmasq.d/local and then sudo restart network-manager. – user508889 Nov 3 '16 at 13:55
  • yes (to no avail) – David Radu Nov 3 '16 at 15:28

You can determine the used IPv4 subnet by configuring one manual address, like

nmcli connection modify $SHARED_NAME ipv4.addresses

It's documented in man nm-settings, see ipv4.method.

/etc/NetworkManager/dnsmasq.d is for using dnsmasq as DNS plugin, not for your use case of connection sharing. For that, it is instead /etc/NetworkManager/dnsmasq-shared.d -- at least in recent versions of NM. But you shouldn't need that.

  • That doesn't seem to work. AFAICS setting an IP is incompatible with ipv4.method shared: NM fails to set the gateway and DNS properly in this situation. And manual control is impossible - nmcli refuses to accept ipv4.dns in ipv4.method shared mode. (I am pretty sure I tried that before by directly modifying address1= in NetworkManager/system-connections - the result was the same: IPs could be set but gateway/DNS were not.) Any ideas? – David Radu Nov 4 '16 at 12:25
  • Manual link confirms this: Addresses cannot be used with the 'shared', 'link-local', or 'disabled' methods as addressing is either automatic or disabled and If shared is specified ... the interface is assigned an address in the 10.42.x.1/24 range.... – David Radu Nov 4 '16 at 12:39
  • True, trusty has, which is very old by now. Works since 0.9.10, as also documented in recent manual. I don't understand why you talk about ipv4.dns, do you mean ipv4.addresses? – thaller Nov 4 '16 at 13:18
  • I tried to set DNS via ipv4.dns because nmcli connection modify $SHARED_NAME ipv4.addresses leaves all clients connected to the hotspots without any gateway and DNS settings. Setting address in shared mode should not work at all but, instead, it creates non-functioning hotspots. What I really need is some control of "x" in 10.42.x.1/24 ranges used by NM (as it sets "x" randomly). – David Radu Nov 4 '16 at 16:29
  • As said, you cannot configure the chosen subnet with version 0.9.8. It works with later version by configuring one manual address. You say it doesn't work, but it's not clear from your comment why. NM on Ubuntu 14.04 would not allow you to do what you want. – thaller Nov 4 '16 at 16:46

After hours of trying different solutions, I was finally able to specify a subnet for a Hotspot connection using Network Manager and then set a manual ip on the client device for a sort of static ip. None of the dnsmasq/dhcp methods work with Network Manager. You have to edit the Network Manager connection file. These files are generated for each connection in the following directory:


I believe that when you create a Hotspot, a new connection file is created and is named Hotspot. You need to edit this file. Make sure you are editing the Hotspot connection file or this will not work! Change/add the following lines under the section [ipv4] to set a subnet. Make sure it has the line method=shared and use whatever ip address you want for address1= and NetworkManager will issue all connecting devices an ip in the same subnet. The format for this line is address1=ip/subnetmask,gateway. Gateway should be the same as the ip. Here is what the [ipv4] section should look like:


Once you have this completed, save the file and run the following to restart Network Manager:

sudo service network-manager restart

Now your connected devices should be issued an ip address under the same subnet as the ip you entered. In this example it would be 192.168.125.x.

To get a static ip, do that on the client side device. Set a manual ip for this hotspot connection under same subnet, using the same subnet mask and gateway that were entered in the Hotspot connection file.

Here is my whole Hotspot connection file for reference:






Documentation on this setting in Network Manager can be read here:


Table 36. ipv4 setting

Key Name: method

Value Type: string

Default Value:

Value Description: IP configuration method. NMSettingIP4Config and NMSettingIP6Config both support "auto", "manual", and "link-local". See the subclass-specific documentation for other values. In general, for the "auto" method, properties such as "dns" and "routes" specify information that is added on to the information returned from automatic configuration. The "ignore-auto-routes" and "ignore-auto-dns" properties modify this behavior. For methods that imply no upstream network, such as "shared" or "link-local", these properties must be empty. For IPv4 method "shared", the IP subnet can be configured by adding one manual IPv4 address or otherwise 10.42.x.0/24 is chosen.

Most important part:

For IPv4 method "shared", the IP subnet can be configured by adding one manual IPv4 address or otherwise 10.42.x.0/24 is chosen.


The following appears to work OK - these commands force Network Manager to assign selected DHCP ranges to Wifi access points (10.42.0.x to wifiname1; 10.42.1.x to wifiname2):

nmcli connection modify wifiname1 ipv4.addresses
nmcli connection modify wifiname2 ipv4.addresses

Note: wifinameN (N=1/2) correspond to files in /etc/NetworkManager/system-connections.

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.