Creating a Wifi hotspot to share internet with

Hello,

My Opensuse 13.2 Xfce system is connected to the internet with ethernet, and has a Wifi netcard, from which I want to create a hotspot for my mobile devices. Sadly it seems that Xfce is rather feature lacking, so I’ve tried going through config files and scrips with the help of this guide: https://nims11.wordpress.com/2012/04/27/hostapd-the-linux-way-to-create-virtual-wifi-access-point/
(not mentioned in the guide: I had to make a rule for NetworkManager not to touch my Wifi card, for the nl80211 driver to be able to load)

I use the dnsmasq route in the guide, as it can’t find the “dhcpd” command even though I have dhcp installed, along with a bunch of other errors. It says dnsmasq is better anyways.
None of my devices get an IP address after connecting to my hotspot, however. Also, once I have started the hotspot, my computer loses all internet connectivity, seemingly because of DNS problems.

I might have made a mistake, in that my /etc/dnsmasq.conf file now only contains the content of the guide, while it says the content should be appended to the existing file. I don’t remember deleting anything from it, though.

Any help is greatly appreciated

What does the following report about your wireless device?

/usr/sbin/iwconfig

This old openSUSE guide might also be helpful:

https://forums.opensuse.org/showthread.php/410475-How-to-setup-an-Access-Point

Even though you are using XFCE, you should be able to use NM to configure an Access Point as explained here (largely self-explanatory)

https://forums.opensuse.org/showthread.php/410475-How-to-setup-an-Access-Point
https://jeremy.visser.name/2009/03/simple-internet-connection-sharing-with-networkmanager/

iwconfig says:

enp2s0    Link encap:Ethernet  HWaddr 40:61:86:58:D0:A6            inet addr:10.62.68.250  Bcast:10.62.68.255  Mask:255.255.255.0
          inet6 addr: fe80::4261:86ff:fe58:d0a6/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:126159 errors:0 dropped:0 overruns:0 frame:0
          TX packets:127236 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:94325382 (89.9 Mb)  TX bytes:102070912 (97.3 Mb)


lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:22975 errors:0 dropped:0 overruns:0 frame:0
          TX packets:22975 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:1460245 (1.3 Mb)  TX bytes:1460245 (1.3 Mb)


victor@linux-43fb:~> sudo iwconfig
root's password:
enp2s0    no wireless extensions.


wlp3s7    IEEE 802.11bg  ESSID:off/any  
          Mode:Managed  Access Point: Not-Associated   Tx-Power=off   
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:on
          
lo        no wireless extensions.



I’m not really sure what to do. If I go into Network Manager and set my Ethernet’s IPv4 Method to “Share to other computers”, I lose internet. I can create a new wireless network that I set to Ad-Hoc, but it doesn’t… turn on. I have set that to “Share to other computers” as well. And worse, the only security available is WEP.

Your wireless card is not in AP mode

wlp3s7    IEEE 802.11bg  ESSID:off/any  
          Mode:Managed  Access Point: Not-Associated   Tx-Power=off   
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:on

Is the hardware capable of being configured that way? Check with

/usr/sbin/iw list
/usr/sbin/iw list|grep AP

https://wiki.archlinux.org/index.php/Software_access_point#Wi-Fi_device_must_support_AP_mode
http://askubuntu.com/questions/180733/how-to-setup-an-access-point-mode-wi-fi-hotspot

Yep, it should very well be AP capable:

Wiphy phy0	max # scan SSIDs: 4
	max scan IEs length: 2285 bytes
	Coverage class: 0 (up to 0m)
	Device supports RSN-IBSS.
	Supported Ciphers:
		* WEP40 (00-0f-ac:1)
		* WEP104 (00-0f-ac:5)
		* TKIP (00-0f-ac:2)
		* CCMP (00-0f-ac:4)
		* CMAC (00-0f-ac:6)
	Available Antennas: TX 0x3 RX 0x3
	Configured Antennas: TX 0x3 RX 0x3
	Supported interface modes:
		 * IBSS
		 * managed
**		 * AP**
		 * AP/VLAN
		 * monitor
		 * mesh point



Well, your wireless card is not in AP mode, so you need to review your configuration and maybe share here if necessary. Also, confirm that hostapd is running.

But I’m able to create a hotspot with the script form the page I linked to in my first post, doesn’t that put it into AP mode…? I think the issue is with DHCP. All my config files are taken directly from that page, the only things I have changed is the names of my adaptors, SSID, password, and that I only want WPA-PSK2.

Your ‘iwconfig’ output shows that the device is still in ‘managed’ mode. You need to investigate further to find out why that is.

In an effort to help, I’ve just configured a wireless hotspot using NM. Once I had done that and activated my ‘hotspot’ connection, I get the following reported

 # iwconfig
ens1      no wireless extensions.

lo        no wireless extensions.

wlan0     IEEE 802.11bg  Mode:Master  Tx-Power=20 dBm   
          Retry  long limit:7   RTS thr:off   Fragment thr:off
          Power Management:off

and I quickly tested that connection with my iPhone and was able to connect and reach the internet.

My working routing table now looks like

# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.90.1    0.0.0.0         UG    0      0        0 ens1
10.42.0.0       0.0.0.0         255.255.255.0   U     9      0        0 wlan0
192.168.90.0    0.0.0.0         255.255.255.0   U     1      0        0 ens1

But how do you active the wireless connection??

Well, if you’re using hostapd (check that it is running) and the configuration is ok, the wireless card should be in master mode and available for other devices to connect to.

The configuration guide (you were using) describes how to test using a minimal configuration:

CONFIGURING HOSTAPD

The /etc/hostapd/hostapd.conf is the main configuration which you need to deal with in order to set
up a SoftAP.

This is the minimal configuration setting which will let you test if hostapd is working. Create a
file ~/hostapd-test.conf
with the following content:

#change wlan0 to your wireless device
interface=wlan0
driver=nl80211
ssid=test
channel=1

start hostapd by

sudo hostapd ~/hostapd-test.conf

Use a wifi device to check if the access point is being detected. You won’t be able to connect to it
at present.
Once hostapd is working fine, its time to configure hostapd with more options.

I might not have said it clearly enough in my first post, but I am able to create my wireless hotspot. The problem is that

  1. Devices aren’t getting IP addresses

  2. Once activated, my computer loses internet connection

Okay, so devices could detect your access point? What you have not demonstrated is that your card is in master mode (like I did).

The problem is that

  1. Devices aren’t getting IP addresses

Is dnsmasq running? Check with

ps -A|grep dns
  1. Once activated, my computer loses internet connection

Check the routing table

ip route

and iptables for NAT

sudo /usr/sbin/iptables --list-rules

You should try configuring via Network Manager. It makes connectivity simple.

Alternatively, review the following masquerading guides using YaST

https://en.opensuse.org/SDB:Internet_connection_sharing
http://swerdna.dyndns.org/suseics.html

Yes, devices detect and can connect to the access point. They are then stuck at waiting for an IP address.

Yes, dnsmasq is running.

ip route:

default via 10.62.68.1 dev enp2s0  proto static  metric 1024 10.0.0.0/24 dev wlp3s7  proto kernel  scope link  src 10.0.0.1 
10.62.68.0/24 dev enp2s0  proto kernel  scope link  src 10.62.68.250 
80.71.128.56 via 10.62.68.1 dev enp2s0  proto dhcp  metric 1 

iptables:

-P INPUT DROP-P FORWARD DROP
-P OUTPUT ACCEPT
-A FORWARD -i wlp3s7 -j ACCEPT

wlp3s7 is the name of the wireless adapter, enp2s0 is the ethernet

I still don’t know how to activate the hotspot I create with Network Manager. It just sits there.

The default route is not correct and it should be pointing at your router. Here’s mine for reference

default via 192.168.90.1 dev ens1  proto static 
10.42.0.0/24 dev wlan0  proto kernel  scope link  src 10.42.0.1  metric 9 
192.168.90.0/24 dev ens1  proto kernel  scope link  src 192.168.90.250  metric 1 

I think you’ve configured dnsmasq incorrectly, and it’s binding to the wrong interface. That would explain why your devices don’t get a DHCP lease.

https://nims11.wordpress.com/2013/05/22/using-hostapd-with-dnsmasq-to-create-virtual-wifi-access-point-in-linux/

I still don’t know how to activate the hotspot I create with Network Manager. It just sits there.

Once the connection is defined, it’s just a matter of selecting it to activate.

Please, show me how

http://i.imgur.com/Hzj494C.png
http://i.imgur.com/fk13MlU.png

Are your devices managed by NM?

nmcli d

You wireless appears to be disabled. Verify status from CLI

nmcli nm

I have made some progress. I had to right-click the icon in the task bar, and tick off “Enable Wi-fi”. Now I was able to use it to create my Wi-fi. My devices can’t see it though, and it still only supports WEP encryption. It just looks like the computer connects to it’s own Wi-fi. I have set the mode to Ad-hoc. If I set the mode to Infrastructure, it supports WPA-PSK2, but then it disappears from the list of Wi-fi networks I could create.

I also tried setting it to no security at all, it still doesn’t show up on my devices.

At the top in the right-click menu, it says that Ethernet is disconnected, even though that is what’s providing internet…

nmcli d after creating the Wi-fi:

DEVICE  TYPE      STATE      CONNECTION         enp2s0  ethernet  connected  Wired connection 1 
wlp3s7  wifi      connected  ComeWithMe!!       
lo      loopback  unmanaged  --    

nm is unknown:

nmcli nmError: Object 'nm' is unknown, try 'nmcli help'.