wgmtu.sh 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. #!/bin/bash
  2. # 定义文字颜色
  3. Green="\033[32m" && Red="\033[31m" && GreenBG="\033[42;37m" && RedBG="\033[41;37m" && Font="\033[0m"
  4. # 修改mtu数值
  5. setmtu(){
  6. echo -e "${GreenBG}WireGuard 修改服务器端MTU值,最大效率加大网速,默认值 MTU = 1420 "
  7. echo -e "WireGuard 客户端可以MTU参数自动,请修改电脑客户端TunSafe配置把MTU行注释掉。${Font}"
  8. read -p "请输入数字(1200--1500): " num
  9. if [[ ${num} -ge 1200 ]] && [[ ${num} -le 1500 ]]; then
  10. mtu=$num
  11. else
  12. mtu=1420
  13. fi
  14. wg-quick down wg0
  15. sed -i "s/MTU = .*$/MTU = ${mtu}/g" /etc/wireguard/wg0.conf
  16. wg-quick up wg0
  17. echo -e "${RedBG} 服务器端MTU值已经修改! ${Font}"
  18. }
  19. # 修改端口号
  20. setport(){
  21. echo -e "${GreenBG}修改 WireGuard 服务器端端口号,客户端要自行修改${Font}"
  22. read -p "请输入数字(100--60000): " num
  23. if [[ ${num} -ge 100 ]] && [[ ${num} -le 60000 ]]; then
  24. port=$num
  25. wg-quick down wg0
  26. sed -i "s/ListenPort = .*$/ListenPort = ${port}/g" /etc/wireguard/wg0.conf
  27. wg-quick up wg0
  28. echo -e "${RedBG} 端口号已经修改! ${Font}"
  29. else
  30. echo -e "${RedBG} 没有修改端口号! ${Font}"
  31. fi
  32. }
  33. # 显示手机客户端二维码
  34. wgconf()
  35. {
  36. echo -e "${RedBG}:: 显示手机客户端二维码 (如改端口,请先菜单5重置客户端配置) ${Font}"
  37. read -p "请输入数字(2-9),默认2号: " x
  38. if [[ ${x} -ge 2 ]] && [[ ${x} -le 9 ]]; then
  39. i=$x
  40. else
  41. i=2
  42. fi
  43. host=$(hostname -s)
  44. cat /etc/wireguard/wg_${host}_$i.conf | qrencode -o - -t UTF8
  45. echo -e "${GreenBG}:: 配置文件: wg_${host}_$i.conf 生成二维码,请用手机客户端扫描使用 ${Font}"
  46. echo -e "${RedBG}SSH工具推荐Git-Bash 2.20; GCP_SSH(浏览器)字体Courier New 二维码正常${Font}"
  47. }
  48. # 重置 WireGuard 客户端配置和数量
  49. wg_clients()
  50. {
  51. echo -e "${RedBG}:: 注意原来的客户端配置都会删除,按 Ctrl+ C 可以紧急撤销 ${Font}"
  52. read -p "请任意键继续:" xx
  53. wget -O ~/wg100 https://git.io/fp6r0 >/dev/null 2>&1
  54. bash ~/wg100
  55. }
  56. # 安装Udp2Raw服务TCP伪装,加速功能
  57. ss_kcp_udp2raw_wg_speed()
  58. {
  59. # 一键安装 SS+Kcp+Udp2Raw 脚本 快速安装 for debian 9
  60. wget -qO- git.io/fpZIW | bash
  61. wget -O ~/ss_wg_set_raw https://git.io/fpKnF >/dev/null 2>&1
  62. bash ~/ss_wg_set_raw
  63. rm ~/ss_wg_set_raw
  64. }
  65. # 主菜单输入数字 88
  66. # 隐藏功能:从源VPS克隆服务端配置,共用客户端配置
  67. scp_conf()
  68. {
  69. echo -e "${RedBG}:: 警告: 警告: 警告: VPS服务器已经被GFW防火墙关照,按 Ctrl+ C 可以紧急逃离! ${Font}"
  70. echo "隐藏功能:从源VPS克隆服务端配置,共用客户端配置"
  71. read -p "请输入源VPS的IP地址(域名):" vps_ip
  72. cmd="scp root@${vps_ip}:/etc/wireguard/* /etc/wireguard/. "
  73. echo -e "${GreenBG}# ${cmd} ${Font} 现在运行scp命令,按提示输入yes,源vps的root密码"
  74. ${cmd}
  75. wg-quick down wg0 >/dev/null 2>&1
  76. wg-quick up wg0 >/dev/null 2>&1
  77. echo -e "${RedBG} 我真不知道WG服务器端是否已经使用源vps的配置启动! ${Font}"
  78. }
  79. # 主菜单输入数字 188 隐藏功能: 一键全家桶
  80. onekey_plus()
  81. {
  82. echo -e "${RedBG} 一键安装设置全家桶 by 蘭雅sRGB ${Font}"
  83. cat <<EOF
  84. # Google Cloud Platform GCP实例开启密码与root用户登陆
  85. wget -qO- git.io/fpQWf | bash
  86. # 一键安装 vnstat 流量检测 by 蘭雅sRGB
  87. wget -qO- git.io/fxxlb | bash
  88. # 一键安装wireguard 脚本 Debian 9 (源:逗比网安装笔记)
  89. wget -qO- git.io/fptwc | bash
  90. # 一键 WireGuard 多用户配置共享脚本 by 蘭雅sRGB
  91. wget -qO- https://git.io/fpnQt | bash
  92. # 一键安装 SS+Kcp+Udp2Raw 脚本 快速安装 for Debian 9
  93. wget -qO- git.io/fpZIW | bash
  94. # 一键安装 SS+Kcp+Udp2Raw 脚本 for Debian 9 Ubuntu (编译安装)
  95. wget -qO- git.io/fx6UQ | bash
  96. # Telegram 代理 MTProxy Go版 一键脚本(源:逗比网)
  97. wget -qO mtproxy_go.sh git.io/fpWo4 && bash mtproxy_go.sh
  98. # linux下golang环境搭建自动脚本 by 蘭雅sRGB
  99. wget -qO- https://git.io/fp4jf | bash
  100. # SuperBench.sh 一键测试服务器的基本参数
  101. wget -qO- git.io/superbench.sh | bash
  102. # 使用BestTrace查看VPS的去程和回程
  103. wget -qO- git.io/fp5lf | bash
  104. # qrencode 生成二维码 -o- 参数显示在屏幕 -t utf8 文本格式
  105. cat wg_vultr_5.conf | qrencode -o- -t utf8
  106. EOF
  107. echo -e "${GreenBG} 开源项目:https://github.com/hongwenjun/vps_setup ${Font}"
  108. }
  109. # 更新wgmtu脚本
  110. update()
  111. {
  112. # 安装 bash wgmtu 脚本用来设置服务器
  113. wget -O ~/wgmtu https://raw.githubusercontent.com/hongwenjun/vps_setup/master/Wireguard/wgmtu.sh >/dev/null 2>&1
  114. }
  115. # 设置菜单
  116. start_menu(){
  117. echo -e "${RedBG} 一键安装 WireGuard 脚本 For Debian_9 Ubuntu Centos_7 ${Font}"
  118. echo -e "${GreenBG} 开源项目:https://github.com/hongwenjun/vps_setup ${Font}"
  119. echo -e "${Green}> 1. 显示手机客户端二维码"
  120. echo -e "> 2. 修改 WireGuard 服务器端 MTU 值"
  121. echo -e "> 3. 修改 WireGuard 端口号 (如改端口,菜单5重置客户端配置)"
  122. echo -e "> 4. 安装WireGuard + Speeder + Udp2Raw 和 Shadowsocks + Kcp + Udp2RAW 一键脚本"
  123. echo -e "> 5. 重置 WireGuard 客户端配置和数量,方便修改过端口或者机场大佬"
  124. echo -e "> 6. 退出设置${Font}"
  125. echo
  126. read -p "请输入数字(1-6):" num
  127. case "$num" in
  128. 1)
  129. wgconf
  130. ;;
  131. 2)
  132. setmtu
  133. ;;
  134. 3)
  135. setport
  136. ;;
  137. 4)
  138. ss_kcp_udp2raw_wg_speed
  139. ;;
  140. 5)
  141. wg_clients
  142. ;;
  143. 6)
  144. update
  145. exit 1
  146. ;;
  147. 88)
  148. scp_conf
  149. ;;
  150. 188)
  151. onekey_plus
  152. ;;
  153. *)
  154. echo
  155. echo "请输入正确数字"
  156. ;;
  157. esac
  158. }
  159. start_menu