一、基础环境
012345678910111213141516 $ curl cip.ccIP : 35.206.235.142数据三 : 中国台湾省彰化县 | 谷歌$ uname -aLinux tw.t4x.org 6.8.0-1017-gcp #19-Ubuntu SMP Tue Oct 15 19:02:59 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux$ curl cip.ccIP : 35.207.210.15数据三 : 印度马哈拉施特拉孟买 | 谷歌$ uname -aLinux mumbai 5.10.0-33-cloud-amd64 #1 SMP Debian 5.10.226-1 (2024-10-03) x86_64 GNU/Linux$ curl cip.ccIP : 35.213.179.122数据三 : 新加坡 | 谷歌$ uname -aLinux singapore 6.1.0-27-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.115-1 (2024-11-01) x86_64 GNU/Linux
特别说明 : Netmaker的服务端有时候是用香港的Server,有时候用台湾的Server,安装方法不一样,一个是采用官方的快速安装,另外一个是采用docker-compose部署,但是基本操作方法是一样的.[自定义网段不同官方默认的100.64.0.0/16、docker-compose自定义网段是100.63.0.0/16] 文 章 源 自 note.t4x.orgByrd's Blog-https://note.t4x.org/basic/netmaker-manager-wireguard/
二、防火墙配置
2.0 基础配置
|
0 1 2 3 4 5 6 7 |
apt install firewalld -y systemctl start firewalld firewall-cmd --new-zone=personal firewall-cmd --permanent --new-zone=personal firewall-cmd --zone=personal --add-interface=netmaker firewall-cmd --permanent --zone=personal --add-interface=netmaker firewall-cmd --zone=personal --add-port=22/tcp firewall-cmd --set-default=personal |
2.1 必须配置
|
0 1 2 3 4 |
firewall-cmd --zone=personal --add-masquerade firewall-cmd --zone=personal --add-port=51820-51899/udp firewall-cmd --zone=personal --add-rich-rule="rule family="ipv4" source address="10.170.0.0/24" accept" firewall-cmd --zone=personal --add-rich-rule="rule family="ipv4" source address="10.170.0.0/24" masquerade" firewall-cmd --zone=personal --add-interface=ens4 |
2.2 非必须配置
|
0 1 2 3 4 5 6 |
firewall-cmd --zone=personal --add-port=53/udp firewall-cmd --zone=personal --add-port=53/tcp firewall-cmd --zone=personal --add-port=443/tcp firewall-cmd --zone=personal --add-port=80/tcp firewall-cmd --zone=personal --add-rich-rule="rule family="ipv4" source address="100.63.0.0/16" accept" firewall-cmd --zone=personal --add-rich-rule="rule family="ipv4" source address="100.63.0.0/16" masquerade" firewall-cmd --zone=personal --add-forward |
三、服务端部署tw
3.1 基础环境
012345678910111213 cat >> /etc/sysctl.conf <<BYRD# WireGuard configure startnet.ipv4.ip_forward = 1net.ipv4.conf.all.rp_filter=2net.ipv4.conf.all.proxy_arp = 1# WireGuard configure endBYRDsysctl -pcat /proc/sys/net/ipv4/ip_forwardcat /proc/sys/net/ipv4/conf/all/proxy_arp# sysctl -w net.ipv4.ip_forward=1# sysctl -w net.ipv4.conf.all.rp_filter=2# echo "1" > /proc/sys/net/ipv4/conf/all/proxy_arp# cat /proc/sys/net/ipv4/conf/all/proxy_arp
3.2 Centos
012 sudo dnf -y install dnf-plugins-coresudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.reposudo dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
3.3 ubuntu、debian
01234567891011 sudo apt-get update -ysudo apt-get install ca-certificates curl -ysudo install -m 0755 -d /etc/apt/keyringssudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.ascsudo chmod a+r /etc/apt/keyrings/docker.asc# Add the repository to Apt sources:echo \"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \sudo tee /etc/apt/sources.list.d/docker.list > /dev/nullsudo apt-get update
Login
3.4.4 nginx部署
文 章 源 自 note.t4x.orgByrd's Blog-https://note.t4x.org/basic/netmaker-manager-wireguard/
01234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 $ wget -O - https://openresty.org/package/pubkey.gpg | sudo gpg --dearmor -o /usr/share/keyrings/openresty.gpg$ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/openresty.gpg] http://openresty.org/package/ubuntu $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/openresty.list > /dev/null$ sudo apt-get update$ sudo apt-get -y install openresty$ egrep -v "^$|#" /usr/local/openresty/nginx/conf/nginx.confworker_processes 1;events {worker_connections 1024;}http {include mime.types;default_type application/octet-stream;sendfile on;keepalive_timeout 65;server {listen 80;server_name localhost;location / {root html;index index.html index.htm;}error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}}server {listen 443 ssl;server_name dashboard.network.t4x.org;ssl_certificate certificate/fullchain.cer;ssl_certificate_key certificate/cert.key;ssl_session_cache shared:SSL:1m;ssl_session_timeout 5m;ssl_ciphers HIGH:!aNULL:!MD5;ssl_prefer_server_ciphers on;location / {proxy_set_header X-Forwarded-Host $host;proxy_set_header X-Forwarded-Server $host;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_pass http://127.0.0.1:8082;proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection "Upgrade";}}server {listen 443 ssl;server_name api.network.t4x.org;ssl_certificate certificate/fullchain.cer;ssl_certificate_key certificate/cert.key;ssl_session_cache shared:SSL:1m;ssl_session_timeout 5m;ssl_ciphers HIGH:!aNULL:!MD5;ssl_prefer_server_ciphers on;location / {proxy_set_header X-Forwarded-Host $host;proxy_set_header X-Forwarded-Server $host;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_pass http://127.0.0.1:8081;proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection "Upgrade";}}server {listen 443 ssl;server_name grpc.network.t4x.org;ssl_certificate certificate/fullchain.cer;ssl_certificate_key certificate/cert.key;ssl_session_cache shared:SSL:1m;ssl_session_timeout 5m;ssl_ciphers HIGH:!aNULL:!MD5;ssl_prefer_server_ciphers on;location / {proxy_set_header X-Forwarded-Host $host;proxy_set_header X-Forwarded-Server $host;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_pass http://127.0.0.1:8083;proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection "Upgrade";}}}
四、节点接入mumbai
文 章 源 自 note.t4x.orgByrd's Blog-https://note.t4x.org/basic/netmaker-manager-wireguard/
01 wget -O netclient https://fileserver.netmaker.io/releases/download/v0.26.0/netclient-linux-amd64 && chmod +x ./netclient && mv netclient /usr/bin/netclient && sudo netclient installnetclient join -t eyJzZXJ2ZXIiOiJhcGkucGVyc29uYWwubmV0d29yay52Zy50NHgub3JnIiwidmFsdWUiOiJDQTNUUU5VWFRBR0JVVUVBRDUzNTNHTkhCUENFNlpLTSJ9
五、连通验证
5.1 windows客户端[河北]
0123456789101112131415161718192021222324252627282930313233343536373839 C:\Windows\System32>netclient join -t eyJzZXJ2ZXIiOiJhcGkucGVyc29uYWwubmV0d29yay52Zy50NHgub3JnIiwidmFsdWUiOiJSRzNZUTVaQVhMRlA0UkdZREk2Uk5QRklON1pSUFJPVCJ9setting host fields{"time":"2024-11-23T14:19:35.8615368+08:00","level":"ERROR","source":"daemon.go 424}","msg":"unable to connect to broker","server":"wss://broker.nm.35-206-235-142.nip.io","error":"connect timeout"}WARNING: Joining any network on another server will disconnect netclient from the networks of the current server -> nm.35-206-235-142.nip.ioregistered with serverC:\Windows\System32>tracert 100.63.0.1通过最多 30 个跃点跟踪到 100.63.0.1 的路由1 51 ms 50 ms 51 ms 100.63.0.1跟踪完成。C:\Windows\System32>ping 100.63.0.1 #台湾服务器正在 Ping 100.63.0.1 具有 32 字节的数据:来自 100.63.0.1 的回复: 字节=32 时间=1143ms TTL=64来自 100.63.0.1 的回复: 字节=32 时间=54ms TTL=64来自 100.63.0.1 的回复: 字节=32 时间=52ms TTL=64来自 100.63.0.1 的回复: 字节=32 时间=51ms TTL=64C:\Windows\System32>ping 100.63.0.3 #新加坡服务器正在 Ping 100.63.0.3 具有 32 字节的数据:来自 100.63.0.3 的回复: 字节=32 时间=203ms TTL=64来自 100.63.0.3 的回复: 字节=32 时间=205ms TTL=64来自 100.63.0.3 的回复: 字节=32 时间=203ms TTL=64来自 100.63.0.3 的回复: 字节=32 时间=203ms TTL=64C:\Windows\System32>wginterface: netmakerpublic key: fzOHq2WPjzYIBw7pX/rv4OE7GqDE07QOOKMvOOF4u00=private key: (hidden)listening port: 51821peer: nS5+/qajqCVlsn0euvnKTBks7zLV5MDmbV9t0b0lJiQ=endpoint: 35.213.179.122:51821allowed ips: 100.63.0.3/32latest handshake: 3 seconds agotransfer: 124 B received, 476 B sentpersistent keepalive: every 20 secondspeer: WIB3JASnLHpxbDXzTAKlNeNbkJ7l0wTqArofcJMQ2hQ=endpoint: 35.206.235.142:51821allowed ips: 100.63.0.1/32latest handshake: 9 seconds agotransfer: 508 B received, 712 B sentpersistent keepalive: every 20 seconds
5.2 ubuntu客户端[新加坡]
012345678910111213141516171819202122 $ netclient join -t eyJzZXJ2ZXIiOiJhcGkucGVyc29uYWwubmV0d29yay52Zy50NHgub3JnIiwidmFsdWUiOiJSRzNZUTVaQVhMRlA0UkdZREk2Uk5QRklON1pSUFJPVCJ9setting host fieldsWARNING: Joining any network on another server will disconnect netclient from the networks of the current server -> nm.35-206-235-142.nip.ioregistered with server$ wginterface: netmakerpublic key: nS5+/qajqCVlsn0euvnKTBks7zLV5MDmbV9t0b0lJiQ=private key: (hidden)listening port: 51821peer: WIB3JASnLHpxbDXzTAKlNeNbkJ7l0wTqArofcJMQ2hQ=endpoint: 10.140.0.3:51821allowed ips: 100.63.0.1/32latest handshake: 29 seconds agotransfer: 956 B received, 1020 B sentpersistent keepalive: every 20 secondspeer: fzOHq2WPjzYIBw7pX/rv4OE7GqDE07QOOKMvOOF4u00=endpoint: x.x.x.x:22628allowed ips: 100.63.0.2/32latest handshake: 35 seconds agotransfer: 212 B received, 272 B sentpersistent keepalive: every 20 seconds
5.3 netmaker服务端[台湾]
[crayon-6917a4bf2bbc0578708544/] 文 章 源 自 note.t4x.orgByrd's Blog-https://note.t4x.org/basic/netmaker-manager-wireguard/
六、官方快速安装方案
[crayon-6917a4bf2bbc1079139071/] 文 章 源 自 note.t4x.orgByrd's Blog-https://note.t4x.org/basic/netmaker-manager-wireguard/
参考文档:
0:https://docs.netmaker.io/docs/server-installation/advanced-options
1:https://docs.docker.com/engine/install/ubuntu/
2:https://mrdoc.fun/doc/587/
3:https://ewhisper.cn/posts/13793/
4:https://icloudnative.io/posts/configure-a-mesh-network-with-netmaker/
5:https://docs.netmaker.io/docs/upgrades文 章 源 自 note.t4x.orgByrd's Blog-https://note.t4x.org/basic/netmaker-manager-wireguard/
文 章 源 自 note.t4x.orgByrd's Blog-https://note.t4x.org/basic/netmaker-manager-wireguard/
申明:除非注明Byrd's Blog内容均为原创,未经许可禁止转载!详情请阅读版权申明!
