taubyte-hosts-file-editor
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseHosts File Editor
Hosts文件编辑器
When to use
使用场景
Use this skill when:
- the user wants to open Dream resources by hostname in browser
- local domains need to resolve on the current machine
*.localtau - curl tests should avoid manual headers
Host
在以下场景使用该技能:
- 用户希望在浏览器中通过主机名打开Dream资源
- 当前机器需要解析本地域名
*.localtau - curl测试需避免手动设置请求头
Host
Inputs
输入项
- One or more FQDNs (for example )
abc123.default.localtau - Target IP (default for Dream local)
127.0.0.1 - OS (,
windows, orlinux)macos
- 一个或多个FQDN(例如 )
abc123.default.localtau - 目标IP(Dream本地环境默认值为 )
127.0.0.1 - 操作系统(、
windows或linux)macos
Hosts file paths
Hosts文件路径
- Windows:
C:\Windows\System32\drivers\etc\hosts - Linux/macOS:
/etc/hosts
- Windows:
C:\Windows\System32\drivers\etc\hosts - Linux/macOS:
/etc/hosts
Procedure
操作步骤
- Validate each FQDN before writing:
- non-empty
- no scheme/path/port
- no duplicates
- Read current hosts file.
- Ensure a section marker exists:
# Taubyte Local Domains
- For each FQDN, ensure exactly one mapping line:
127.0.0.1 <fqdn>
- If an entry exists with a different IP, update it to target IP.
- Preserve unrelated lines and comments.
- Write changes with elevated permissions.
- If elevation fails, provide exact manual steps and content to append.
- 写入前验证每个FQDN:
- 非空
- 不包含协议/路径/端口
- 无重复项
- 读取当前hosts文件。
- 确保存在分段标记:
# Taubyte Local Domains
- 为每个FQDN确保仅有一条映射行:
127.0.0.1 <fqdn>
- 如果存在IP不同的条目,将其更新为目标IP。
- 保留无关的行和注释。
- 使用提升的权限写入更改。
- 如果提权失败,提供精确的手动步骤和要追加的内容。
Automation policy
自动化策略
- Always attempt automatic update first (idempotent write, no duplicates).
- On Windows, try elevated write path first; if blocked, switch to manual fallback immediately with exact lines.
- After update attempt (success or fallback), run verification curl checks so execution can continue.
- 始终优先尝试自动更新(幂等写入,无重复项)。
- 在Windows系统上,优先尝试提权写入路径;如果被阻止,立即切换到手动回退方案并提供精确的行内容。
- 更新尝试后(无论成功还是回退),运行curl验证检查,以便执行流程可以继续。
Safety rules
安全规则
- Never remove unrelated host mappings.
- Never add URL prefixes such as or
http://.https:// - Never include ports/paths in hosts file lines.
- Prefer idempotent updates (re-running should not duplicate entries).
- 永远不要删除无关的hosts映射。
- 永远不要添加或
http://等URL前缀。https:// - 永远不要在hosts文件行中包含端口/路径。
- 优先使用幂等更新(重复执行不应产生重复条目)。
Verification
验证步骤
Run at least one check after edits:
bash
curl "http://<fqdn>:<port>/"Or verify direct routing without hosts dependency:
bash
curl --resolve "<fqdn>:<port>:127.0.0.1" "http://<fqdn>:<port>/"If using browser, open:
text
http://<fqdn>:<port>/编辑后至少运行一项检查:
bash
curl "http://<fqdn>:<port>/"或者验证不依赖hosts的直接路由:
bash
curl --resolve "<fqdn>:<port>:127.0.0.1" "http://<fqdn>:<port>/"如果使用浏览器,打开:
text
http://<fqdn>:<port>/Windows manual fallback (if no elevation)
Windows手动回退方案(无法提权时)
- Open Notepad as Administrator.
- Open (All Files filter).
C:\Windows\System32\drivers\etc\hosts - Append:
# Taubyte Local Domains127.0.0.1 <fqdn>- (repeat one line per FQDN)
- Save.
- 以管理员身份打开记事本。
- 打开 (选择“所有文件”筛选器)。
C:\Windows\System32\drivers\etc\hosts - 追加以下内容:
# Taubyte Local Domains127.0.0.1 <fqdn>- (每个FQDN对应一行)
- 保存文件。