Introduction
In this article, we will discuss how to set up an Ad-hoc Wi-Fi network with multiple Raspberry Pi 5s using the nmclinmtui command-line tool. We will configure static IP addresses for each Raspberry Pi and will not set up a default route. This setup is useful when you want to create a local network without the need for a DHCP server or an internet connection.
Prerequisites
Before we begin, make sure you have the following:
- Two or more Raspberry Pi 5s
- A monitor, keyboard, and mouse for each Raspberry Pi (or SSH access)
- A microSD card with Raspberry Pi OS installed on each Raspberry Pi
- A valid SSH key or password for each Raspberry Pi
Step 1: Configure the Hosts File
First, we need to configure the hosts file on each Raspberry Pi to map the IP addresses to their respective hostnames. Open the hosts file on each Raspberry Pi using the following command:
sudo nano /etc/hosts
Add the following lines to the file:
127.0.0.1 localhostfirst_raspberry_pi_hostname second_raspberry_pi_hostname
Replace
Step 2: Configure the Wireless Interface
Next, we need to configure the wireless interface on each Raspberry Pi. Open the wpa_supplicant.conf file on each Raspberry Pi using the following command:
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
Add the following lines to the file:
country=US
network={
ssid="Your_Adhoc_Network_Name"
psk="Your_Network_Password"
id_str="raspberrypi_"
scan_ssid=1
}
Replace "Your_Adhoc_Network_Name" and "Your_Network_Password" with the name and password of your Ad-hoc network. Replace
Step 3: Configure the Network Interface
Now, we need to configure the network interface on each Raspberry Pi. Open the interfaces file on each Raspberry Pi using the following command:
sudo nano /etc/network/interfaces
Add the following lines to the file:
auto wlan0 allow-hotplug wlan0 ifname wlan0 source-addressnetmask 255.255.255.0 wireless-mode Ad-hoc wireless-essid Your_Adhoc_Network_Name wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
Replace
Step 4: Restart the Network Services
Restart the network services on each Raspberry Pi using the following command:
sudo systemctl restart networking.service
Step 5: Verify the Network Configuration
Verify that each Raspberry Pi can connect to the Ad-hoc network by checking the network interfaces using the following command:
ifconfig
You should see the wireless interface (wlan0) with the correct IP address and the Ad-hoc network SSID.
In this article, we learned how to set up an Ad-hoc Wi-Fi network with multiple Raspberry Pi 5s using the nmclinmtui command-line tool. We configured static IP addresses for each Raspberry Pi and did not set up a default route. This setup is useful when you want to create a local network without the need for a DHCP server or an internet connection.