{"id":18702538,"url":"https://github.com/mayocream/tun-container","last_synced_at":"2025-11-09T01:30:34.737Z","repository":{"id":103330491,"uuid":"411105726","full_name":"mayocream/tun-container","owner":"mayocream","description":null,"archived":false,"fork":false,"pushed_at":"2021-10-29T05:43:05.000Z","size":80,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-15T11:37:29.824Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mayocream.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-28T02:08:52.000Z","updated_at":"2021-10-29T05:43:08.000Z","dependencies_parsed_at":"2023-06-02T12:15:53.331Z","dependency_job_id":null,"html_url":"https://github.com/mayocream/tun-container","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mayocream%2Ftun-container","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mayocream%2Ftun-container/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mayocream%2Ftun-container/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mayocream%2Ftun-container/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mayocream","download_url":"https://codeload.github.com/mayocream/tun-container/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239565644,"owners_count":19660154,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T11:46:11.227Z","updated_at":"2025-11-09T01:30:34.701Z","avatar_url":"https://github.com/mayocream.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tun-container\n\n## TUN\n\n基于 wireguard 的网络库实现。\n\nTODO:\n\n- [] 转发 DNS 请求\n- [] 解析 DNS UDP 包\n- [] 内网流量转发\n- [] 解析来源 IP\n\n## Route\n\n基于源策略的路由。\n\nref: https://superuser.com/questions/376667/how-to-route-only-specific-subnet-source-ip-to-a-particular-interface\n\n```bash\nip rule add from \u003csource\u003e/\u003cmask\u003e table \u003cname\u003e\nip route add 1.2.3.4/24 via \u003crouter\u003e dev eth4 table \u003cname\u003e\n```\n\n## Docker\n\n创建 Docker 网络：\n\n- **MacVlan**:\n\n    创建 MacVlan 网络，二层设备流量转发，相比于 Bridge 模式性能更好。\n\n    ```bash\n    sudo docker network create -d network --gateway 192.168.10.1 --subnet 192.168.10.0/24 tunnet\n    ```\n\n- **Bridge**:\n\n    Bridge 网络，Docker 的默认网络模式。\n\n    ```bash\n    sudo docker network create --gateway 192.168.20.1 --subnet 192.168.20.0/24 tunnet\n    ```\n\n删除 Docker network：\n\n```bash\nsudo docker network rm tunnet\n```\n\n## Debug\n\n```bash\n# 指定 Docker 网络\nsudo docker run --rm -it --network tunnet golang:1.16\n# 指定 IP 地址\nsudo docker run --rm -it --network tunnet --ip 192.168.20.3 golang:1.16\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmayocream%2Ftun-container","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmayocream%2Ftun-container","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmayocream%2Ftun-container/lists"}