0

For a certain project I have a very specific need to connect a Raspberry Pi with an unrooted android tablet through a UTP cable (with an adapter on the android side).

Both of these devices work fine if plugged into a separate router individually, since the tablet then gets a DHCP IP and all is well (being unrooted, it cannot have a static one unfortunately). Not so much when I try to connect them directly I cannot get the connection to work.

The option I was pursuing thus far was to set up a DHCP server on the Pi and have that set the IP on the tablet once it's connected. I've followed like 5 Pi DHCP tutorials by now and none of them worked so I'm slowly starting to reconsider this idea. Perhaps DHCP cannot work without a cross-over cable?

Another thing would be a direct bridge connection for which I'm not entirely sure where to start.

Any tips on what to pursue?

Moff Kalast
  • 124
  • 1
  • 7
  • What ip address exactly gets the android device from the router? Just to verify the ip class. – Ingo Jul 25 '19 at 08:42
  • It's somewhere in the usual 192.168.1.x range as is default from routers. The Pi has a static ip of 192.168.1.120. They obviously have to be in the same subnet. – Moff Kalast Jul 25 '19 at 08:57

1 Answers1

0

I have tested this tiny setup with systemd-networkd using a fresh flashed Raspbian Buster Light. Just switch to systemd-networkd 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

For more details look at Howto migrate from networking to systemd-networkd with dynamic failover.

Now create this file and reboot:

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

I couldn't test it with an android device because I haven't this ethernet dongle but with my laptop it works without problems. It gets an ip address from 192.168.1.0/24 and I can ping 192.168.1.120.

Ingo
  • 42,107
  • 20
  • 85
  • 197
  • I don't really have an option to try this out at the moment since I eventually figured out the dhcp problem (dnsmasq was running) and the Pi is already in an embedded device. I'll mark it as solved though. Thanks for taking the time to write it up anyway, hopefully someone will find it useful in the future. – Moff Kalast Jul 27 '19 at 08:10