
In this article, we will be discussing how to set up an access point with Netplan on Ubuntu Server 18.04. This setup can be beneficial for creating a wireless network or extending your existing network.
To set up an access point with Netplan on Ubuntu Server 18.04, you will need to install the necessary packages, unmask and enable the hostapd service, create a hostapd configuration file, edit the hostapd configuration file, configure the network with Netplan, and apply the new Netplan configuration. This process allows you to create a wireless network or extend your existing network.
Prerequisites
Before we begin, ensure that you have:
- A system running Ubuntu Server 18.04
- A user account with sudo privileges
- A wireless network interface
Step 1: Install Necessary Packages
The first step is to install the necessary packages. We will need the hostapd
package, which allows the use of a network interface as an access point.
Open your terminal and enter the following commands:
sudo apt-get update
sudo apt-get install hostapd
The sudo apt-get update
command updates your package lists, while sudo apt-get install hostapd
installs the hostapd package.
Step 2: Unmask and Enable hostapd
Next, we need to unmask and enable the hostapd
service. This is done with the following commands:
sudo systemctl unmask hostapd
sudo systemctl enable hostapd
The unmask
command removes any masks that prevent the service from starting. The enable
command sets the service to start on boot.
Step 3: Create the hostapd Configuration File
Now, we need to create a configuration file for hostapd
. This file will contain the settings for our access point.
Use the following command to create and open the file:
sudo nano /etc/hostapd/hostapd.conf
In this file, paste the following configuration:
interface=wlan0
driver=nl80211
hw_mode=g
channel=1
ieee80211d=1
country_code=DE
ieee80211n=1
wmm_enabled=1
ssid=yourSSID
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=yourpassphrase
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP
Here is a brief explanation of some of the parameters:
interface
: This specifies the wireless interface to be used. In our case, it iswlan0
.driver
: This is the driver to be used.nl80211
is generally the standard for most modern wireless devices.ssid
: This is the name of your wireless network.wpa_passphrase
: This is the password for your wireless network.
Remember to replace yourSSID
and yourpassphrase
with your desired network name and password, respectively.
Step 4: Edit the hostapd Configuration File
Next, we need to tell hostapd
where to find the configuration file we just created. To do this, open the /etc/default/hostapd
file:
sudo nano /etc/default/hostapd
In this file, find the #DAEMON_CONF=""
line and replace it with DAEMON_CONF="/etc/hostapd/hostapd.conf"
.
Step 5: Configure the Network with Netplan
Now, we need to configure the network using Netplan. Open the Netplan configuration file with the following command:
sudo nano /etc/netplan/01-netcfg.yaml
In this file, paste the following configuration:
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: no
wlan0:
dhcp4: no
bridges:
br0:
interfaces:
- eth0
- wlan0
addresses:
- 192.168.1.xxx/24
gateway4: 192.168.1.x
nameservers:
addresses: [1.1.1.1, 1.0.0.1]
This configuration sets up a bridge (br0
) that includes both the eth0
and wlan0
interfaces. Replace 192.168.1.xxx
with your desired IP address, and 192.168.1.x
with your gateway address.
Step 6: Apply the New Netplan Configuration
Finally, we need to apply the new Netplan configuration. This is done with the following commands:
sudo netplan generate
sudo netplan apply
The generate
command checks the configuration for errors, while the apply
command applies the new configuration.
Conclusion
Congratulations! You have successfully set up an access point with Netplan on Ubuntu Server 18.04. Now, you can connect to your new wireless network with the SSID and password you set earlier. If you have any questions or run into any issues, feel free to ask for help in the comment section below.
No, you will need a wireless network interface to set up an access point with Netplan on Ubuntu Server 18.04.
It is recommended to use the nl80211 driver as it is the standard for most modern wireless devices. However, you may be able to use a different driver depending on your specific hardware.
You can use the iwconfig
command in the terminal to list the available wireless interfaces on your system.
Yes, you can change the channel and country code in the hostapd configuration file to comply with the regulations and requirements of your specific location.
Yes, you can set up multiple access points by creating separate hostapd configuration files and Netplan configurations for each access point.