1. Current Location: Home >  NAS >  In the NAS, Tailscale loses power and has to log in again. There are three leaks.

In the NAS, Tailscale loses power and has to log in again. There are three leaks.

Three leaks in the state directory after the Tailscale container in the NAS is powered off and the troubleshooting sequence

At 11:40 pm on July 19th, the space in the study room jumped. The NAS was powered off immediately and was not connected to the UPS - the budget allocated two disks first, and the UPS was moved to the back. When I got home at dawn the next day, no one went to the study. It was my mobile phone that first noticed something was wrong.: The NAS node in tailnet is grayed out.

NAS actually got up on its own. I have the switch in the BIOS that turns on the incoming call automatically. I spent a whole night hunkering down in another article before I found it. , the N100 small host is hidden in Power Management. After hooking it up, it will come back to life automatically when it trips. I logged into the Feiniu backend at 9:20 in the morning, and there were 9 containers in the list, all green and running.: Jellyfin, Immich, qBittorrent, Home Assistant, Cloudreve, AdGuard Home, Vaultwarden, ddns-go, Tailscale.

It looks pretty. But I took my mobile phone and clicked on each one from the external network, and all eight services were accessible. Only the path through Tailscale was blocked. The container is not hung, and the process is not dead, but it just cannot be connected. This status is much harder to check than if the container is directly hung up - no error is reported in the background.

Let’s first explain clearly what happened that day

Put the conclusion first: What is broken is not the tunnel, but the "identity" of this NAS in the tailnet. Tailscale relies on the node itself to bring the node key to the table. The key is in a local file. If the file is lost, the machine is reborn.

I have tried many ways to go back to my home NAS, including DDNS plus port mapping, intranet penetration, and IPv6 direct connection. I have calculated all the accounts and written them down. I have tried all three routes in that article. inside. The last thing I left behind was the VPN networking section. Only one UDP port was exposed at home, and the rest were closed. The logs were finally clean. This and I ran 5001 naked for a week and only left one UDP port. It's the same set of ideas. But the VPN path has a premise that it must always be there - once a node is disconnected, the table must be rechecked.

On July 19, I saw the container log scrolling to 23:58, and the last line was still normal. After the power is cut off, the container is pulled up again, and the process is new, but tailscale status It just stops at Connecting to control.tailscale.com , can't go any further. Feiniu was not slow, Immich was already scanning photos at that time.

What really threw me for a loop was the background device list. There is an extra device inside that I can’t name. The name was randomly chosen by me back then, but the creation time was 9:26 a.m. on July 20—six minutes after the power was cut off. My first reaction was that someone had logged in. I stared at it for half an hour. Only later did I understand: It's not someone else, it's itself.

The first one to miss: The temporary container has no directory attached at all.

On the day I installed Tailscale, I followed the official quick start instructions. There is a sentence in it: tailscale up --state=/dev/null . The meaning is very straightforward: The status is written to /dev/null, which means it is not written.

In order to save trouble at that time, the container was directly clicked on "Install" in the Feiniu web backend without compose file. Once it can be connected after installation, I will consider it installed. Until that night when the power went out and the container was rebuilt, docker inspect tailscale Check the Mounts column, it's empty. I hung up ./ts-state:/var/lib/tailscale Not in it at all.

The state falling in /dev/null means that every time the process is restarted, it starts from zero. When the power is turned off, the key is thrown away. The node key is regenerated, and other devices still recognize the old key. So there will be a very confusing phenomenon: It is clearly running in the container list and there is no red text in the log, but it does not light up in the tailnet.

The replenishment method is stupid. Add a line of volume mapping to compose, fix the state to a directory on the disk, and then rebuild the container. The relative path in Feiniu ./ts-state actually falls on /vol1/1000/container Below, follow the working directory of the container. The location is fixed. I later confirmed this by running ls in the file system.

When it comes to container orchestration, I started by clicking around in the web backend, and then I changed it to writing compose files. The container never messed up again, and the process continued. After NAS switched to Docker Compose That was written. The lesson this time is a continuation of the same thing: In the container installed in the background of the web page, you rarely have the opportunity to see clearly what is attached to it.

Missing the second one: state follows the market

The hole has been buried longer. I changed the name of the storage pool from pool1 to nas in August, and moved several paths in it together. What is written in Tailscale's compose is /volume1/docker/tailscale , absolute path.

After changing the name, the directory cannot be found. Feiniu's handling method is to create a new file silently - it does not report an error or pop up a window, it directly creates a new empty directory for you, and the container starts as usual. So you will see that the container is "running normally", but the state is still empty.

When I was reviewing the review, I was looking at the timeline.: I changed the disk name in August, and every time I restarted the container, I lost my identity. But because the restart frequency is low, it only restarts two or three times a month. Each time it is just a "re-login", it is not painful or itchy, and it has never been discovered. What really came to light was the power outage on July 19th—not that it was broken, but that it had saved up enough reasons to log back on, and I happened to be outside that time.

The lesson of this section is: Do not write absolute paths for anything in the container that "remembers who you are". Either use a relative path to follow the working directory, or use the "container mounting directory" graphical configuration in the Feiniu backend instead of handwriting strings.

Missing the third one: Login again does not mean the container is broken.

Let’s talk about that strange device. After the node key is lost, the container runs once tailscale up It is equivalent to re-registering, and there will be one more row in the background device list. The old is still there, and the new is coming in.

I stared at that line for half an hour, and what was going through my mind was: Who logged in, at what time, and from which IP. Later, I discovered that the IP segment of the new one is exactly the home exit, and the creation time was six minutes after the power was cut off - that is my own NAS.

This is worth mentioning separately because it determines your next move. If it is invaded, what you should do is change the key and check the logs ; If it logs back in on its own, what you should do is delete the old one and then hang up the state. The two actions are completely opposite. If you make a wrong judgment, you will cut off your own tunnel manually.

The judgment method is also simple: Check to see if the new device name is the name you gave the NAS back then, and see if the creation time matches the time of your last power outage and restart. If it's right, log in again ; If you don't agree, then you have to be careful.

By the way, I will switch the log on this time. TS_LOG=1 Keep it, not for this incident - I opened the log specifically because the Docker log can reach 40G in half a year. After three steps of locking, I never touched the thunder again. . Tailscale's log volume is very small. If you keep it, you can see which step is stuck when the table fails. I have tried both ends.

My compose looks like this now

Putting the three missing points together, the final writing is just these few lines. You can copy it from Feiniu and use it directly, just change two or three names.

services: tailscale: image: tailscale/tailscale:latest container_name: tailscale privileged: true cap_add: - NET_ADMIN sysctls: - net.ipv4.ip_forward=1 - net.ipv6.conf.all.forwarding=1 volumes: - ./ts-state:/var/lib/tailscale restart: unless-stopped environment: - TS_STATE_DIR=/var/lib/tailscale - TS_LOG=1 - TS_SERVE=false - TS_ENABLE_TETHERING=lan

I have specially marked a few places. ./ts-state This is the core of this time. The state is here, and it can be recognized even when the power is cut off and restarted. restart: unless-stopped It must be checked, otherwise the NAS will power down once and the tunnel and the reverse generation hanging behind it will not get up on their own. TS_STATE_The DIR line may seem redundant, but pointing it and the volume to the same location in the container can prevent individual versions from reading from the default path.

privileged: true add NET_ADMIN It is because it needs to set up a TUN device as a virtual network card in the container. I was originally stuck on the choice between bridge and host. It was only after I installed Home Assistant that I really understood the difference between the two. I wrote this in Docker's bridge, host and port mapping inside. It is recommended to use host or at least allow UDP for the Tailscale container. Subnet routing is always blocked when using bridge.

Run once after pretending tailscale up --advertise-routes=192.168.1.0/24 , go to the background to confirm and enable that route. Just being connected to the tunnel does not mean that the entire LAN is automatically visible. This is the same as My speed increased tenfold after I straightened out IPv6 I stepped on the same pitfall that time - connectivity seems to be there, but the actual reach is smaller than you think.

To verify whether your identity is lost, you only need to look in one place.: tailscale status The creation time of the node inside. If the timestamp does not change before and after the power is turned off and restarted, it means that the state is hung. ; If it changes, it means logging in again. This is the only hard indicator. Whether the container is "running" or not does not count at all.

Check the order, starting with the cheapest step

Next time I encounter "the container is running but the tunnel is blocked", I will follow this order and the first two steps will basically be able to locate it. Don’t start using the Internet as soon as you get started.

What steps see what What does it mean, where to go?
1 status keeps stopping at Connecting to control It's not a network problem. Check the state first to see if the disk directory is mounted.
2 There is no such volume in Mounts in docker inspect For the temporary container, add a line ./ts-state:/var/lib/tailscale and then rebuild it.
3 state directory exists but is 0 bytes The path has failed before. Go back and look for the record on the day the disk name was changed.
4 There are many unfamiliar names in the background device list First compare the creation time. If it is powered off, it will log in again and delete the old node.

There is another one that leaks easily: Container restart strategy. Tailscale, a permanent product that has been around all year round, sets the restart policy to unless-stopped when building a container, and the "auto-restart" switch in Feiniu's backend is easily turned on. This time, 8 of the 9 containers were checked, and I added the Tailscale one later.

Looking at these three places together, we are actually asking about the same thing.: Where does the identity of the container reside. It is stored in the memory and will be gone when the power is turned off. ; Hang on the absolute path that follows the disk name. If you change the name once, it will be gone. ; No one cares about it re-listing, it just recognizes itself again. You can save the container if it dies, but you can only start over if your identity is lost.

This Tailscale has been in my house for five months now, and the power went out twice. One was for property maintenance, and the other was because the outdoor air conditioner blew the air conditioner. It came back on its own both times, the node list in tailnet has not changed, and the created timestamp has always stopped at the day it was installed. What I want is this "no need to worry about it".

If you are also running Tailscale in Feiniu, go read it first. docker inspect The Mounts column. Don't wait if it's empty, it just hasn't been powered off yet. I have sorted out the pitfalls for getting started with Docker. Feiniu NAS plays with Docker to understand mirror port mapping After reading that article about the number of containers and port mapping, I can now look back at the state issue this time.

Read More


Copyright Notice Scan to read on mobile
All Rights Reserved: 《SHUNOT》 => 《In the NAS, Tailscale loses power and has to log in again. There are three leaks.》
Article URL: https://www.shunot.com/en/nas/1607.html
Unless otherwise stated, all articles are original by 《SHUNOT》. Reposting is welcome! Please indicate the original URL when reposting, thank you.

Contact Us

Online Consultation: Click here to send me a message

WeChat ID: master_135

Scan to follow