Imagine you have only a ethernet cable and more than a laptop to connect to the Internet (i.e.: your mobile phone, the laptop of a friend and his mobile phone, etc). Imagine you’re in a undergroun Data Center, or in a hotel’s room where you don’t have wifi (for example, in Japan). If you had an Access Point, you could simply connect that cable to it and every device would go through it…
Well, if you have GNU/Linux, you can accomplish it very easily. We’ll see how.
- [OPTIONAL] Blacklist the manufacturer module
I faced some troubles when I tried to create the ad-hoc connection, and I solved it by blacklisting the manufacturer wmi module, so to see if you have any loaded you can do:
lsmod | grep wmi acer_wmi 20480 0 sparse_keymap 16384 1 acer_wmi wmi_bmof 16384 0 rfkill 20480 7 bluetooth,acer_wmi,cfg80211 wmi 20480 2 wmi_bmof,acer_wmi video 36864 2 acer_wmi,i915 i8042 24576 1 acer_wmi led_class 16384 4 sdhci,input_leds,acer_wmi,ath9k
As my laptop is an acer, the module obviously is acer_wmi. Select what you guess is yours and blacklist with something like
echo "blacklist acer_wmi" > /etc/modprobe.d/acer.conf
And reboot to apply.
- Creating it with NetworkManager
With NetworkManager, creating an Access Pointy connection is pretty straight forward. You need to:
- Create a Wi-Fi Connection (Shared)
- Put a name for the connection (like Access Point Connection)
- Put a name for the SSID (like LinuxAP)
- On “Wi-Fi Security” tab, select “WPA/WPA2 PSK” and set the password for your network
- On the same computer you just created the Access Point network, connect to that “LinuxAP” network with the provided credentials.
Ready, now take your mobile phone and browse the Wi-Fi networs, you’ll see a new one named “LinuxAP” and you will be able to connect to it with the password you’d provide.
To bring down the Access Point, simply use NetworkManager to disconnect from “LinuxAP”. Immediatly, all devices connected will be disconnected as well.
- Creating an Access Point within the command line
The easiest way to create an access point without NetworkManager is using the script create_ap.
sudo pacman -S create_ap
Once installed, let’s create our Access Point with
# create_ap ap0 WIRELESS_INTERFACE LinuxAP WPA2_PASSWORD
And let it run on a terminal. It will create and adapter called “ap0” as long as the create_ap script runs.
ap0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 link/ether b8:ee:65:1e:13:95 brd ff:ff:ff:ff:ff:ff inet 192.168.12.1/24 brd 192.168.12.255 scope global ap0 valid_lft forever preferred_lft forever inet6 fe80::2257:61cf:b9ce:5873/64 scope link valid_lft forever preferred_lft forever
You can grab your mobile phone and connecto to “LinuxAP” using the WPA2_PASSWORD. When you want to bring down the Access Point, just go to the terminal where create_ap is running and Ctrl+C to shut it down.
Note: If you use the create_ap approach, it will blacklist your wireless device in NetworkManager. If you plan to manage that device with NetworkManager, take in mind that you will need to modify /etc/NetworkManager/NetworkManager.conf and comment out or delete the line unmanaged-devices and restart NetworkManager.service.