5

I just moved to a bigger apartment and my router signal peaks right before the edge of it, which is were I just installed my home server, an old laptop with ubuntu server I use to store media and as a printer server.

So the idea is to make the server act as a range extender as well, problem is I can't find any documentation on how to do it.

Can it be done?

1

I use this script described in this post to create a hotspot in my Ubuntu server:

http://www.webupd8.org/2013/06/how-to-set-up-wireless-hotspot-access.html

Basically, it helps you create a hotspot. You'll need to have two interfaces in the computer you want to use, one connected to the internet, and the serving the hotspot.

sudo add-apt-repository ppa:nilarimogard/webupd8
sudo apt-get update
sudo apt-get install ap-hotspot

When it's installed, run:

sudo ap-hotspot configure

It will ask you a few questions (internet interface, wireless interface to create the access point, password) and then the hotspot can be run and stopped with:

sudo ap-hotspot start
sudo ap-hotspot stop

Note than this script automates the process of creating the hotspot, which can be done manually installing and configuring dns-masq and hostapd, but the result is the same.

8
  • 3
    Thanks but wouldn't this create a separate AP? I need to extend the signal of the router
    – Ghost
    Dec 26 '13 at 14:12
  • Yes, it creates an access point, but it would work exactly the same way. What you do is basically make your server act as a wireless router. It's the closest solution I've found. Dec 26 '13 at 14:29
  • I would like this answer to be unaccepted so we can get an answer for wifi range extending Sep 29 '19 at 14:15
  • @steveantwan only the original poster of the question can unaccept. You can still get answers though even if a question has an accepted answer - accepted does not mean closed.
    – Thomas Ward
    Sep 30 '19 at 15:18
  • 1
    I see that my comment above ought to have gone to @steveantwan. If you can one of those servers you plan to use for extending your wifi have a wired connection to the LAN, then I can detail how I'd do it - but you've got to be someone comfortable working at the CLI.
    – AnthonyK
    Oct 7 '19 at 1:49
0

create_ap is a great tool for creating any access point.

I was able to create a wifi exteder using the following configuration:

CHANNEL=default
GATEWAY=192.168.2.1
WPA_VERSION=2
ETC_HOSTS=0
DHCP_DNS=gateway
NO_DNS=0
NO_DNSMASQ=0
HIDDEN=0
MAC_FILTER=0
MAC_FILTER_ACCEPT=/etc/hostapd/hostapd.accept
ISOLATE_CLIENTS=0
SHARE_METHOD=nat
IEEE80211N=0
IEEE80211AC=0
HT_CAPAB=[HT40+]
VHT_CAPAB=
DRIVER=nl80211
NO_VIRT=0
COUNTRY=
FREQ_BAND=2.4
NEW_MACADDR=
DAEMONIZE=0
NO_HAVEGED=0
WIFI_IFACE=wlan0
INTERNET_IFACE=wlan0
SSID=MyAccessPoint
PASSPHRASE=12345678
USE_PSK=0

This configuration basically creates a new hotspot with SSID: MyAccessPoint and password: 12345678, which will connect to the internet via the ubuntu server's INTERNET_IFACE

Important notes:

  1. NO_VIRT=0is a must if WIFI_IFACE and INTERNET_IFACE are the same.
  2. It's possible to play with these parametersIEEE80211N IEEE80211AC HT_CAPAB VHT_CAPAB to get better preformance from the ubuntu server's wifi, but it requires some more knowledge about your wifi hardware
  3. I used SHARE_METHOD=nat because SHARE_METHOD=bridge gave me an error, but I guess installing some requirments and/or updating the kernel would fix it.
0

The instructions below make the assumption that the Laptop (Server) is connected as indicated below - pardon my ascii art. Specifically, that it has a wired connection to the LAN and also has a Wireless interface.

                      ^             ^
                      |             |    SSID: This here be my WiFi
                      |             |     PSK: St@yTh3#ell0ut!
                      /             \ CHANNEL: 6
 -----------------   /               \   -----------------
|    Laptop   |   |wlan0           wlan0|   |  Router     |
|   (Server)   ---|                     |---              |
|              ---|                     |---              |
|             |   |eth0 --       -- eth0|   |             |
 -----------------        |     |        -----------------
                          |     | 
                     -----------------
                    |     Switch      |
                     -----------------

In this scenario, you can extend the Router's WiFi by using the following configuration. The steps below require that hostapd and dnsmasq be installed on the Laptop:

cat <<EOF | ~/extendwifi.sh
#!/bin/bash
sudo apt install -y hostapd
sudo mv /etc/hostapd.conf{,.old}
wget -qO- https://w1.fi/cgit/hostap/plain/hostapd/hostapd.conf | egrep -v '^$|^#' | sed -e 's/test/This here be my WiFi/;s/rts_threshold=-1/rts_threshold=2347/;s/fragm_threshold=-1/fragm_threshold=2346/' | sudo tee /etc/hostapd/hostapd.conf
echo -e "wpa=2\nwpa_passphrase=St@yTh3#ell0ut!\nwpa_key_mgmt=WPA-PSK WPA-EAP WPA-PSK-SHA256 WPA-EAP-SHA256" | sudo tee /etc/hostapd/hostapd.conf
EOF
chmod +x ~/extendwifi.sh
~/extendwifi.sh

Once the script above has been executed, you should restart the hostapd service systemctl restart hostapd

If you have WiFiAnalyzer (open-source) installed on your Android phone, then you should be able to now see this new access point (check the MAC addresses). See it? Good! If not, double check your configuration. Of note is the channel; make sure to change it in /etc/hostapd/hostapd.conf if they appear on the same channel.

Now, since this procedure has turned your lowly Laptop into a Router, we now need to deal with some networking bits. For that, you will definitely need dnsmasq and here's what you'll need to do:

  • Install dnsmasq - sudo apt install -y dnsmasq
  • Enable IP Forwarding (file /etc/sysctl.conf)
    • nano /etc/sysctl.conf
    • Uncomment net.ipv4.ip_forward=1
    • Save the file and exit the editor
    • sudo sysctl -p

Now we need to create the configuration for dnsmasq. Let's assume that we'll create a new subnet with the following details: - Subnet IP : 10.11.12.0/24 - DHCP Range : 10.11.12.13 to 10.11.12.32 - This gives you 20 devices that you can attach to this wifi subnet. - Increase if you need more - wlan0 IP : 10.11.12.1/24 - You will need to have somehow added this IP to the interface - There are many tutorials on how to accomplish this on the internet - Lease Period : 12hours - DNS Server : 192.168.1.1 - Assuming that the Router is at IP 192.168.1.1 and is also the DNS Server

Copy and paste the lines below on the terminal and hit enter:

cat <<EOF | sudo tee /etc/hostapd_dnsmasq.conf
bind_interfaces
interface=wlan0
dhcp-range=10.11.12.13,10.11.12.32,255.255.255.0,12h # increase if you need more
dhcp-option=option:router,10.11.12.1
dhcp-option=option:dns-server,192.168.1.1
EOF

Now we need to create a service file to start the dnsmasq service

Copy and paste the lines below on the terminal and hit enter:

cat <<EOF | sudo tee /etc/systemd/system/hostapd_dnsmasq.service
[Unit]
Description=DHCP and DNS caching server for wlan1.
After=network.target

[Service]
ExecStartPre=/sbin/iptables -t nat -A POSTROUTING ! -o wlan0 -j MASQUERADE
ExecStart=/usr/sbin/dnsmasq -k --conf-file=/etc/hostapd_dnsmasq.conf
ExecStopPost=/sbin/iptables -t nat -D POSTROUTING ! -o wlan0 -j MASQUERADE
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
RestartSec=300

[Install]
WantedBy=multi-user.target
EOF

Now that all bits and pieces are in place, let's start the service:

sudo systemctl restart hostapd_dnsmasq

I always use restart even though the service is stopped. This is my best practice.

If all is working as intended, then you can enable the service so it starts automatically on Laptop reboot:

sudo systemctl enable hostapd_dnsmasq

Enjoy!

NOTE: If your Laptop does not have an RJ45 port, then your only option is to use multiple WiFi dongles and definitely a different SSID for the new WiFi AP. The configuration will be similar; the main difference being that you will not be extending your current WiFi but rather creating a new one.

CAVEAT EMPTOR I have a similar setting that I occasionally utilise when I'm testing. If you break anything on your system, you alone are responsible for the breakage and you get to keep all the pieces.

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.