I am what is known in the business as a "professional moron". Take anything I write here with a huge grain of salt. If something breaks, it probably also broke for me so please don't come complaining because I'll probably be busy trying to fix it. If you have questions, I can look at them with great intensity, but I cannot promise you answers. If you have remarks about what I'm doing and/or tips on how to make it better, I will probably read them and reply with a "Thanks! 👍". Either way, send me an e-mail if you want to tell me something. My address should be somewhere on this page, have fun finding it.
192.168.1.1with a nameserver, DHCP, and all that stuff.
Ubuntu Server 18.04 comes with
netplan by default now, which is a bit annoying because most tutorials I found either expected
ifupdown do be installed or explicitly told me to replace
netplan (something I did and then undid).
Either way, you can still do this using
netplan. But I'm getting ahead of myself, let's find out what interfaces we have first. You can use the following command for that:
ip addr show
Here's an abridged version of what it outputs for me:
sff@panfried:~$ ip addr show 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: enp4s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master br0 state UP group default qlen 1000 link/ether e8:9d:87:5e:11:2a brd ff:ff:ff:ff:ff:ff 3: wlp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master br0 state UP group default qlen 1000 link/ether 88:53:2e:27:16:63 brd ff:ff:ff:ff:ff:ff
From what I gather, some part of
systemd gives these funky names to your interfaces. They used to be called
wlanX, ... before but it doesn't really matter. My wired interface is called
enp4s0, my wireless interface is called
wlp3s0. Make sure to write yours down somewhere. Or just remember them, if you have good memory.
So, my approach for solving this conundrum is bridging the two interfaces together. Well, that ended up being my approach, first I did some weird stuff with
iptables but that just gave me a headache. Either way, it boils down to adding a
bridge interface that... bridges the two other interfaces. From what I gathered, the purpose of a bridge is to create a single network from multiple segments/interfaces, as opposed to setting up two networks (one via the wired interface, another via the wireless interface) and routing requests from one to the other.
Either way, you can create a bridge using
netplan. First I disabled the
cloud-init Ubuntu comes with out-of-the-box. Just follow the instructions in
/etc/netplan/50-cloud-init.yaml. I'm not sure you need to do this, but I did it just in case. Afterwards, add a file
/etc/netplan/10-network.yaml (you can also give it another name, it's okay) with the following contents:
sff@panfried:~$ cat /etc/netplan/10-network.yaml network: version: 2 renderer: networkd ethernets: enp4s0: # Set this to your own wired interface dhcp4: no wlp3s0: # Set this to your own wireless interface dhcp4: no bridges: br0: # You don't need to call it br0 by the way interfaces: [enp4s0, wlp3s0] addresses: [192.168.1.237/24] # A static IP I chose, you can pick one yourself. But also, I'd prefer if the IP wasn't static, but I'm not sure how to do it. gateway4: 192.168.1.1 # IP of my router nameservers: addresses: [192.168.1.1] # Since my router also does the DNS, IP of my router
You can enable it by running
sudo netplan apply
Now we need to add the actuall access point. I used
hostapd for that. Install it as follows:
sudo apt install hostapd
Let's edit some configuration files first. In
/etc/defalt/hostapd edit the following line:
#DAEMON_CONF="" <--- it looks like this by default, change it DAEMON_CONF="/etc/hostapd/hostapd.conf"
Now, we add the configuration of
hostapd itself. Create
/etc/hostapd/hostapd.conf and place the following in it:
interface=wlp3s0 # Set this to your own wireless interface bridge=br0 # Set this to your own bridge interface driver=nl80211 # Hardware mode, see: https://wiki.gentoo.org/wiki/Hostapd for mroe info hw_mode=g channel=1 # Limit the frequencies used to those allowed in the country ieee80211d=1 # Set the country country_code=BE # Set this to your own country # 802.11n support ieee80211n=1 # QoS support wmm_enabled=1 # Accept all MAC addresses macaddr_acl=0 # Shared Key Authentication auth_algs=1 # Don't broadcast SSID ignore_broadcast_ssid=1 ssid=YourSSID wpa=3 wpa_passphrase=YourPassphrase wpa_key_mgmt=WPA-PSK wpa_pairwise=TKIP rsn_pairwise=CCMP
hostapd and start:
sudo systemctl enable hostapd sudo systemctl start hostapd
And that's it! It should be working now.