1

I need to connect a device to raspberry pi via ethernet cable, the said device has no wireless functionality. I understand that we have hostapd on raspberry pi that can setup wireless access point, which unfortunately is not feasible in my case. Hence, I need to connect the device to raspberry pi, and get an ip address assigned to the device by raspberry pi. There is no need to connect to the internet. It would seem like an enclosed network just between raspberry pi and the device.

2

Using systemd-networkd it is simple to achieve what you want. First use it with:

# disable classic networking
rpi ~$ sudo -Es
rpi ~# systemctl mask networking.service dhcpcd.service
rpi ~# mv /etc/network/interfaces /etc/network/interfaces~
rpi ~# sed -i '1i resolvconf=NO' /etc/resolvconf.conf

# enable systemd-networkd
rpi ~# systemctl enable systemd-networkd.service systemd-resolved.service
rpi ~# ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf

Then create this file:

rpi ~# cat > /etc/systemd/network/04-eth0.network <<EOF
[Match]
Name=e*
[Network]
Address=192.168.4.1/24
DHCPServer=yes
EOF

Reboot and it should do.

1

You will need to disable dhcpcd (which implements the DHCP client) and set up a static IP address. You can refer to this answer if you're unsure how to do that.

Then you'll need to install (sudo apt-get install) and configure dhcpd (which implements the DHCP server). Essentially, you will need to define a subrange of dynamic IP addresses which can be assinged to clients on the same subnet on which you have configured the static IP. Assuming you have used 192.168.0.1 as the static IP, you could go with

subnet 192.168.0.0 netmask 255.255.255.0 {
  range 192.168.0.10 192.168.0.30;
}

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.