1

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.

2

The easiest way is to use static IP addresses, if your device supports that. Give the device IP address 192.168.1.100 netmask 255.255.255.0 and your pi's ethernet adapter the address 192.168.1.101, 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)

| improve this answer | |
  • 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 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. – Ljm Dullaart Oct 28 at 21:23
  • Yes, I meant "a potential issue" w/ a static IP. – goldilocks Oct 28 at 21:30
  • This doesn't sound right... have you tried this yourself & seen it work? – Seamus Oct 29 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. – Ljm Dullaart Oct 29 at 3:46
2

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
[Match]
Name=e*

[Network]
Address=192.168.0.1/24
MulticastDNS=yes
DHCPServer=yes
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).

| improve this answer | |
  • sudo cat sudo -Es? not just sudo -Es? – Ljm Dullaart Oct 29 at 8:06
  • @LjmDullaart Thanks for the hint, you are right. I corrected the typo. – Ingo Oct 29 at 9:54
0

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

static ip_address=10.0.0.15/24

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.

| improve this answer | |
  • 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 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.