Guest User

Untitled

a guest
Feb 4th, 2020
639
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.75 KB | None | 0 0
  1. #!/bin/bash
  2. function Welcome()
  3. {
  4. clear
  5. if [[ $EUID -ne 0 ]]; then
  6. echo "Error:This script must be run as root!" 1>&2
  7. exit 1
  8. fi
  9. clear
  10. echo -n " Local Time : " && date "+%F [%T] ";
  11. echo " ======================================================";
  12. echo " | OpenConnect(ocserv) |";
  13. echo " | |";
  14. echo " | for Debian |";
  15. echo " |----------------------------------------------------|";
  16. echo " | -- By MoeClub.org(Vicer) |";
  17. echo " ======================================================";
  18. echo;
  19. }
  20.  
  21. function pause()
  22. {
  23. echo;
  24. read -n 1 -p "Press Enter to Continue..." INP
  25. if [ "$INP" != '' ] ; then
  26. echo -ne '\b \n'
  27. echo;
  28. fi
  29. }
  30.  
  31. function ETHER()
  32. {
  33. sysBits=x$(getconf LONG_BIT);
  34. ifname=`cat /proc/net/dev | awk -F: 'function trim(str){sub(/^[ \t]*/,"",str); sub(/[ \t]*$/,"",str); return str } NR>2 {print trim($1)}' | grep -Ev '^lo|^sit|^stf|^gif|^dummy|^vmnet|^vir|^gre|^ipip|^ppp|^bond|^tun|^tap|^ip6gre|^ip6tnl|^teql' | awk 'NR==1 {print $0}'`
  35. }
  36.  
  37. function OWNNET()
  38. {
  39. echo -ne "\nSelect a IP Address from \e[33m[\e[32m0\e[0m.\e[35m${MACIP}\e[33m/\e[33m1\e[0m.\e[35m${PublicIP}\e[33m]\e[0m. \nIt will be regard as default IP Address: "
  40. read OWNNETIP
  41. if [ -n "$OWNNETIP" ]; then
  42. if [ "$OWNNETIP" == '0' ]; then
  43. DefaultIP="${MACIP}"
  44. elif [ "$OWNNETIP" == '1' ]; then
  45. DefaultIP="${PublicIP}"
  46. else
  47. OWNNET;
  48. fi
  49. else
  50. DefaultIP="${MACIP}"
  51. fi
  52. }
  53.  
  54. function ServerIP()
  55. {
  56. PublicIP="$(wget -qO- checkip.amazonaws.com)"
  57. echo -ne "Default Server IP: \e[36m${PublicIP}\e[0m .\nIf Default Server IP \e[31mcorrect\e[0m, Press Enter .\nIf Default Server IP \e[31mincorrect\e[0m, Please input Server IP :"
  58. read iptmp
  59. if [[ -n "$iptmp" ]]; then
  60. PublicIP=$iptmp
  61. fi
  62. sysBits=x$(getconf LONG_BIT);
  63. ifname=`cat /proc/net/dev | awk -F: 'function trim(str){sub(/^[ \t]*/,"",str); sub(/[ \t]*$/,"",str); return str } NR>2 {print trim($1)}' | grep -Ev '^lo|^sit|^stf|^gif|^dummy|^vmnet|^vir|^gre|^ipip|^ppp|^bond|^tun|^tap|^ip6gre|^ip6tnl|^teql' | awk 'NR==1 {print $0}'`;
  64. echo -n $ifname |grep -q 'venet';
  65. [ $? -eq '0' ] && oVZ='y' || oVZ='n';
  66. MACIP="$(ifconfig $ifname |awk -F ':' '/inet addr/{ print $2}' |grep -o '[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}')";
  67. [ "${PublicIP}" != "${MACIP}" ] && OWNNET
  68. [ "${PublicIP}" == "${MACIP}" ] && DefaultIP="${PublicIP}";
  69. echo -ne "Server IP: \e[35m${DefaultIP}\e[0m .\n";
  70. MyDomain="${PublicIP}"
  71. echo -ne "\nIf you \e[31mdo not have\e[0m a domain name, \e[33mPress Enter\e[0m! \nIf you \e[31mhave\e[0m a domain name, Please \e[32mInput your domain name\e[0m :"
  72. read DomainTMP
  73. if [[ -n "$DomainTMP" ]]; then
  74. MyDomain=$DomainTMP
  75. echo -ne "Domain name: \e[35m$MyDomain\e[0m .\n"
  76. fi
  77. DOMAIN=`echo "$MyDomain" |awk -F"[.]" '{print $(NF-1)"."$NF}'`
  78. echo "$DOMAIN" |grep -q '[0-9]\{1,3\}.[0-9]\{1,3\}'
  79. [ $? -eq '0' ] && DOMAIN='' || echo -ne "\nPlease put your \e[33mdomain certificate\e[0m and \e[33mprivate key\e[0m into \e[33m/etc/ocserv\e[0m when the shell script install finish! \n\e[31mrename\e[0m \e[33mcertificate\e[0m with \e[32mserver.cert.pem\e[0m\n\e[31mrename\e[0m \e[33mprivate key\e[0m with \e[32mserver.key.pem\e[0m\n"
  80. [ $oVZ == 'n' ] && {
  81. echo -ne "\nIt will install \e[35mocserv\e[0m automaticly."
  82. }
  83. pause;
  84. }
  85.  
  86. function Ask_ocserv_port()
  87. {
  88. echo -ne "\n\e[35mInstall OpenConnect...\e[0m\n"
  89. SSLTCP=443;
  90. SSLUDP=443;
  91. echo -ne "\n\e[35mPlease enter AnyConnet port\e[33m[Default:\e[32m443\e[33m]\e[0m: "
  92. read myPORT
  93. if [[ -n "$myPORT" ]]; then
  94. SSLTCP=$myPORT
  95. SSLUDP=$myPORT
  96. fi
  97. }
  98.  
  99. function Ask_ocserv_type()
  100. {
  101. echo -ne "\n\e[35mPlease select a type to login AnyConnet.\e[33m[\e[33m0\e[0m.\e[35mcertificate\e[33m/\e[32m1\e[0m.\e[35mpassword\e[33m]\e[0m: "
  102. read logintype
  103. if [ -n "$logintype" ]; then
  104. if [ "$logintype" == '0' ]; then
  105. MyType='certificate'
  106. elif [ "$logintype" == '1' ]; then
  107. MyType='password'
  108. else
  109. Ask_ocserv_type;
  110. fi
  111. else
  112. MyType='password'
  113. fi
  114. }
  115.  
  116. function Ask_ocserv_password()
  117. {
  118. [ $MyType == 'certificate' ] && {
  119. FILL1='CANAME'
  120. FILL2='ORGANIZATION'
  121. }
  122. [ $MyType == 'password' ] && {
  123. FILL1='UserName'
  124. FILL2='PassWord'
  125. }
  126. [ -n "$FILL1" -a -n "$FILL2" ] && {
  127. FILLIT1='MoeClub.org'
  128. echo -ne "\n\e[35mPlease input AnyConnet $FILL1\e[33m[Default:\e[32mMoeClub.org\e[33m]\e[0m: "
  129. read tmpFILL1
  130. if [[ -n "$tmpFILL1" ]]; then
  131. FILLIT1=$tmpFILL1
  132. fi
  133. FILLIT2='Vicer'
  134. echo -ne "\n\e[35mPlease input AnyConnet $FILL2\e[33m[Default:\e[32mVicer\e[33m]\e[0m: "
  135. read tmpFILL2
  136. if [[ -n "$tmpFILL2" ]]; then
  137. FILLIT2=$tmpFILL2
  138. fi
  139. }
  140. }
  141.  
  142. function SYSCONF()
  143. {
  144. sed -i '/net.ipv4.ip_forward/d' /etc/sysctl.conf
  145. echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
  146. sed -i '/net.ipv4.tcp_syncookies/d' /etc/sysctl.conf
  147. echo "net.ipv4.tcp_syncookies = 1" >> /etc/sysctl.conf
  148. sed -i '/soft nofile/d' /etc/security/limits.conf
  149. echo "* soft nofile 51200" >> /etc/security/limits.conf
  150. sed -i '/hard nofile/d' /etc/security/limits.conf
  151. echo "* hard nofile 51200" >> /etc/security/limits.conf
  152. [ $oVZ == 'n' ] && {
  153. cat >/etc/sysctl.conf<<EOFSYS
  154. #This line below add by user.
  155. #sysctl net.ipv4.tcp_available_congestion_control
  156. #modprobe tcp_htcp
  157. net.ipv4.ip_forward = 1
  158. fs.file-max = 51200
  159. net.core.wmem_max = 8388608
  160. net.core.rmem_max = 8388608
  161. net.core.rmem_default = 131072
  162. net.core.wmem_default = 131072
  163. net.core.somaxconn = 4096
  164. net.core.netdev_max_backlog = 65535
  165. net.ipv4.tcp_rmem = 10240 81920 8388608
  166. net.ipv4.tcp_wmem = 10240 81920 8388608
  167. net.ipv4.tcp_mtu_probing = 1
  168. net.ipv4.tcp_syncookies = 1
  169. net.ipv4.tcp_tw_reuse = 1
  170. net.ipv4.tcp_tw_recycle = 0
  171. net.ipv4.tcp_fin_timeout = 15
  172. net.ipv4.tcp_window_scaling = 1
  173. net.ipv4.tcp_keepalive_time = 1200
  174. net.ipv4.tcp_max_syn_backlog = 8192
  175. net.ipv4.tcp_congestion_control = htcp
  176. net.ipv4.icmp_echo_ignore_all = 1
  177. #net.ipv4.tcp_fastopen = 3
  178. EOFSYS
  179. [ -f "/proc/sys/net/ipv4/tcp_fastopen" ] && [ -f /etc/sysctl.conf ] && sed -i 's/#net.ipv4.tcp_fastopen/net.ipv4.tcp_fastopen/g' /etc/sysctl.conf
  180. }
  181. sysctl -p >/dev/null 2>&1
  182. }
  183.  
  184. function ins_ocserv()
  185. {
  186. BitVer='';
  187. mkdir -p /tmp;
  188. [ $sysBits == 'x32' ] && BitVer='i386'
  189. [ $sysBits == 'x64' ] && BitVer='amd64'
  190. [ -n "$BitVer" ] && {
  191. wget --no-check-certificate -qO "/tmp/libradcli4_1.2.6-3~bpo8+1_$BitVer.deb" "https://moeclub.org/attachment/DebianPackage/ocserv/libradcli4_1.2.6-3~bpo8+1_$BitVer.deb"
  192. wget --no-check-certificate -qO "/tmp/ocserv_0.11.6-1~bpo8+2_$BitVer.deb" "https://moeclub.org/attachment/DebianPackage/ocserv/ocserv_0.11.6-1~bpo8+2_$BitVer.deb"
  193. } || {
  194. echo "Error, download fail! "
  195. exit 1
  196. }
  197. bash -c "$(wget --no-check-certificate -qO- 'https://moeclub.org/attachment/LinuxShell/src.sh')"
  198. DEBIAN_FRONTEND=noninteractive apt-get install -y -t jessie dbus init-system-helpers libc6 libev4 libgnutls-deb0-28 libgssapi-krb5-2 libhttp-parser2.1 liblz4-1 libnettle4 libnl-3-200 libnl-route-3-200 liboath0 libopts25 libpcl1 libprotobuf-c1 libsystemd0 libtalloc2 gnutls-bin ssl-cert
  199. dpkg -i /tmp/libradcli4_*.deb
  200. dpkg -i /tmp/ocserv_*.deb
  201. which ocserv >/dev/null 2>&1
  202. [ $? -ne '0' ] && echo 'Error, Install ocerv.' && exit 1
  203. sed -i '/exit .*/d' /etc/rc.local
  204. sed -i '$a\iptables -t nat -A POSTROUTING -o '${ifname}' -j MASQUERADE' /etc/rc.local
  205. sed -i '$a\iptables -I INPUT -p tcp --dport '${SSLTCP}' -j ACCEPT' /etc/rc.local
  206. sed -i '$a\iptables -I INPUT -p udp --dport '${SSLUDP}' -j ACCEPT' /etc/rc.local
  207. sed -i '$a\iptables -I FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu' /etc/rc.local
  208. sed -i '$a\exit 0' /etc/rc.local
  209. cat >/etc/ocserv/ocserv.conf<<EOF
  210. #Login Type
  211. #auth = "plain[passwd=/etc/ocserv/ocpasswd]"
  212. auth = "certificate"
  213.  
  214. # TCP and UDP port number
  215. tcp-port = $SSLTCP
  216. #udp-port = $SSLUDP
  217.  
  218. server-cert = /etc/ocserv/server.cert.pem
  219. server-key = /etc/ocserv/server.key.pem
  220. ca-cert = /etc/ocserv/ca.cert.pem
  221. dh-params = /etc/ocserv/dh.pem
  222.  
  223. socket-file = /var/run/ocserv.socket
  224. occtl-socket-file = /var/run/occtl.socket
  225. pid-file = /var/run/ocserv.pid
  226. user-profile = /etc/ocserv/profile.xml
  227. run-as-user = nobody
  228. cert-user-oid = 2.5.4.3
  229. isolate-workers = false
  230. max-clients = 192
  231. max-same-clients = 192
  232. keepalive = 32400
  233. dpd = 300
  234. mobile-dpd = 1800
  235. #output-buffer = 1000
  236. try-mtu-discovery = true
  237. compression = true
  238. no-compress-limit = 256
  239. auth-timeout = 40
  240. idle-timeout = 1200
  241. mobile-idle-timeout = 1200
  242. cookie-timeout = 43200
  243. persistent-cookies = true
  244. deny-roaming = false
  245. rekey-time = 43200
  246. rekey-method = ssl
  247. use-utmp = true
  248. use-occtl = true
  249. device = ocserv
  250. predictable-ips = false
  251. ping-leases = false
  252. cisco-client-compat = true
  253. tls-priorities = "NORMAL:%SERVER_PRECEDENCE:%COMPAT:-RSA:-VERS-SSL3.0:-ARCFOUR-128"
  254. ipv4-network = 192.168.8.0
  255. ipv4-netmask = 255.255.255.0
  256. dns = 192.168.8.1
  257.  
  258. EOF
  259. cat >/etc/ocserv/profile.xml<<EOF
  260. <?xml version="1.0" encoding="UTF-8"?>
  261. <AnyConnectProfile xmlns="http://schemas.xmlsoap.org/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.xmlsoap.org/encoding/ AnyConnectProfile.xsd">
  262.  
  263. <ClientInitialization>
  264. <UseStartBeforeLogon UserControllable="false">false</UseStartBeforeLogon>
  265. <StrictCertificateTrust>false</StrictCertificateTrust>
  266. <RestrictPreferenceCaching>false</RestrictPreferenceCaching>
  267. <RestrictTunnelProtocols>false</RestrictTunnelProtocols>
  268. <BypassDownloader>true</BypassDownloader>
  269. <WindowsVPNEstablishment>AllowRemoteUsers</WindowsVPNEstablishment>
  270. <CertEnrollmentPin>pinAllowed</CertEnrollmentPin>
  271. <CertificateMatch>
  272. <KeyUsage>
  273. <MatchKey>Digital_Signature</MatchKey>
  274. </KeyUsage>
  275. <ExtendedKeyUsage>
  276. <ExtendedMatchKey>ClientAuth</ExtendedMatchKey>
  277. </ExtendedKeyUsage>
  278. </CertificateMatch>
  279.  
  280. <BackupServerList>
  281. <HostAddress>$MyDomain</HostAddress>
  282. </BackupServerList>
  283. </ClientInitialization>
  284. </AnyConnectProfile>
  285. EOF
  286.  
  287. mkdir -p /etc/ocserv/template
  288. cat >/etc/ocserv/template/ca.tmp<<EOF
  289. cn = "$FILLIT1"
  290. organization = "$FILLIT2"
  291. serial = 1
  292. expiration_days = 1825
  293. ca
  294. signing_key
  295. cert_signing_key
  296. crl_signing_key
  297. EOF
  298. openssl genrsa -out /etc/ocserv/template/ca.key.pem 2048
  299. certtool --generate-self-signed --hash SHA256 --load-privkey /etc/ocserv/template/ca.key.pem --template /etc/ocserv/template/ca.tmp --outfile /etc/ocserv/ca.cert.pem
  300. certtool --generate-dh-params --outfile /etc/ocserv/dh.pem
  301.  
  302. cat >/etc/ocserv/template/server.tmp<<EOF
  303. cn = "$MyDomain"
  304. organization = "MoeClub.org"
  305. serial = 2
  306. expiration_days = 1825
  307. signing_key
  308. encryption_key
  309. tls_www_server
  310. EOF
  311. openssl genrsa -out /etc/ocserv/server.key.pem 2048
  312. certtool --generate-certificate --hash SHA256 --load-privkey /etc/ocserv/server.key.pem --load-ca-certificate /etc/ocserv/ca.cert.pem --load-ca-privkey /etc/ocserv/template/ca.key.pem --template /etc/ocserv/template/server.tmp --outfile /etc/ocserv/server.cert.pem
  313. cat /etc/ocserv/ca.cert.pem >>/etc/ocserv/server.cert.pem
  314. }
  315.  
  316. function login_ocserv()
  317. {
  318. [ $MyType == 'certificate' ] && {
  319. cat >/etc/ocserv/template/user.tmp<<EOF
  320. cn = "$FILLIT1"
  321. unit = "$FILLIT2"
  322. expiration_days = 1825
  323. signing_key
  324. tls_www_client
  325. EOF
  326. openssl genrsa -out /etc/ocserv/template/user.key.pem 2048
  327. certtool --generate-certificate --hash SHA256 --load-privkey /etc/ocserv/template/user.key.pem --load-ca-certificate /etc/ocserv/ca.cert.pem --load-ca-privkey /etc/ocserv/template/ca.key.pem --template /etc/ocserv/template/user.tmp --outfile /etc/ocserv/template/user.cert.pem
  328. cat /etc/ocserv/ca.cert.pem >>/etc/ocserv/template/user.cert.pem
  329. openssl pkcs12 -export -inkey /etc/ocserv/template/user.key.pem -in /etc/ocserv/template/user.cert.pem -name "Vicer" -certfile /etc/ocserv/ca.cert.pem -caname "$FILLIT1" -out /etc/ocserv/AnyConnect.p12 -passout pass:
  330. [ -f /etc/ocserv/ocserv.conf ] && sed -i 's/^auth =/#auth =/g;s/^#auth = "certificate".*/auth = "certificate"/g' /etc/ocserv/ocserv.conf
  331. }
  332. [ $MyType == 'password' ] && {
  333. [ -f /etc/ocserv/ocpasswd ] && sed -i '/'${FILLIT1}':/d' /etc/ocserv/ocpasswd
  334. echo -n "$FILLIT1:*:" >>/etc/ocserv/ocpasswd
  335. openssl passwd "$FILLIT2" >>/etc/ocserv/ocpasswd
  336. [ -f /etc/ocserv/ocserv.conf ] && sed -i 's/^auth =/#auth =/g;s/^#auth = "plain.*/auth = "plain\[passwd=\/etc\/ocserv\/ocpasswd\]"/g' /etc/ocserv/ocserv.conf
  337. }
  338. }
  339.  
  340. function ask_ocserv()
  341. {
  342. Welcome
  343. Ask_ocserv_port
  344. Ask_ocserv_type
  345. Ask_ocserv_password
  346. pause
  347. clear
  348. }
  349.  
  350. function ins_dnsmasq()
  351. {
  352. apt-get install -y dnsmasq
  353. cat >/etc/dnsmasq.conf<<EOF
  354. except-interface=$ifname
  355. dhcp-range=192.168.8.2,192.168.8.254,255.255.255.0,24h
  356. dhcp-option-force=option:router,192.168.8.1
  357. dhcp-option-force=option:dns-server,192.168.8.1
  358. dhcp-option-force=option:netbios-ns,192.168.8.1
  359. listen-address=127.0.0.1,192.168.8.1
  360. no-resolv
  361. bogus-priv
  362. no-negcache
  363. clear-on-reload
  364. cache-size=81920
  365. server=208.67.220.220#5353
  366. EOF
  367. bash /etc/init.d/dnsmasq restart
  368. }
  369.  
  370. function add_user()
  371. {
  372. [ "$(grep -c '^auth =' /etc/ocserv/ocserv.conf)" != '1' ] && sed -i 's/^auth =/#auth =/g;s/^#auth = "plain.*/auth = "plain\[passwd=\/etc\/ocserv\/ocpasswd\]"/g' /etc/ocserv/ocserv.conf
  373. MyType='password'
  374. FILLIT1="$tmpUser"
  375. FILLIT2="$tmpPass"
  376. [ -n "$FILLIT1" ] && [ -n "$FILLIT2" ] && login_ocserv
  377. }
  378.  
  379. function del_user()
  380. {
  381. [ -f /etc/ocserv/ocpasswd ] && sed -i '/'${delUser}':/d' /etc/ocserv/ocpasswd
  382. }
  383.  
  384. function ChangeType()
  385. {
  386. TheType="$(echo -n "$tmpType"|sed -r 's/(.*)/\L\1/')"
  387. echo -n "$TheType" |grep -q '^cert'
  388. [ $? -eq '0' ] && [ -f /etc/ocserv/ocserv.conf ] && sed -i 's/^auth =/#auth =/g;s/^#auth = "certificate".*/auth = "certificate"/g' /etc/ocserv/ocserv.conf
  389. echo -n "$TheType" |grep -q '^pass'
  390. [ $? -eq '0' ] && [ -f /etc/ocserv/ocserv.conf ] && sed -i 's/^auth =/#auth =/g;s/^#auth = "plain.*/auth = "plain\[passwd=\/etc\/ocserv\/ocpasswd\]"/g' /etc/ocserv/ocserv.conf
  391. [ -e /etc/init.d/ocserv ] && bash /etc/init.d/ocserv restart
  392. }
  393.  
  394. function add_route()
  395. {
  396. sed -i '/^route/d' /etc/ocserv/ocserv.conf
  397. sed -i '/^no-route/d' /etc/ocserv/ocserv.conf
  398. cat >>/etc/ocserv/ocserv.conf<<EOF
  399. ## Route List
  400. route = 0.0.0.0/248.0.0.0
  401. route = 8.0.0.0/254.0.0.0
  402. route = 11.0.0.0/255.0.0.0
  403. route = 12.0.0.0/252.0.0.0
  404. route = 16.0.0.0/248.0.0.0
  405. route = 24.0.0.0/254.0.0.0
  406. route = 26.0.0.0/255.0.0.0
  407. route = 27.0.0.0/255.128.0.0
  408. route = 27.128.0.0/255.192.0.0
  409. route = 27.224.0.0/255.224.0.0
  410. route = 28.0.0.0/252.0.0.0
  411. route = 32.0.0.0/252.0.0.0
  412. route = 36.0.0.0/255.192.0.0
  413. route = 36.64.0.0/255.224.0.0
  414. route = 36.224.0.0/255.224.0.0
  415. route = 37.0.0.0/255.0.0.0
  416. route = 38.0.0.0/255.0.0.0
  417. route = 39.0.0.0/255.192.0.0
  418. route = 39.96.0.0/255.224.0.0
  419. route = 39.192.0.0/255.192.0.0
  420. route = 40.0.0.0/252.0.0.0
  421. route = 44.0.0.0/254.0.0.0
  422. route = 46.0.0.0/255.0.0.0
  423. route = 47.0.0.0/255.192.0.0
  424. route = 47.64.0.0/255.224.0.0
  425. route = 47.128.0.0/255.128.0.0
  426. route = 48.0.0.0/255.0.0.0
  427. route = 49.0.0.0/255.192.0.0
  428. route = 49.96.0.0/255.224.0.0
  429. route = 49.128.0.0/255.128.0.0
  430. route = 50.0.0.0/254.0.0.0
  431. route = 52.0.0.0/252.0.0.0
  432. route = 56.0.0.0/254.0.0.0
  433. route = 58.0.0.0/255.224.0.0
  434. route = 58.64.0.0/255.192.0.0
  435. route = 58.128.0.0/255.192.0.0
  436. route = 58.224.0.0/255.224.0.0
  437. route = 59.0.0.0/255.224.0.0
  438. route = 59.64.0.0/255.192.0.0
  439. route = 59.128.0.0/255.192.0.0
  440. route = 60.32.0.0/255.224.0.0
  441. route = 60.64.0.0/255.192.0.0
  442. route = 60.128.0.0/255.224.0.0
  443. route = 60.192.0.0/255.192.0.0
  444. route = 61.0.0.0/255.128.0.0
  445. route = 61.192.0.0/255.192.0.0
  446. route = 62.0.0.0/254.0.0.0
  447. route = 64.0.0.0/224.0.0.0
  448. route = 96.0.0.0/248.0.0.0
  449. route = 104.0.0.0/252.0.0.0
  450. route = 108.0.0.0/254.0.0.0
  451. route = 110.0.0.0/255.192.0.0
  452. route = 110.64.0.0/255.224.0.0
  453. route = 110.128.0.0/255.192.0.0
  454. route = 110.224.0.0/255.224.0.0
  455. route = 111.64.0.0/255.192.0.0
  456. route = 111.160.0.0/255.224.0.0
  457. route = 111.192.0.0/255.192.0.0
  458. route = 112.64.0.0/255.192.0.0
  459. route = 112.128.0.0/255.192.0.0
  460. route = 112.192.0.0/255.224.0.0
  461. route = 113.0.0.0/255.192.0.0
  462. route = 113.128.0.0/255.128.0.0
  463. route = 114.0.0.0/255.128.0.0
  464. route = 114.128.0.0/255.192.0.0
  465. route = 114.192.0.0/255.224.0.0
  466. route = 115.0.0.0/255.128.0.0
  467. route = 115.128.0.0/255.192.0.0
  468. route = 115.224.0.0/255.224.0.0
  469. route = 116.0.0.0/255.128.0.0
  470. route = 116.192.0.0/255.192.0.0
  471. route = 117.0.0.0/255.128.0.0
  472. route = 117.192.0.0/255.192.0.0
  473. route = 118.0.0.0/254.0.0.0
  474. route = 120.0.0.0/255.128.0.0
  475. route = 120.128.0.0/255.192.0.0
  476. route = 121.0.0.0/255.240.0.0
  477. route = 121.16.0.0/255.240.0.0
  478. route = 121.32.0.0/255.240.0.0
  479. route = 121.48.0.0/255.254.0.0
  480. route = 121.50.0.0/255.255.0.0
  481. route = 121.52.0.0/255.252.0.0
  482. route = 121.56.0.0/255.248.0.0
  483. route = 121.64.0.0/255.192.0.0
  484. route = 121.128.0.0/255.128.0.0
  485. route = 122.0.0.0/255.192.0.0
  486. route = 122.96.0.0/255.224.0.0
  487. route = 122.128.0.0/255.128.0.0
  488. route = 123.0.0.0/255.192.0.0
  489. route = 123.96.0.0/255.224.0.0
  490. route = 123.128.0.0/255.128.0.0
  491. route = 124.0.0.0/255.0.0.0
  492. route = 125.0.0.0/255.192.0.0
  493. route = 125.96.0.0/255.224.0.0
  494. route = 125.128.0.0/255.128.0.0
  495. route = 126.0.0.0/254.0.0.0
  496. route = 128.0.0.0/248.0.0.0
  497. route = 136.0.0.0/252.0.0.0
  498. route = 140.0.0.0/255.128.0.0
  499. route = 140.128.0.0/255.192.0.0
  500. route = 140.192.0.0/255.248.0.0
  501. route = 140.200.0.0/255.252.0.0
  502. route = 140.204.0.0/255.255.0.0
  503. route = 140.208.0.0/255.240.0.0
  504. route = 140.224.0.0/255.224.0.0
  505. route = 141.0.0.0/255.0.0.0
  506. route = 142.0.0.0/254.0.0.0
  507. route = 144.0.0.0/240.0.0.0
  508. route = 160.0.0.0/248.0.0.0
  509. route = 168.0.0.0/255.128.0.0
  510. route = 168.128.0.0/255.192.0.0
  511. route = 168.192.0.0/255.224.0.0
  512. route = 168.224.0.0/255.240.0.0
  513. route = 168.240.0.0/255.248.0.0
  514. route = 168.248.0.0/255.252.0.0
  515. route = 168.252.0.0/255.254.0.0
  516. route = 168.255.0.0/255.255.0.0
  517. route = 169.0.0.0/255.0.0.0
  518. route = 170.0.0.0/254.0.0.0
  519. route = 172.0.0.0/255.240.0.0
  520. route = 172.32.0.0/255.224.0.0
  521. route = 172.64.0.0/255.192.0.0
  522. route = 172.128.0.0/255.128.0.0
  523. route = 173.0.0.0/255.0.0.0
  524. route = 174.0.0.0/255.0.0.0
  525. route = 175.0.0.0/255.192.0.0
  526. route = 175.96.0.0/255.224.0.0
  527. route = 175.128.0.0/255.128.0.0
  528. route = 176.0.0.0/252.0.0.0
  529. route = 180.0.0.0/255.192.0.0
  530. route = 180.64.0.0/255.224.0.0
  531. route = 180.128.0.0/255.128.0.0
  532. route = 181.0.0.0/255.0.0.0
  533. route = 182.0.0.0/255.192.0.0
  534. route = 182.64.0.0/255.224.0.0
  535. route = 182.128.0.0/255.128.0.0
  536. route = 183.64.0.0/255.192.0.0
  537. route = 183.160.0.0/255.224.0.0
  538. route = 184.0.0.0/248.0.0.0
  539. route = 192.0.0.0/255.128.0.0
  540. route = 192.128.0.0/255.224.0.0
  541. route = 192.160.0.0/255.248.0.0
  542. route = 192.169.0.0/255.255.0.0
  543. route = 192.170.0.0/255.254.0.0
  544. route = 192.172.0.0/255.252.0.0
  545. route = 192.176.0.0/255.240.0.0
  546. route = 192.192.0.0/255.192.0.0
  547. route = 193.0.0.0/255.0.0.0
  548. route = 194.0.0.0/254.0.0.0
  549. route = 196.0.0.0/252.0.0.0
  550. route = 200.0.0.0/248.0.0.0
  551. route = 208.0.0.0/248.0.0.0
  552. route = 216.0.0.0/254.0.0.0
  553. route = 218.32.0.0/255.224.0.0
  554. route = 218.96.0.0/255.224.0.0
  555. route = 218.128.0.0/255.128.0.0
  556. route = 219.0.0.0/255.128.0.0
  557. route = 219.160.0.0/255.224.0.0
  558. route = 219.192.0.0/255.192.0.0
  559. route = 220.0.0.0/255.128.0.0
  560. route = 220.128.0.0/255.224.0.0
  561. route = 220.192.0.0/255.192.0.0
  562. route = 221.0.0.0/255.0.0.0
  563. route = 222.0.0.0/255.224.0.0
  564. route = 222.96.0.0/255.224.0.0
  565. route = 222.128.0.0/255.192.0.0
  566. route = 222.224.0.0/255.224.0.0
  567. route = 223.0.0.0/255.192.0.0
  568. route = 223.96.0.0/255.224.0.0
  569. route = 223.128.0.0/255.128.0.0
  570. route = 224.0.0.0/224.0.0.0
  571. EOF
  572. [ -e /etc/init.d/ocserv ] && bash /etc/init.d/ocserv restart
  573. }
  574.  
  575. function add_noroute()
  576. {
  577. sed -i '/^route/d' /etc/ocserv/ocserv.conf
  578. sed -i '/^no-route/d' /etc/ocserv/ocserv.conf
  579. PublicIP="$(wget -qO- checkip.amazonaws.com)"
  580. cat >>/etc/ocserv/ocserv.conf<<EOF
  581. ## No Route List
  582. no-route = $PublicIP/255.255.255.255
  583. no-route = 192.168.0.0/255.255.0.0
  584.  
  585. no-route = 1.0.0.0/255.192.0.0
  586. no-route = 1.64.0.0/255.224.0.0
  587. no-route = 1.112.0.0/255.248.0.0
  588. no-route = 1.176.0.0/255.240.0.0
  589. no-route = 1.192.0.0/255.240.0.0
  590. no-route = 14.0.0.0/255.224.0.0
  591. no-route = 14.96.0.0/255.224.0.0
  592. no-route = 14.128.0.0/255.224.0.0
  593. no-route = 14.192.0.0/255.224.0.0
  594. no-route = 27.0.0.0/255.192.0.0
  595. no-route = 27.96.0.0/255.224.0.0
  596. no-route = 27.128.0.0/255.224.0.0
  597. no-route = 27.176.0.0/255.240.0.0
  598. no-route = 27.192.0.0/255.224.0.0
  599. no-route = 27.224.0.0/255.252.0.0
  600. no-route = 36.0.0.0/255.192.0.0
  601. no-route = 36.96.0.0/255.224.0.0
  602. no-route = 36.128.0.0/255.192.0.0
  603. no-route = 36.192.0.0/255.224.0.0
  604. no-route = 36.240.0.0/255.240.0.0
  605. no-route = 39.0.0.0/255.255.0.0
  606. no-route = 39.64.0.0/255.224.0.0
  607. no-route = 39.96.0.0/255.240.0.0
  608. no-route = 39.128.0.0/255.192.0.0
  609. no-route = 40.72.0.0/255.254.0.0
  610. no-route = 40.124.0.0/255.252.0.0
  611. no-route = 42.0.0.0/255.248.0.0
  612. no-route = 42.48.0.0/255.240.0.0
  613. no-route = 42.80.0.0/255.240.0.0
  614. no-route = 42.96.0.0/255.224.0.0
  615. no-route = 42.128.0.0/255.128.0.0
  616. no-route = 43.224.0.0/255.224.0.0
  617. no-route = 45.65.16.0/255.255.240.0
  618. no-route = 45.112.0.0/255.240.0.0
  619. no-route = 45.248.0.0/255.248.0.0
  620. no-route = 47.92.0.0/255.252.0.0
  621. no-route = 47.96.0.0/255.224.0.0
  622. no-route = 49.0.0.0/255.128.0.0
  623. no-route = 49.128.0.0/255.224.0.0
  624. no-route = 49.192.0.0/255.192.0.0
  625. no-route = 52.80.0.0/255.252.0.0
  626. no-route = 54.222.0.0/255.254.0.0
  627. no-route = 58.0.0.0/255.128.0.0
  628. no-route = 58.128.0.0/255.224.0.0
  629. no-route = 58.192.0.0/255.224.0.0
  630. no-route = 58.240.0.0/255.240.0.0
  631. no-route = 59.32.0.0/255.224.0.0
  632. no-route = 59.64.0.0/255.224.0.0
  633. no-route = 59.96.0.0/255.240.0.0
  634. no-route = 59.144.0.0/255.240.0.0
  635. no-route = 59.160.0.0/255.224.0.0
  636. no-route = 59.192.0.0/255.192.0.0
  637. no-route = 60.0.0.0/255.224.0.0
  638. no-route = 60.48.0.0/255.240.0.0
  639. no-route = 60.160.0.0/255.224.0.0
  640. no-route = 60.192.0.0/255.192.0.0
  641. no-route = 61.0.0.0/255.192.0.0
  642. no-route = 61.80.0.0/255.248.0.0
  643. no-route = 61.128.0.0/255.192.0.0
  644. no-route = 61.224.0.0/255.224.0.0
  645. no-route = 91.234.36.0/255.255.255.0
  646. no-route = 101.0.0.0/255.128.0.0
  647. no-route = 101.128.0.0/255.224.0.0
  648. no-route = 101.192.0.0/255.240.0.0
  649. no-route = 101.224.0.0/255.224.0.0
  650. no-route = 103.0.0.0/255.0.0.0
  651. no-route = 106.0.0.0/255.128.0.0
  652. no-route = 106.224.0.0/255.240.0.0
  653. no-route = 110.0.0.0/255.128.0.0
  654. no-route = 110.144.0.0/255.240.0.0
  655. no-route = 110.160.0.0/255.224.0.0
  656. no-route = 110.192.0.0/255.192.0.0
  657. no-route = 111.0.0.0/255.192.0.0
  658. no-route = 111.64.0.0/255.224.0.0
  659. no-route = 111.112.0.0/255.240.0.0
  660. no-route = 111.128.0.0/255.192.0.0
  661. no-route = 111.192.0.0/255.224.0.0
  662. no-route = 111.224.0.0/255.240.0.0
  663. no-route = 112.0.0.0/255.128.0.0
  664. no-route = 112.128.0.0/255.240.0.0
  665. no-route = 112.192.0.0/255.252.0.0
  666. no-route = 112.224.0.0/255.224.0.0
  667. no-route = 113.0.0.0/255.128.0.0
  668. no-route = 113.128.0.0/255.240.0.0
  669. no-route = 113.192.0.0/255.192.0.0
  670. no-route = 114.16.0.0/255.240.0.0
  671. no-route = 114.48.0.0/255.240.0.0
  672. no-route = 114.64.0.0/255.192.0.0
  673. no-route = 114.128.0.0/255.240.0.0
  674. no-route = 114.192.0.0/255.192.0.0
  675. no-route = 115.0.0.0/255.0.0.0
  676. no-route = 116.0.0.0/255.0.0.0
  677. no-route = 117.0.0.0/255.128.0.0
  678. no-route = 117.128.0.0/255.192.0.0
  679. no-route = 118.16.0.0/255.240.0.0
  680. no-route = 118.64.0.0/255.192.0.0
  681. no-route = 118.128.0.0/255.128.0.0
  682. no-route = 119.0.0.0/255.128.0.0
  683. no-route = 119.128.0.0/255.192.0.0
  684. no-route = 119.224.0.0/255.224.0.0
  685. no-route = 120.0.0.0/255.192.0.0
  686. no-route = 120.64.0.0/255.224.0.0
  687. no-route = 120.128.0.0/255.240.0.0
  688. no-route = 120.192.0.0/255.192.0.0
  689. no-route = 121.0.0.0/255.128.0.0
  690. no-route = 121.192.0.0/255.192.0.0
  691. no-route = 122.0.0.0/254.0.0.0
  692. no-route = 124.0.0.0/255.0.0.0
  693. no-route = 125.0.0.0/255.128.0.0
  694. no-route = 125.160.0.0/255.224.0.0
  695. no-route = 125.192.0.0/255.192.0.0
  696. no-route = 137.59.59.0/255.255.255.0
  697. no-route = 137.59.88.0/255.255.252.0
  698. no-route = 139.0.0.0/255.224.0.0
  699. no-route = 139.128.0.0/255.128.0.0
  700. no-route = 140.64.0.0/255.240.0.0
  701. no-route = 140.128.0.0/255.240.0.0
  702. no-route = 140.192.0.0/255.192.0.0
  703. no-route = 144.0.0.0/255.248.0.0
  704. no-route = 144.12.0.0/255.255.0.0
  705. no-route = 144.48.0.0/255.248.0.0
  706. no-route = 144.123.0.0/255.255.0.0
  707. no-route = 144.255.0.0/255.255.0.0
  708. no-route = 146.196.0.0/255.255.128.0
  709. no-route = 150.0.0.0/255.255.0.0
  710. no-route = 150.96.0.0/255.224.0.0
  711. no-route = 150.128.0.0/255.240.0.0
  712. no-route = 150.192.0.0/255.192.0.0
  713. no-route = 152.104.128.0/255.255.128.0
  714. no-route = 153.0.0.0/255.192.0.0
  715. no-route = 153.96.0.0/255.224.0.0
  716. no-route = 157.0.0.0/255.255.0.0
  717. no-route = 157.18.0.0/255.255.0.0
  718. no-route = 157.61.0.0/255.255.0.0
  719. no-route = 157.112.0.0/255.240.0.0
  720. no-route = 157.144.0.0/255.240.0.0
  721. no-route = 157.255.0.0/255.255.0.0
  722. no-route = 159.226.0.0/255.255.0.0
  723. no-route = 160.19.0.0/255.255.0.0
  724. no-route = 160.20.48.0/255.255.252.0
  725. no-route = 160.202.0.0/255.255.0.0
  726. no-route = 160.238.64.0/255.255.252.0
  727. no-route = 161.207.0.0/255.255.0.0
  728. no-route = 162.105.0.0/255.255.0.0
  729. no-route = 163.0.0.0/255.192.0.0
  730. no-route = 163.96.0.0/255.224.0.0
  731. no-route = 163.128.0.0/255.192.0.0
  732. no-route = 163.192.0.0/255.224.0.0
  733. no-route = 164.52.0.0/255.255.128.0
  734. no-route = 166.111.0.0/255.255.0.0
  735. no-route = 167.139.0.0/255.255.0.0
  736. no-route = 167.189.0.0/255.255.0.0
  737. no-route = 167.220.244.0/255.255.252.0
  738. no-route = 168.160.0.0/255.255.0.0
  739. no-route = 170.179.0.0/255.255.0.0
  740. no-route = 171.0.0.0/255.128.0.0
  741. no-route = 171.192.0.0/255.224.0.0
  742. no-route = 175.0.0.0/255.128.0.0
  743. no-route = 175.128.0.0/255.192.0.0
  744. no-route = 180.64.0.0/255.192.0.0
  745. no-route = 180.128.0.0/255.128.0.0
  746. no-route = 182.0.0.0/255.0.0.0
  747. no-route = 183.0.0.0/255.192.0.0
  748. no-route = 183.64.0.0/255.224.0.0
  749. no-route = 183.128.0.0/255.128.0.0
  750. no-route = 192.124.154.0/255.255.255.0
  751. no-route = 192.140.128.0/255.255.128.0
  752. no-route = 202.0.0.0/255.128.0.0
  753. no-route = 202.128.0.0/255.192.0.0
  754. no-route = 202.192.0.0/255.224.0.0
  755. no-route = 203.0.0.0/255.0.0.0
  756. no-route = 210.0.0.0/255.192.0.0
  757. no-route = 210.64.0.0/255.224.0.0
  758. no-route = 210.160.0.0/255.224.0.0
  759. no-route = 210.192.0.0/255.224.0.0
  760. no-route = 211.64.0.0/255.248.0.0
  761. no-route = 211.80.0.0/255.240.0.0
  762. no-route = 211.96.0.0/255.248.0.0
  763. no-route = 211.136.0.0/255.248.0.0
  764. no-route = 211.144.0.0/255.240.0.0
  765. no-route = 211.160.0.0/255.248.0.0
  766. no-route = 216.250.108.0/255.255.252.0
  767. no-route = 218.0.0.0/255.128.0.0
  768. no-route = 218.160.0.0/255.224.0.0
  769. no-route = 218.192.0.0/255.192.0.0
  770. no-route = 219.64.0.0/255.224.0.0
  771. no-route = 219.128.0.0/255.224.0.0
  772. no-route = 219.192.0.0/255.192.0.0
  773. no-route = 220.96.0.0/255.224.0.0
  774. no-route = 220.128.0.0/255.128.0.0
  775. no-route = 221.0.0.0/255.224.0.0
  776. no-route = 221.96.0.0/255.224.0.0
  777. no-route = 221.128.0.0/255.128.0.0
  778. no-route = 222.0.0.0/255.0.0.0
  779. no-route = 223.0.0.0/255.224.0.0
  780. no-route = 223.64.0.0/255.192.0.0
  781. no-route = 223.128.0.0/255.128.0.0
  782. EOF
  783. [ -e /etc/init.d/ocserv ] && bash /etc/init.d/ocserv restart
  784. }
  785.  
  786. function ins_all()
  787. {
  788. Welcome
  789. ServerIP
  790. ask_ocserv
  791. ins_ocserv
  792. login_ocserv
  793. ins_dnsmasq
  794. SYSCONF
  795. ins_Finish
  796. }
  797.  
  798. function ins_Finish()
  799. {
  800. grep '^iptables' /etc/rc.local >/tmp/iptables.tmp
  801. [ -f /tmp/iptables.tmp ] && bash /tmp/iptables.tmp
  802. [ -e /etc/init.d/dnsmasq ] && bash /etc/init.d/dnsmasq restart
  803. [ -e /etc/init.d/ocserv ] && bash /etc/init.d/ocserv restart
  804. rm -rf /tmp/*.tmp
  805. }
  806.  
  807. [ $# -eq '0' ] && ins_all
  808. ins_it='0';
  809. addroute='0';
  810. addnoroute='0';
  811. adduser='0';
  812. delUser='0';
  813. UseType='0';
  814. tmpUser="";
  815. tmpPass="";
  816. tmpType="";
  817. while [[ $# -ge 1 ]]; do
  818. case $1 in
  819. -i|ins|-ins|install|-install)
  820. shift
  821. ins_it='1'
  822. ;;
  823. -u|u|use|-use)
  824. shift
  825. UseType='1'
  826. tmpType="$1"
  827. shift
  828. ;;
  829. -a|a|-add|add)
  830. shift
  831. adduser='1'
  832. tmpUser="$1"
  833. shift
  834. tmpPass="$1"
  835. shift
  836. ;;
  837. -d|d|-del|del)
  838. shift
  839. delUser='1'
  840. tmpUser="$1"
  841. shift
  842. ;;
  843. -route|route)
  844. shift
  845. addroute="1"
  846. ;;
  847. -noroute|noroute)
  848. shift
  849. addnoroute="1"
  850. ;;
  851. *)
  852. echo -ne " Usage:\n\tbash $0\t\n"
  853. exit 1;
  854. ;;
  855. esac
  856. done
  857.  
  858. [ "$ins_it" == '1' ] && ins_all;
  859. [ "$addroute" == '1' ] && add_route;
  860. [ "$addnoroute" == '1' ] && add_noroute;
  861. [ "$UseType" == '1' ] && [ -n "$tmpType" ] && ChangeType;
  862. [ "$delUser" == '1' ] && [ -n "$tmpUser" ] && del_user;
  863. [ "$adduser" == '1' ] && [ -n "$tmpUser" ] && [ -n "$tmpPass" ] && add_user;
Advertisement
Add Comment
Please, Sign In to add comment