From 7299c0e761b4e11a8ee43410cb02adc50e33dca1 Mon Sep 17 00:00:00 2001 From: bjdgyc Date: Mon, 28 Nov 2022 12:18:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=BB=98=E8=AE=A4=E7=BD=91?= =?UTF-8?q?=E6=AE=B5=EF=BC=8C=E9=98=B2=E6=AD=A2=E7=94=A8=E6=88=B7=E5=86=B2?= =?UTF-8?q?=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 49 ++++++++-------------------------- server/base/config.go | 10 +++---- server/conf/server-sample.toml | 8 +++--- server/conf/server.toml | 8 +++--- 4 files changed, 24 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index bd9e3b2..c57a7e1 100644 --- a/README.md +++ b/README.md @@ -159,9 +159,9 @@ systemctl stop firewalld.service systemctl disable firewalld.service # 请根据服务器内网网卡替换 eth0 -iptables -t nat -A POSTROUTING -s 192.168.10.0/24 -o eth0 -j MASQUERADE +iptables -t nat -A POSTROUTING -s 192.168.90.0/24 -o eth0 -j MASQUERADE # 如果执行第一个命令不生效,可以继续执行下面的命令 -# iptables -A FORWARD -i eth0 -s 192.168.10.0/24 -j ACCEPT +# iptables -A FORWARD -i eth0 -s 192.168.90.0/24 -j ACCEPT # 查看设置是否生效 iptables -nL -t nat ``` @@ -169,17 +169,17 @@ iptables -nL -t nat 2.2 使用全局路由转发(二选一) ```shell -# 假设anylink所在服务器的内网ip: 10.1.0.10 +# 假设anylink所在服务器的内网ip: 10.1.2.10 # 传统网络架构,在华三交换机添加以下静态路由规则 -ip route-static 192.168.10.0 255.255.255.0 10.1.0.10 +ip route-static 192.168.90.0 255.255.255.0 10.1.2.10 # 其他品牌的交换机命令,请参考以下地址 https://cloud.tencent.com/document/product/216/62007 # 公有云环境下,需设置vpc下的路由表,添加以下路由策略 -目的端: 192.168.10.0/24 +目的端: 192.168.90.0/24 下一跳类型: 云服务器 -下一跳: 10.1.0.10 +下一跳: 10.1.2.10 ``` @@ -197,46 +197,19 @@ https://cloud.tencent.com/document/product/216/62007 #内网主网卡名称 ipv4_master = "eth0" #以下网段需要跟ipv4_master网卡设置成一样 -ipv4_cidr = "192.168.10.0/24" -ipv4_gateway = "192.168.10.1" -ipv4_start = "192.168.10.100" -ipv4_end = "192.168.10.200" +ipv4_cidr = "10.1.2.0/24" +ipv4_gateway = "10.1.2.1" +ipv4_start = "10.1.2.100" +ipv4_end = "10.1.2.200" ``` -
-tap设置 - -### ~~tap 设置~~ - -1. 创建桥接网卡 - -``` -注意 server.toml 的ip参数,需要与 bridge-init.sh 的配置参数一致 -``` - -2. 修改 bridge-init.sh 内的参数 - -> 以下参数可以通过执行 `ip a` 查看 - -``` -eth="eth0" -eth_ip="192.168.10.4/24" -eth_broadcast="192.168.10.255" -eth_gateway="192.168.10.1" -``` - -3. 执行 bridge-init.sh 文件 - -``` -sh bridge-init.sh -``` -
## Systemd 1. 添加 anylink 程序 - anylink 程序目录放入 `/usr/local/anylink-deploy` + - 添加执行权限 `chmod +x /usr/local/anylink-deploy/anylink` 2. systemd/anylink.service 脚本放入: diff --git a/server/base/config.go b/server/base/config.go index 739e4f1..fef5f85 100644 --- a/server/base/config.go +++ b/server/base/config.go @@ -41,15 +41,15 @@ var configs = []config{ {Typ: cfgStr, Name: "jwt_secret", Usage: "JWT密钥", ValStr: defaultJwt}, {Typ: cfgStr, Name: "link_mode", Usage: "虚拟网络类型[tun tap macvtap ipvtap]", ValStr: "tun"}, {Typ: cfgStr, Name: "ipv4_master", Usage: "ipv4主网卡名称", ValStr: "eth0"}, - {Typ: cfgStr, Name: "ipv4_cidr", Usage: "ip地址网段", ValStr: "192.168.10.0/24"}, - {Typ: cfgStr, Name: "ipv4_gateway", Usage: "ipv4_gateway", ValStr: "192.168.10.1"}, - {Typ: cfgStr, Name: "ipv4_start", Usage: "IPV4开始地址", ValStr: "192.168.10.100"}, - {Typ: cfgStr, Name: "ipv4_end", Usage: "IPV4结束", ValStr: "192.168.10.200"}, + {Typ: cfgStr, Name: "ipv4_cidr", Usage: "ip地址网段", ValStr: "192.168.90.0/24"}, + {Typ: cfgStr, Name: "ipv4_gateway", Usage: "ipv4_gateway", ValStr: "192.168.90.1"}, + {Typ: cfgStr, Name: "ipv4_start", Usage: "IPV4开始地址", ValStr: "192.168.90.100"}, + {Typ: cfgStr, Name: "ipv4_end", Usage: "IPV4结束", ValStr: "192.168.90.200"}, {Typ: cfgStr, Name: "default_group", Usage: "默认用户组", ValStr: "one"}, {Typ: cfgStr, Name: "default_domain", Usage: "要发布的默认域", ValStr: ""}, {Typ: cfgInt, Name: "ip_lease", Usage: "IP租期(秒)", ValInt: 1209600}, - {Typ: cfgInt, Name: "max_client", Usage: "最大用户连接", ValInt: 100}, + {Typ: cfgInt, Name: "max_client", Usage: "最大用户连接", ValInt: 200}, {Typ: cfgInt, Name: "max_user_client", Usage: "最大单用户连接", ValInt: 3}, {Typ: cfgInt, Name: "cstp_keepalive", Usage: "keepalive时间(秒)", ValInt: 9}, {Typ: cfgInt, Name: "cstp_dpd", Usage: "死链接检测时间(秒)", ValInt: 15}, diff --git a/server/conf/server-sample.toml b/server/conf/server-sample.toml index b9ccd06..d852541 100644 --- a/server/conf/server-sample.toml +++ b/server/conf/server-sample.toml @@ -40,10 +40,10 @@ link_mode = "tun" #客户端分配的ip地址池 ipv4_master = "eth0" -ipv4_cidr = "192.168.10.0/24" -ipv4_gateway = "192.168.10.1" -ipv4_start = "192.168.10.100" -ipv4_end = "192.168.10.200" +ipv4_cidr = "192.168.90.0/24" +ipv4_gateway = "192.168.90.1" +ipv4_start = "192.168.90.100" +ipv4_end = "192.168.90.200" #最大客户端数量 max_client = 100 diff --git a/server/conf/server.toml b/server/conf/server.toml index e7f274b..5bc31c2 100644 --- a/server/conf/server.toml +++ b/server/conf/server.toml @@ -28,10 +28,10 @@ admin_addr = ":8800" #客户端分配的ip地址池 ipv4_master = "eth0" -ipv4_cidr = "192.168.10.0/24" -ipv4_gateway = "192.168.10.1" -ipv4_start = "192.168.10.100" -ipv4_end = "192.168.10.200" +ipv4_cidr = "192.168.90.0/24" +ipv4_gateway = "192.168.90.1" +ipv4_start = "192.168.90.100" +ipv4_end = "192.168.90.200" #是否自动添加nat iptables_nat = false