Selfhosted
A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.
Rules:
-
Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.
-
No spam posting.
-
Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.
-
Don't duplicate the full text of your blog or github here. Just post the link for folks to click.
-
Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).
-
No trolling.
Resources:
- selfh.st Newsletter and index of selfhosted software and apps
- awesome-selfhosted software
- awesome-sysadmin resources
- Self-Hosted Podcast from Jupiter Broadcasting
Any issues on the community? Report it using the report flag.
Questions? DM the mods!
view the rest of the comments
Give each device a static address, and set the default gateway to whatever's on the other end of the cable. You might need a crossover cable, but most NICs can work using a straight-through.
E.g. set the laptop's address to
169.254.1.1/16
and default gateway to169.254.1.2
, and the RPi's address to169.254.1.2/16
and default gateway to169.254.1.1
. They should be able to talk to each other then.If those addresses seem familiar - Windows uses the 169.254.0.0/16 subnet to automatically assign random addresses if DHCP fails, so that if there are several computers in the subnet, they'll at least have addresses that can talk to each other. It's called APIPA in Windows, and Zeroconf in the Unixverse.
~~You jump between 196 and 169 in your comment.~~
It's not just Windows that uses 169.254. That's a special block used for self assigned link-local addresses.
oops, fixed. Caffeine withdrawal is hell.
Would you set a gateway? They're on the same network.
You would not. In the example given 169.254.1.1 doesn't even exist, no machine is listening on that address so it couldn't possibly do any good if it wanted to
Thanks! That seems rather easy. Only thing I'm not sure about, I have basically only access to the pi over SSH. I could use a screen and keyboard but would prefer not to. What would happen if I configure the network wrong on the pi and can not connect anymore, even over my home network? Could I change the config by putting the SD card into my laptop and changing a file? Or is it possible to make it redundant, so if it can't find a DHCP server, it automatically switches to the preconfigured settings you described? :) Thanks a lot
Configure ethernet with fixed IPs, and configure wifi to use your phone hotspot.
Then you can use one to troubleshoot the other as needed.
Then your normal setup would be wired between the pi+laptop, with the laptop connected to local wifi for internet.
Network interfaces can be assigned multiple IP addresses. You should be able to use DHCP and a link local address at the same time.
That said I think this is easier to do with network manager. I'm not sure how it works with the rpi. But "link local address rpi" is a good search term to start with.
I've never used a pi, but it should be possible to mount the root partition and edit the
/etc/network/interfaces
or/etc/dhcpcd.conf
file, or/etc/NetworkManager/conf.d/*
if you have NetworkManager (systemctl status NetworkManager
to check).You should also make sure that sshd is listening for connections from any address (
0.0.0.0
and::
).Is there an easy method to know the self assigned IP address of the other machine if it's run as headless?
The only methods I can think of is using something like Wireguard to see what IP addresses are talking, or ping all 32k IP addresses to see which responds.
The poster you're replying to is suggesting a static IP in the apipa range, not an apipa assigned ip. You'd already know a static IP because you set it yourself.
You mean Wireshark? It's possible. You might even capture the DHCP exchange.
The two best programs for the job are
nmap
andarp-scan
.Nmap is like ping on steroids. You can use it for network discovery, port scanning, fingerprinting, and basic pentesting. As long as the pi can talk to the computer,
nmap
will sniff it out.ARP-scan works on the data link layer to identify hosts using ARP. It should be able to return the IP address of all ethernet devices even if they end up in different subnets. It took me a little over two minutes to scan a /16 subnet with one retry and 0.1 second timeout.
If you are really concerned about the pi's address, you should run a local DHCP server on the laptop.
dnsmasq
for Linux and Mac, but I have no idea what to use on Windows (other than a VM bridged to the ethernet interface).Setting the default gateway is unnecessary for a network of peers that are already on the subnet. It can only lead to problems as the hosts try to send every request outside their network to 169.254.1.1, which doesn't even exist in this scenario
Would the Pi automatically set an APIPA address if DHCP was not available? If so he need only connect the cable, and ask each machine what their address is.
No idea. It depends on what software it uses for network configuration, and how that software handles DHCP failure. I use NetworkManager and I've never gotten an APIPA address.