I have a device that is connected to Raspberry Pi via Ethernet cable. The Pi is connected to internet via WiFi. The device should not be visible from the main home network, which has 10.0.0... ip address range. How do I setup a 192.168... subnet on Raspberry’s ethernet so it can communicate with the device via UDP ? The device itself does not need to access wan.


The easiest way is to use static IP addresses, if your device supports that. Give the device IP address netmask and your pi's ethernet adapter the address, same mask.

Another fairly easy way would be to buy a cheap router/switch thing with a DHCP server in it. You probably won't need gigabit speeds. This has another advantage: you can connect the "wan" interface to your home-network and allow port forwarding to the Pi. And you will probably have a few spare ports on the 192.168-lan, which can be useful.

Of course, it is also possible to set-up a DHCP server on the Pi. In that case, you can connect the device directly to Pi (no switch or cross-over cables are needed). There are plenty tutorials on how to set-up such a server (see reply by @ingo)

  • I think a potential issue with this is you need to be able to configure the connected device with the static IP in advance.
    – goldilocks
    Oct 28 '20 at 19:38
  • @goldilocks: not with the second option. At the prices of (second hand) soho-devices, I think that could actually the easiest option. Oct 28 '20 at 21:23
  • Yes, I meant "a potential issue" w/ a static IP.
    – goldilocks
    Oct 28 '20 at 21:30
  • This doesn't sound right... have you tried this yourself & seen it work?
    – Seamus
    Oct 29 '20 at 2:56
  • @Seamus: what option does not sound right? usig static IP addresses, using a SOHO router or using a DHCP server? I've used the two first, but a DHCP server should not be such a problem. Oct 29 '20 at 3:46

You can use systemd-networkd that provides everything out of the box, including a DHCP server. You only have to configure it, no need to install additional helper programs. First setup the WiFi connection. You can Use systemd-networkd for general networking, following section ♦ Create interface file for a WiFi connection.

Then create this file for the wired interface to the device:

rpi ~$ sudo -Es   # if not already done
rpi ~# cat > /etc/systemd/network/04-wired.network <<EOF


Because there is no ip forwarding or routing enabled, only the RasPi can connect to the device and there is no way for the device to your local network and vice versa and to the internet.

If the device supports multicast DNS (mDNS) or Link-Local Multicast Name Resolution (LLMNR) you can try to address it with its name, e.g. ping devicename.local (mDNS) or ping devicename (LLMNR).

  • sudo cat sudo -Es? not just sudo -Es? Oct 29 '20 at 8:06
  • @LjmDullaart Thanks for the hint, you are right. I corrected the typo.
    – Ingo
    Oct 29 '20 at 9:54

As suggested by @LjmDullaart I set static ip address to ethenet adapter in /etc/dhcpcd.conf

static ip_address=

in section eth0 with no other changes. Please note you will not see the change in ifconfig unless someting is connected to the ethernet port. So now my device is connected to pi and there is no access to it from the outside world, just what I need.

  • Please mark the answer as the accepted one with a click on the tick on its left side. That prevents your Question from being shown as an unsolved Post to the community and saves them/us a lot of work.
    – Ingo
    Nov 3 '20 at 16:46

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.