In some Linux distributions (e.g. Ubuntu, Debian), udev automatically renames any device with its name prefix is "eth*", "wlan*",... as declared in "/lib/udev/rules.d/75-persistent-net-generator.rules". This made a problem when creating a virtual device on these distributions declaring that device not found. Solution was to change virtual device's name prefix to "ap*" to avoid this collision.
Ubuntu has a bit different setup than other distributions and because
of this dnsmasq was failing to retrieve the results of a DNS lookup.
This can be fixed if we specify that the listen-address is the gateway
instead of binding all the addresses of the WIFI_IFACE.
Fix#46
With the 6a3e1d98 commit NetworkManager was throwing an assertion so
we take a different approach when we create the bridge interface.
Also if the <interface-with-internet> is already a bridge interface
we skip creation.
The new approach is:
1) Save the IPs and route table of INTERNET_IFACE
2) If NetworkManager is running set INTERNET_IFACE as unmanaged
3) Create BRIDGE_IFACE and add INTERNET_IFACE to it
4) Set the previously saved IPs and route table to BRIDGE_IFACE
Better fix#19
To initialize the bridge interface correctly we need to do the following:
1) duplicate the IPs of INTERNET_IFACE to BRIDGE_IFACE
2) duplicate routing table of INTERNET_IFACE to BRIDGE_IFACE
3) delete routing table of INTERNET_IFACE
NOTE: we don't need to delete the IPs of INTERNET_IFACE
We need the above because BRIDGE_IFACE is the master interface from now on
and it must know where is connected, otherwise connection is lost.
Fix#19
Form NetworkManager 0.9.10 and above they introduce 'interface-name:'
for 'unmanaged-devices', use this method instead of 'mac:' since it
reduce many problems.
Fix#33
Some virtual interfaces have a different MAC address from their real
interfaces and their drivers disallow us to change it. In this case
we don't need to change the MAC address anyway.
With this we can avoid errors like 'RTNETLINK answers: Invalid argument'.
* Check the version of Network Manager and accordingly issue commands
as nmcli >= 0.9.10 is not backwards compatible
* Also, check if NetworkManager is running before issuing related
suggestions
Hostapd v2 introduces a bug which currently throws the following error
and initialization fails
nl80211: Could not configure driver mode
nl80211 driver initialization failed.
hostapd_free_hapd_data: Interface wlp3s0ap wasn't started
More Info: https://bugs.launchpad.net/ubuntu/+source/wpa/+bug/1289047
Give a suggestive message to the user when hostapd fails because of the
above bug outlining the workaround mentioned in the above bug report.
Inserted the ExecStop directive to kill the hostapd process in order for the script to be able to receive the SIGINT signal. This enables the cleaning process to work when requesting the service to stop.