my blog my blog

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

配置完成,

  1. /etc/init.d/danted start 

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