2

I've been trying to create an ad hoc server using a Raspberry Pi 4 running Raspbian GNU Linux 11 (Buster) following this forum post. I've modified it slightly to make it simpler, rather than any logical checks for existing networks etc. it launches directly into ad-hoc mode on boot.

What I've done:

  1. Set up a DHCP Server
  • Installed isc-dhcp-server using sudo apt-get install isc-dhcp-server
  • Changed /etc/default/isc-dhcp-server to
# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
# Separate multiple interfaces with spaces, e.g. "eth0 eth1".
INTERFACESv4="wlan0"
INTERFACESv6=""
  • Changed /etc/dhcp/dhcpd.conf to
DHCPDARGS=wlan0; #args for the dhcpd daemon -> limit DHCP to the wlan0 interface
default-lease-time 600;
max-lease-time 7200;
 
option subnet-mask 255.255.255.0;
option broadcast-address 10.0.0.255;
option domain-name "RPi-network";
option routers 10.0.0.1; #default gateway
 
subnet 10.0.0.0 netmask 255.255.255.0 {
    range 10.0.0.2 10.0.0.20; #IP range to offer
}
 
#static IP-assignment
host myLaptop {
    hardware ethernet 11:aa:22:bb:33:cc;
    fixed-address 10.0.0.100;
}
  • Changed /etc/network/interfaces to
# start interfaces upon start of the system
auto lo wlan0
 
# register loopback interface
iface lo inet loopback
 
# use dhcp and allow interface to be started when kernel detects a hotplug event
allow-hotplug eth0
iface eth0 inet dhcp
 
# use manual ip configuration for wlan0 interface and allow hotplug as well
allow-hotplug wlan0
iface wlan0 inet manual
  1. Setup rc.local to launch the interface as an ad hoc network on boot. My rc.locallooks like:
#!/bin/bash
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will “exit 0” on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# Print the IP address
_IP=$(hostname -I) || true
if [ “$_IP” ]; then
printf “My IP address is %s\n” “$_IP”
fi

# RPi Network Conf Bootstrapper

createAdHocNetwork(){
echo “Creating ad-hoc network”
ifconfig wlan0 down
iwconfig wlan0 mode ad-hoc
iwconfig wlan0 key aaaaa11111 #WEP key you can change this but keep it 10 digits
iwconfig wlan0 essid pi_Ad-Hoc #SSID set this to whatever you want
ifconfig wlan0 10.0.0.200 netmask 255.255.255.0 up
/usr/sbin/dhcpd wlan0
echo “Ad-hoc network created”
echo “The server ip is 10.0.0.200”
}

createAdHocNetwork


exit 0

I can see this network from other devices, but when attempting to connect from a win10 laptop and a Google Pixel 4a both the connection reaches 'Secured' before giving the error 'Can't connect to this network'. On Windows, I can see a small circled x by the network name.
journalctl | grep -i dhc yields the following after attempted connection:

Mar 04 16:41:27 raspberrypi dhclient[273]: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 3
Mar 04 16:41:30 raspberrypi dhclient[273]: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 3
Mar 04 16:41:33 raspberrypi dhclient[273]: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 5
Mar 04 16:41:38 raspberrypi dhclient[273]: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 14
Mar 04 16:41:52 raspberrypi dhclient[273]: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 9
Mar 04 16:42:01 raspberrypi dhclient[273]: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 8
Mar 04 16:42:09 raspberrypi dhclient[273]: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 19
Mar 04 16:42:28 raspberrypi dhclient[273]: No DHCPOFFERS received.
Mar 04 16:42:28 raspberrypi dhclient[273]: No working leases in persistent database - sleeping.
Mar 04 16:42:51 raspberrypi dhcpcd[459]: wlan0: failed to renew DHCP, rebinding
Mar 04 16:42:51 raspberrypi dhcpd[700]: DHCPREQUEST for 10.0.0.2 from e4:5f:01:d4:81:c3 (raspberrypi) via wlan0
Mar 04 16:42:51 raspberrypi dhcpd[700]: DHCPACK on 10.0.0.2 to e4:5f:01:d4:81:c3 (raspberrypi) via wlan0
Mar 04 16:42:55 raspberrypi dhcpd[700]: reuse_lease: lease age 4 (secs) under 25% threshold, reply with unaltered, existing lease for 10.0.0.2
Mar 04 16:42:55 raspberrypi dhcpd[700]: DHCPREQUEST for 10.0.0.2 from e4:5f:01:d4:81:c3 (raspberrypi) via wlan0
Mar 04 16:42:55 raspberrypi dhcpd[700]: DHCPACK on 10.0.0.2 to e4:5f:01:d4:81:c3 (raspberrypi) via wlan0
Mar 04 16:43:04 raspberrypi dhcpd[700]: reuse_lease: lease age 13 (secs) under 25% threshold, reply with unaltered, existing lease for 10.0.0.2
Mar 04 16:43:04 raspberrypi dhcpd[700]: DHCPREQUEST for 10.0.0.2 from e4:5f:01:d4:81:c3 (raspberrypi) via wlan0
Mar 04 16:43:04 raspberrypi dhcpd[700]: DHCPACK on 10.0.0.2 to e4:5f:01:d4:81:c3 (raspberrypi) via wlan0
Mar 04 16:43:19 raspberrypi dhcpd[700]: reuse_lease: lease age 28 (secs) under 25% threshold, reply with unaltered, existing lease for 10.0.0.2
Mar 04 16:43:19 raspberrypi dhcpd[700]: DHCPREQUEST for 10.0.0.2 from e4:5f:01:d4:81:c3 (raspberrypi) via wlan0
Mar 04 16:43:19 raspberrypi dhcpd[700]: DHCPACK on 10.0.0.2 to e4:5f:01:d4:81:c3 (raspberrypi) via wlan0
Mar 04 16:43:52 raspberrypi dhcpd[700]: reuse_lease: lease age 61 (secs) under 25% threshold, reply with unaltered, existing lease for 10.0.0.2
Mar 04 16:43:52 raspberrypi dhcpd[700]: DHCPREQUEST for 10.0.0.2 from e4:5f:01:d4:81:c3 (raspberrypi) via wlan0
Mar 04 16:43:52 raspberrypi dhcpd[700]: DHCPACK on 10.0.0.2 to e4:5f:01:d4:81:c3 (raspberrypi) via wlan0
Mar 04 16:43:57 raspberrypi dhcpcd[459]: wlan0: DHCP lease expired
Mar 04 16:43:57 raspberrypi dhcpcd[459]: wlan0: deleting route to 10.0.0.0/24
Mar 04 16:43:57 raspberrypi dhcpcd[459]: wlan0: deleting default route via 10.0.0.1
Mar 04 16:43:57 raspberrypi dhcpcd[459]: wlan0: soliciting a DHCP lease
Mar 04 16:43:57 raspberrypi dhcpd[700]: reuse_lease: lease age 66 (secs) under 25% threshold, reply with unaltered, existing lease for 10.0.0.2
Mar 04 16:43:57 raspberrypi dhcpd[700]: DHCPDISCOVER from e4:5f:01:d4:81:c3 (raspberrypi) via wlan0
Mar 04 16:43:57 raspberrypi dhcpd[700]: DHCPOFFER on 10.0.0.2 to e4:5f:01:d4:81:c3 (raspberrypi) via wlan0
Mar 04 16:43:57 raspberrypi dhcpcd[459]: wlan0: offered 10.0.0.2 from 10.0.0.200
Mar 04 16:43:57 raspberrypi dhcpd[700]: reuse_lease: lease age 66 (secs) under 25% threshold, reply with unaltered, existing lease for 10.0.0.2
Mar 04 16:43:57 raspberrypi dhcpd[700]: DHCPREQUEST for 10.0.0.2 (10.0.0.200) from e4:5f:01:d4:81:c3 (raspberrypi) via wlan0
Mar 04 16:43:57 raspberrypi dhcpd[700]: DHCPACK on 10.0.0.2 to e4:5f:01:d4:81:c3 (raspberrypi) via wlan0
Mar 04 16:43:57 raspberrypi dhcpcd[459]: wlan0: probing address 10.0.0.2/24
Mar 04 16:44:01 raspberrypi dhcpcd[459]: wlan0: leased 10.0.0.2 for 534 seconds
Mar 04 16:44:01 raspberrypi dhcpcd[459]: wlan0: adding route to 10.0.0.0/24
Mar 04 16:44:01 raspberrypi dhcpcd[459]: wlan0: adding default route via 10.0.0.1

jounralctl -u isc-dhcp-server only shows the first run errors from not being configured. Could anyone point me in the right direction to solve or even just troubleshoot this? Thanks in advance!

3
  • You have to be joking - trying to follow a 10+ year old tutorial for an obsolete OS. Virtually everything you have done is obsolete. You probably don't want an ad-hoc network anyway - just create an Access Point.
    – Milliways
    Mar 4, 2023 at 23:29
  • your question is not even about the Raspberry Pi ... it is a question about Linux
    – jsotola
    Mar 4, 2023 at 23:36
  • @Milliways I guess I was too stuck on the term ad-hoc as a large proportion of responses I found using it as a keyword were quite outdated (as you said lol), already finding much more promising and contemporary reading using Access Point. Thank you!
    – lundbrundt
    Mar 5, 2023 at 14:08

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.