Logo

site iconYinan

生活在英国的在读物理 PhD,记录日常,写点折腾笔记,热爱分享 App
请复制 RSS 到你的阅读器,或快速订阅到 :

Inoreader Feedly Follow Feedbin Local Reader

Yinan RSS 预览

Tailscale 访问内网特定端口

2025-06-30 22:26:44

搬家之后,家里的宽带从原来的 Virgin Media 1000 Mbps 下行100 Mbps 上行换到了 Hyperoptic 1000 Mbps 上下对等的光纤,价格都在37英镑每月,原以为是一次各方面的升级,结果却发现 Hyperoptic 并没有提供公网 ip(VM 提供公网 ipv4 在套餐内),如果要开通则需额外付5英镑每月。

原本一些运行在 nas 上的服务通过 OpenVPN 提供自组网内访问,但是考虑到安全问题,我并没有把 VPS 加入自组网,如果确实需要访问 nas 中的特定服务则通过路由器端口映射和防火墙提供给 VPS 访问。没有了公网 ip 之后,无法将服务端口映射开放,只能另寻其他解决方案。

Tailscale 的安全配置

之前在用 OpenVPN 的时候,也尝试过 Tailscale、Netbird 等自组网,现在为了让 VPS 也能访问到 nas 上的特定服务就必须要把 VPS 也加入到 Tailscale 网络,但是我又不想要 VPS 能够访问 Tailscale 网内的所有设备所有服务,就需要限制 VPS 只允许访问内网特定设备的特定端口 - 通过设定 ACL 规则。

这里贴出我的部分配置方案,去除了默认 grants 中允许所有连接的配置,加上了两条规则,仅允许 VPS 访问 NAS 的13333端口以及其他所有设备和 nas 互联。

{
    // Define the tags which can be applied to devices and by which users.
    "tagOwners": {
        "tag:nas": ["autogroup:admin"],
        "tag:vps": ["autogroup:admin"],
    },

    // Define grants that govern access for users, groups, autogroups, tags,
    // Tailscale IP addresses, and subnet ranges.
    //"grants": [
    // Allow all connections.
    // Comment this section out if you want to define specific restrictions.
    //  {"src": ["*"], "dst": ["*"], "ip": ["*"]},
    //],

    // Define users and devices that can use Tailscale SSH.
    "ssh": [
        // Allow all users to SSH into their own devices in check mode.
        // Comment this section out if you want to define specific restrictions.
        {
            "action": "check",
            "src":    ["autogroup:member"],
            "dst":    ["autogroup:self"],
            "users":  ["autogroup:nonroot", "root"],
        },
    ],
    // 定义访问控制规则
    "acls": [
        // 规则一:允许所有设备互相访问所有端口。
        // "autogroup:member" 代表 Tailscale 网络中的所有用户及其设备。
        {
            "action": "accept",
            "src":    ["autogroup:member"],
            "dst":    ["autogroup:member:*", "tag:nas:*"],
        },

        // 规则二:仅允许 VPS 访问 NAS 的13333端口。
        {
            "action": "accept",
            "src":    ["tag:vps"],
            "dst":    ["tag:nas:13333"],
        },
    ],

    // (可选) 添加测试以验证规则是否按预期工作

    "tests": [
        {
            "src":    "tag:vps",
            "accept": ["tag:nas:13333"], // 应该允许访问 13333 端口
            "deny":   ["tag:nas:5000"], // 应该拒绝访问 5000 端口
        }
    ],
}

配置完成后,如果测试成功则会正常保存配置文件,接下来回到管理设备页面为 nas 和 vps 分别打上标签即可。

另外我发现群晖使用 tailscale 的时候似乎无法通过 tailscale ip 来 ping 内网内的其他设备。

sudo ping 100.xx.xx.xxx # 这条会失败

sudo tailscale ping 100.xx.xx.xx # tailscale ping 却能成功
pong from (vps)xxx via 173.xxx.xxx.xxx:xxxxx in 87ms

似乎和这个 bug 有关。

Pagefind

2025-03-23 06:05:54

I found Pagefind as a full text search for static sites.

Pagefind is a fully static search library that aims to perform well on large sites, while using as little of your users’ bandwidth as possible, and without hosting any infrastructure.

So I added a small search button on the homepage and asked Claude to modify the style a bit. The best thing about this tool is that it is also a static index, meaning you don't have to keep the index server running in the back ground, once the index is generated, and the following snippet added to a page of your choice:

<link href="/pagefind/pagefind-ui.css" rel="stylesheet">
<script src="/pagefind/pagefind-ui.js"></script>
<div id="search"></div>
<script>
    window.addEventListener('DOMContentLoaded', (event) => {
        new PagefindUI({ element: "#search", showSubResults: true });
    });
</script>

You're good to go, it works perfectly with GitHub pages (what I'm using currently) or any other website framework such as Hugo. Alternatively, you can use it as a web server to host your static pages (add a --serve flag in the end, maybe it can update the index while new pages were generated).

Try it out in my blog!

On &quot;You don't need to work on hard problems&quot;

2025-03-05 23:09:38

You don't need to work on hard problems - Ben Kuhn

I just came across this interesting article. I have to agree on how the problems (and how you are evaluated) in school set deliberately to be linear or 1 dimensional. While in real world, problems tend to be multi-dimensional, which relies on both so-called soft skills and hard skills. However, it is also exactly the same reason that there is no other place than school, that you'll been evaluated in a fair, straight-forward way.

I am not saying that you don't need to work hard in school. However, what school really taught us was really far beyond solving hard problems.

Cross-post from Mastondon to X and Bluesky

2025-03-05 07:12:50

These are the current methods I am using to do Crossing Posting.

Log in both accounts and you're ready to post toots.

You'll need to configure both Twitter and Mastodon API for this.

Unfortunately I did not find a good way to sync old Tweets to mastodon account in mastodon.social. Let me know if you do find something for this.

记录足迹

2025-02-26 22:02:19

我之前在推特上分享过,用 RSS+Hoarder/DEVONthink 存档来记录我在互联网上的足迹。这篇文章我来推荐几个记录生活足迹的软件/方法。

不知道有没有人跟我有一样的记录习惯,事件记录,时间记录,地点记录。比如说在什么时间去了那些有趣的地方,可能是一个咖啡店,一个饭店,一次远足,甚至是记录日常健身跑步。

最简单的方案就是用日历,日历事件本身具有时间地点的属性,既可以用作提前安排行程事项,也可以用作记录过去的行程和地点。

在这个基础上,苹果商店就能找到一些一键记录时间戳/地点然后同步到日历的软件,关键词 where when。如果你用 Things 3 来做事项管理,Culturedcode 官方就提供了 Save My Location的捷径。

另外还有一个比较有意思的软件,what3words,这是一个以三个常见的单词组合来编码地理位置的系统,将地球表面划分为三米见方的网格,每一格对应专属的三个词语。例如,英国首相官邸唐宁街10号正门所在位置对应的三个词语为slurs.this.shark[1]。据说还支持各种不同的语言,有兴趣的朋友可以看一下 wiki,并下载来试用一下,这个软件需要登录账号才能保存地理位置。

世界迷雾

世界迷雾大概就是把探索世界当成一个游戏,有等级,成就和迷雾护照的概念,你每探索一个新的地方,你脚下的地图颜色就会被点亮,然后记录一个探索的百分比。很有意思的一款软件,但是没有时间的概念,只有点亮和未点亮的区别。(让我想起了小时候玩 QQ 宠物也有类似小企鹅赛博旅游,点亮全国全世界地图)。

如果你使用世界迷雾,这里推荐两个辅助工具,fog machine 可以用来擦除修改和绘制足迹,也有时光机支持定时给迷雾定期保存快照,连起来播放之后就有点像塞尔达传说的足迹模式。

迷雾资料库 - Vicc,这个我没有怎么用过,据说可以导入国内的铁路轨迹,想要了解更多的可以去微信公众号搜索。

如果你觉得世界迷雾太贵了,还有平替 Mapcred一生足迹。Mapcred 我试过很费电,一生足迹没怎么用过,不做评价。

Rond

Rond 跟世界迷雾的理念不一样,他不会记录你的详细轨迹,而更像是我一开始说的那样,如果你在一个地方待了一段时间,它会标记这段时间和地点,在不同的标记时间段期间他还会根据时间、路程的变化,推测出之间的交通方式。

数据主要以两种形式展示,一是以时间轴的形式将你一天的形成串联起来,你还可以在一块时间段上标记你的心情(联动 Apple Health),你还可以记录笔记,打标签等等。

二是统计饼图,有日周月年的不同统计区间。有点像 Life Cycle

除了显示数据,它还可以像世界迷雾一样在地图上显示你去过的地方,只不过不是连续的轨迹,而是一个一个的图钉📌,一个图钉代表时间轴上的一个时间段。App 内还会统计你去过的所有国家/城市,以及各个城市的图钉数量热力图,它还支持根据不同的活动导出到不同的日历中。总之功能丰富,玩法很多,而且开发者非常 nice,更新勤快,回复反馈及时,非常推荐。

关于电量使用

两个软件都会要求始终获取 GPS,但是实测下来 fog of world 一天只会用掉 5% 的电量,当然你如果一直待在一个地方也可以把 fog of world 暂时关闭来省电。而 Rond 则更为省电,大概只有 1-2% 的电量消耗。

关于隐私数据安全

根据 App store 的描述,以上提到的所有软件,除了 what3words 可能是需要注册账号的原因,会有部分数据收集,其他的软件都标注不收集任何信息,所有数据都不会在服务端保存。

推荐阅读

[1]三词地址 - Wikipedia

[2]不用世界迷雾,还有这些工具来处理足迹

[3]App+1 | Rond 与世界迷雾:现实世界的塞尔达传说地图册