my blog my blog

Monthly 7月 2015
Ubuntu下socks5代理服务器dante-server的安装与配置

 

安装

  1. apt-get install dante-server 

配置文件在/etc/danted.conf

  1. vim /etc/danted.conf 
  2. # $Id: sockd.conf,v 1.43 2005/12/26 16:35:26 michaels Exp $ 
  3. # 
  4. # A sample danted.conf 
  5. # 
  6. # 
  7. # The configfile is divided into three parts; 
  8. #    1) serversettings 
  9. #    2) rules 
  10. #    3) routes 
  11. # 
  12. # The recommended order is: 
  13. #   Serversettings: 
  14. #               logoutput 
  15. #               internal 
  16. #               external 
  17. #               method 
  18. #               clientmethod 
  19. #               users 
  20. #               compatibility 
  21. #               extension 
  22. #               connecttimeout 
  23. #               iotimeout 
  24. #               srchost 
  25. # 
  26. #  Rules: 
  27. #       client block/pass 
  28. #               from to 
  29. #               libwrap 
  30. #               log 
  31. # 
  32. #     block/pass 
  33. #               from to 
  34. #               method 
  35. #               command 
  36. #               libwrap 
  37. #               log 
  38. #               protocol 
  39. #               proxyprotocol 
  40. # 
  41. #  Routes: 
  42.  
  43. # the server will log both via syslog, to stdout and to /var/log/lotsoflogs 这行是日志输出,输出到syslog stdout和lotsoflogs里面
  44. logoutput: syslog stdout /var/log/lotsoflogs 
  45.  
  46. # The server will bind to the address 10.1.1.1, port 1080 and will only 
  47. # accept connections going to that address. 
  48. #internal: 10.1.1.1 port = 1080 
  49. # Alternatively, the interface name can be used instead of the address. 这里设置eth0为网卡,端口1080
  50. internal: eth0 port = 1080 
  51.  
  52. # all outgoing connections from the server will use the IP address 
  53. # 195.168.1.1 
  54. #external: 192.168.1.1,这里是设置流量出口使用的ip,也是用eth0网卡的
  55. external:eth0
  56. # list over acceptable methods, order of preference. 
  57. # A method not set here will never be selected. 
  58. # 
  59. # If the method field is not set in a rule, the global 
  60. # method is filled in for that rule. 
  61. # 
  62.  
  63. # methods for socks-rules. 设置方式为用户名模式
  64. method: username 
  65. #methods for client-rules. 
  66. clientmethod: none 
  67.  
  68. #or for PAM authentification 
  69. #method: pam 
  70.  
  71. # 
  72. # An important section, pay attention. 
  73. # 
  74.  
  75. # when doing something that can require privilege, it will use the 
  76. # userid: 
  77. user.privileged: root 
  78.  
  79. # when running as usual, it will use the unprivileged userid of: 
  80. user.notprivileged: nobody 
  81.  
  82. # If you compiled with libwrap support, what userid should it use 
  83. # when executing your libwrap commands?  "libwrap". 
  84. user.libwrap: nobody 
  85.  
  86.  
  87. # 
  88. # some options to help clients with compatibility: 
  89. # 
  90.  
  91. # when a client connection comes in the socksserver will try to use 
  92. # the same port as the client is using, when the socksserver 
  93. # goes out on the clients behalf (external: IP address). 
  94. # If this option is set, Dante will try to do it for reserved ports aswell. 
  95. # This will usually require user.privileged to be set to "root". 
  96. compatibility: sameport 
  97.  
  98. # If you are using the bind extension and have trouble running servers 
  99. # via the server, you might try setting this.  The consequences of it 
  100. # are unknown. 
  101. compatibility: reuseaddr 
  102.  
  103. # 
  104. # The Dante server supports some extensions to the socks protocol. 
  105. # These require that the socks client implements the same extension and 
  106. # can be enabled using the "extension" keyword. 
  107. # 
  108. # enable the bind extension. 
  109. extension: bind 
  110.  
  111.  
  112. # 
  113. # 
  114. # misc options. 
  115. # 
  116.  
  117. # how many seconds can pass from when a client connects til it has 
  118. # sent us it's request?  Adjust according to your network performance 
  119. # and methods supported. 
  120. #connecttimeout: 30   # on a lan, this should be enough if method is "none". 
  121.  
  122. # how many seconds can the client and it's peer idle without sending 
  123. # any data before we dump it?  Unless you disable tcp keep-alive for 
  124. # some reason, it's probably best to set this to 0, which is 
  125. # "forever". 
  126. #iotimeout: 0 # or perhaps 86400, for a day. 
  127.  
  128. # do you want to accept connections from addresses without 
  129. # dns info?  what about addresses having a mismatch in dnsinfo? 
  130. #srchost: nounknown nomismatch 
  131.  
  132. # 
  133. # The actual rules.  There are two kinds and they work at different levels. 
  134. # 
  135. # The rules prefixed with "client" are checked first and say who is allowed 
  136. # and who is not allowed to speak/connect to the server.  I.e the 
  137. # ip range containing possibly valid clients. 
  138. # It is especially important that these only use IP addresses, not hostnames, 
  139. # for security reasons. 
  140. # 
  141. # The rules that do not have a "client" prefix are checked later, when the 
  142. # client has sent its request and are used to evaluate the actual 
  143. # request. 
  144. # 
  145. # The "to:" in the "client" context gives the address the connection 
  146. # is accepted on, i.e the address the socksserver is listening on, or 
  147. # just "0.0.0.0/0" for any address the server is listening on. 
  148. # 
  149. # The "to:" in the non-"client" context gives the destination of the clients 
  150. # socksrequest. 
  151. # 
  152. # "from:" is the source address in both contexts. 
  153. # 
  154.  
  155.  
  156. # the "client" rules.  All our clients come from the net 10.0.0.0/8. 
  157. # 
  158.  
  159. # Allow our clients, also provides an example of the port range command. 设置客户可以通过任何ip登陆,访问任何ip
  160. client pass { 
  161.         from: 0.0.0.0/0 to: 0.0.0.0/0 
  162. #       method: rfc931 # match all idented users that also are in passwordfile 
  163. } 
  164.  
  165. # This is identical to above, but allows clients without a rfc931 (ident) 
  166. # too.  In practise this means the socksserver will try to get a rfc931 
  167. # reply first (the above rule), if that fails, it tries this rule. 
  168. #client pass { 
  169. #       from: 10.0.0.0/8 port 1-65535 to: 0.0.0.0/0 
  170. #} 
  171.  
  172.  
  173. # drop everyone else as soon as we can and log the connect, they are not 
  174. # on our net and have no business connecting to us.  This is the default 
  175. # but if you give the rule yourself, you can specify details. 
  176. #client block { 
  177. #       from: 0.0.0.0/0 to: 0.0.0.0/0 
  178. #       log: connect error 
  179. #} 
  180.  
  181.  
  182. # the rules controlling what clients are allowed what requests 
  183. # 
  184.  
  185. # you probably don't want people connecting to loopback addresses, 
  186. # who knows what could happen then. 
  187. #block { 
  188. #       from: 0.0.0.0/0 to: 127.0.0.0/8 
  189. #       log: connect error 
  190. #} 
  191.  
  192. # the people at the 172.16.0.0/12 are bad, no one should talk to them. 
  193. # log the connect request and also provide an example on how to 
  194. # interact with libwrap. 
  195. #block { 
  196. #       from: 0.0.0.0/0 to: 172.16.0.0/12 
  197. #       libwrap: spawn finger @%a 
  198. #       log: connect error 
  199. #} 
  200.  
  201. # unless you need it, you could block any bind requests. 
  202. #block { 
  203. #       from: 0.0.0.0/0 to: 0.0.0.0/0 
  204. #       command: bind 
  205. #       log: connect error 
  206. #} 
  207.  
  208. # or you might want to allow it, for instance "active" ftp uses it. 
  209. # Note that a "bindreply" command must also be allowed, it 
  210. # should usually by from "0.0.0.0/0", i.e if a client of yours 
  211. # has permission to bind, it will also have permission to accept 
  212. # the reply from anywhere. 
  213. #pass { 
  214. #       from: 10.0.0.0/8 to: 0.0.0.0/0 
  215. #       command: bind 
  216. #       log: connect error 
  217. #} 
  218.  
  219. # some connections expect some sort of "reply", this might be 
  220. # the reply to a bind request or it may be the reply to a 
  221. # udppacket, since udp is packetbased. 
  222. # Note that nothing is done to verify that it's a "genuine" reply, 
  223. # that is in general not possible anyway.  The below will allow 
  224. # all "replies" in to your clients at the 10.0.0.0/8 net. 
  225. #pass { 
  226. #       from: 0.0.0.0/0 to: 10.0.0.0/8 
  227. #       command: bindreply udpreply 
  228. #       log: connect error 
  229. #} 
  230.  
  231.  
  232. # pass any http connects to the example.com domain if they 
  233. # authenticate with username. 
  234. # This matches "example.com" itself and everything ending in ".example.com". 
  235. #pass { 
  236. #       from: 10.0.0.0/8 to: .example.com port = http 
  237. #       log: connect error 
  238. #       method: username 
  239. #} 
  240.  
  241.  
  242.  
  243.  
  244. # block any other http connects to the example.com domain. 
  245. #block { 
  246. #       from: 0.0.0.0/0 to: .example.com port = http 
  247. #       log: connect error 
  248. #} 
  249.  
  250. # everyone from our internal network, 10.0.0.0/8 is allowed to use 
  251. # tcp and udp for everything else. 设置协议支持tcp和udp
  252. pass { 
  253.         from: 0.0.0.0/0 to: 0.0.0.0/0 
  254.         protocol: tcp udp 
  255. } 
  256.  
  257. # last line, block everyone else.  This is the default but if you provide 
  258. # one  yourself you can specify your own logging/actions 
  259. #block { 
  260. #       from: 0.0.0.0/0 to: 0.0.0.0/0 
  261. #       log: connect error 
  262. #} 
  263.  
  264. # route all http connects via an upstream socks server, aka "server-chaining". 
  265. #route { 
  266. # from: 10.0.0.0/8 to: 0.0.0.0/0 port = http via: socks.example.net port = socks 
  267. #} 

配置完成,

  1. /etc/init.d/danted start 

进行启动。登陆是用本机用户名和密码即可。建议将用户的shell设置为nologin

linux下命令行上传下载测速

 

好吧,最近搞了个香港服务器,但是香港带宽限制比较严格,当然不能吃亏了,测速,必须测速。

今天主角出场speedtest-cli,它工作在Python 2.4-3.4

安装:

  1. pip / easy_install 
  2.  
  3. pip install speedtest-cli 
  4.  
  5. or 
  6.  
  7. easy_install speedtest-cli 
  8.  
  9. Github 
  10.  
  11. pip install git+https://github.com/sivel/speedtest-cli.git 
  12.  
  13. or 
  14.  
  15. git clone https://github.com/sivel/speedtest-cli.git 
  16. python speedtest-cli/setup.py install 
  17.  
  18. Just download (Like the way it used to be) 
  19.  
  20. wget -O speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest_cli.py 
  21. chmod +x speedtest-cli 
  22.  
  23. or 
  24.  
  25. curl -Lo speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest_cli.py 
  26. chmod +x speedtest-cli 

功能和使用:

  1. $ speedtest-cli -h 
  2. usage: speedtest-cli [-h] [--bytes] [--share] [--simple] [--list] 
  3.                      [--server SERVER] [--mini MINI] [--source SOURCE] 
  4.                      [--timeout TIMEOUT] [--version] 
  5.  
  6. Command line interface for testing internet bandwidth using speedtest.net. 
  7. -------------------------------------------------------------------------- 
  8. https://github.com/sivel/speedtest-cli 
  9.  
  10. optional arguments: 
  11.   -h, --help         show this help message and exit 
  12.   --bytes            Display values in bytes instead of bits. Does not affect 
  13.                      the image generated by --share 
  14.   --share            Generate and provide a URL to the speedtest.net share 
  15.                      results image 
  16.   --simple           Suppress verbose output, only show basic information 
  17.   --list             Display a list of speedtest.net servers sorted by 
  18.                      distance 
  19.   --server SERVER    Specify a server ID to test against 
  20.   --mini MINI        URL of the Speedtest Mini server 
  21.   --source SOURCE    Source IP address to bind to 
  22.   --timeout TIMEOUT  HTTP timeout in seconds. Default 10 
  23.   --version          Show the version number and exit 

简单测速,奶牛是在ubuntu下进行的测试:

  1. apt-get install python-pip 
  2. pip install speedtest-cli 

安装完成后执行:

  1. speedtest 

测试结果如下:

  1. root@gameserver1:~# speedtest  
  2. Retrieving speedtest.net configuration...  
  3. Retrieving speedtest.net server list...  
  4. Testing from Shanghai Anchnet Network Technology (XXX.XXX.XXX.XXX)...  
  5. Selecting best server based on latency...  
  6. Hosted by Shanghai Branch, China Unicom (Shanghai) [19.64 km]: 29.249 ms  
  7. Testing download speed........................................  
  8. Download: 18.84 Mbit/s  
  9. Testing upload speed..................................................  
  10. Upload: 1.51 Mbit/s  

 

Goagent部署失败账号安全问题解决方案

 

你会收到如是的邮件提醒,如果是设置了转发可能收不到,有可能进入垃圾邮件箱。

 

  1. 尊敬的奶牛,您好! 
  2.  
  3. 您最近更改了安全设置,因此您的Google帐户不再受最新安全标准的保护。 
  4.  
  5. 如果此项更改不是您本人所为 
  6. 请通过https://security.google.com/settings/security/activity查看“帐户活动”页面,以确定是否存在任何可疑活动。做出此项更改的人员知道您的密码,我们建议您立即更改密码。 
  7.  
  8. 如果此项更改是您本人所为 
  9. 请注意:攻击者现在可以更轻松地侵入您的帐户。您可以重新提高帐户的安全性,具体方法是:通过https://www.google.com/settings/security/lesssecureapps撤消此项更改,然后改用Google开发的应用(如Gmail)访问您的帐户。 
  10.  
  11. 此致 
  12. Google 帐户小组敬上    

所以呢,直接进入https://www.google.com/settings/security/lesssecureapps 来进行处理就可以了。