对于那些谁使用NTLM验证网络代理环境(即除了需要设置的代理主机和端口还需要提供一个域用户名和密码)供。通过代理上网头疼。这主要是由于非常大的软件不支持NTLM的代理(比方眼下的GIT就不能支持NTLM验证,即使在代理中指定了域帐号和密码,在连接过程中依旧报: Received HTTP code 407 from proxy after CONNECT ,说明验证并未通过)。假设有这样一种工具能封装NTLM验证然后对外提供普通的HTTP代理服务。那么第三方应用就能够通过配置普通的代理訪问网络了,这就是Cntlm (项目官网:http://cntlm.sourceforge.net/)所要解决的问题! 由于Cntlm也有linux版本号,这意味着在linux系统上通过NTLM身份验证的网络代理也是可行的。本文原文出处: http://blog.csdn.net/bluishglc/article/details/37600773 严禁不论什么形式的转载,否则将托付CSDN官方维护权益!

配置

下载安装Cntlm之后。仅仅须要改动cntlm.ini文件,提供身份认证必要的信息,然后以服务的方式启动cntlm就能够了。

在cntlm.ini中有例如以下几个重要的配置是可能须要改动的:

  • Username - your domain/proxy account name

  • Domain - the actual domain name

  • Workstation - NetBIOS name of your workstation; Cntlm tries to autodetect it, but you might want to set it explicitly should dialect detection fail (see below)

  • Proxy - IP address (or ping-able hostname) of your proxy; if you use several alternative proxies or know of backup ones, use this option multiple times; if one stops working, Cntlm will move on to the next

  • Listen - local port number which Cntlm should bind to; the default is OK, but remember you can't have more than one application per port; you can use netstat to list used up ports (lines with LISTEN)

当中Listen配置项是cntlm将在本地打开的作为普通代理的端口。假如我的windows域是abc,帐号是laurence,密码是123,代理server是192.168.0.1:80,则cntlm.ini应该例如以下配置:

#
# Cntlm Authentication Proxy Configuration
#
# NOTE: all values are parsed literally, do NOT escape spaces,
# do not quote. Use 0600 perms if you use plaintext password.
# Username laurence
Domain abc
Password 123
# NOTE: Use plaintext password only at your own risk
# Use hashes instead. You can use a "cntlm -M" and "cntlm -H"
# command sequence to get the right config for your environment.
# See cntlm man page
# Example secure config shown below.
# PassLM 1AD35398BE6565DDB5C4EF70C0593492
# PassNT 77B9081511704EE852F94227CF48A793
### Only for user 'testuser', domain 'corp-uk'
# PassNTLMv2 D5826E9C665C37C80B53397D5C07BBCB # Specify the netbios hostname cntlm will send to the parent
# proxies. Normally the value is auto-guessed.
#
# Workstation netbios_hostname # List of parent proxies to use. More proxies can be defined
# one per line in format <proxy_ip>:<proxy_port>
#
Proxy 192.168.0.1:80 # List addresses you do not want to pass to parent proxies
# * and ? wildcards can be used
#
NoProxy localhost, 127.0.0.*, 10.*, 192.168.* # Specify the port cntlm will listen on
# You can bind cntlm to specific interface by specifying
# the appropriate IP address also in format <local_ip>:<local_port>
# Cntlm listens on 127.0.0.1:3128 by default
#
Listen 3128 # If you wish to use the SOCKS5 proxy feature as well, uncomment
# the following option. It can be used several times
# to have SOCKS5 on more than one port or on different network
# interfaces (specify explicit source address for that).
#
# WARNING: The service accepts all requests, unless you use
# SOCKS5User and make authentication mandatory. SOCKS5User
# can be used repeatedly for a whole bunch of individual accounts.
#
#SOCKS5Proxy 8010
#SOCKS5User dave:password # Use -M first to detect the best NTLM settings for your proxy.
# Default is to use the only secure hash, NTLMv2, but it is not
# as available as the older stuff.
#
# This example is the most universal setup known to man, but it
# uses the weakest hash ever. I won't have it's usage on my
# conscience. :) Really, try -M first.
#
#Auth LM
#Flags 0x06820000 # Enable to allow access from other computers
#
#Gateway yes # Useful in Gateway mode to allow/restrict certain IPs
# Specifiy individual IPs or subnets one rule per line.
#
#Allow 127.0.0.1
#Deny 0/0 # GFI WebMonitor-handling plugin parameters, disabled by default
#
#ISAScannerSize 1024
#ISAScannerAgent Wget/
#ISAScannerAgent APT-HTTP/
#ISAScannerAgent Yum/ # Headers which should be replaced if present in the request
#
#Header User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows 98) # Tunnels mapping local port to a machine behind the proxy.
# The format is <local_port>:<remote_host>:<remote_port>
#
#Tunnel 11443:remote.com:443

当中对于监听端口使用默认的端口3128就能够了。我们能够通过命令来验证配置是否正确:

cntlm -c /path/to/cntlm.ini -I -M http://www.baidu.com

假设能正常返回就表示各项配置都是正确的,接下就能够启动cntlm服务在后台执行了,使用命令:

net start cntlm

服务启动之后,我们就能够在第三方应用的代理配置上这样设定了:代理server:127.0.0.1 (即本机),代理server端口:3128(即cntlm.ini文件里配置的Listen端口)

日志与常见错误

cntlm绝大多数错误表现为服务无法启动。详细原因有非常多,好在cntlm有较好的日志信息能够帮助我们找到问题的根源,查看cntlm日志的方法是:Start -> Settings -> Control Panel -> Administrative Tools -> Event Viewer, 然后在左側面板的文件夹树中选择:Windows Logs -> Application, 再在右側面板中配置一下过虑项,将事件源设定为cntlm就能够过滤出全部的cntlm日志了。

这里我们介绍两种可能的错误:

1. cntlm: PID XXXX: Possible duplicate cygwin1.dll: /socat-1.7.2.1/cygwin1.dll.

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYmx1aXNoZ2xj/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />

相似这种错误是由于cygwin1.dll冲突引起的。有多种工具会携带自己的cygwin1.dll,假设版本号不兼容就会报如上的错误,最简单的方是先移除它们。

2. cntlm: Parent proxy address missing

这是一个easy造成误导的错误,假设多数情况下并非由于你在cntlm.ini中错误地制定了Proxy而是cntlm程序启动时根本没用找到cntlm.ini文件,造成这种问题的可能诱因之中的一个是在安装cntlm时改动了默认的安装文件夹,这应该是cntlm的一个bug。不知道在启动cntlm服务的配置界面(Control Panel -> Administrative Tools -> Services)上指定-c參数是否有效。有有兴趣的朋友可以试试,我按照默认配置重装cntlm已解决。

版权声明:本文博主原创文章,博客,未经同意不得转载。

Cntlm安装和配置体验的更多相关文章

  1. 香蕉派(or 皮?)上手初体验 -- 外观鉴赏,安装,配置&amp;总结

    一.前言及简单介绍 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbG9uZ2Vyem9uZQ==/font/5a6L5L2T/fontsize/400/f ...

  2. Maven的安装、配置及使用入门

    Maven的安装.配置及使用入门 本书代码下载 大家可以从我的网站下载本书的代码:http://www.juvenxu.com/mvn-in-action/,也可以通过我的网站与我取得联系,欢迎大家与 ...

  3. Linux(Ubuntu)下MySQL的安装与配置

    转自:http://www.2cto.com/database/201401/273423.html 在Linux下MySQL的安装,我一直觉得挺麻烦的,因为之前安装时就是由于复杂的配置导致有点晕.今 ...

  4. ArchLinux安装与配置小结

    最近无意间发现一个基于ArchLinux的发行版--BlackArch,主题十分炫酷(中二).当然渗透类的Linux 发行版已经有BackTrack和Kali了,不过都是源于Debian的,使用者众多 ...

  5. LXD 2.0 系列(二):安装与配置

    导读 简单来说,LXD是一个守护进程,为LXC容器的管理提供一组REST API.主要目标是提供一种类虚拟机的用户体验,是一种第三方的容器管理工具.下面呢,我们来介绍LXD 2.0 的安装与配置 安装 ...

  6. g4e基础篇#3 Git安装与配置

    g4e 是 Git for Enterprise Developer的简写,这个系列文章会统一使用g4e作为标识,便于大家查看和搜索. 章节目录 前言 1. 基础篇: 为什么要使用版本控制系统 Git ...

  7. 安装与配置Flutter开发环境

    这篇博客我们介绍了Flutter,并且对比了H5,React Native,Flutter. 由于Flutter是跨平台的开发框架,开发一次可以同时运行在Android和iOS上面,所以我们开发时最好 ...

  8. Ubuntu16.04下Hadoop的本地安装与配置

    一.系统环境 os : Ubuntu 16.04 LTS 64bit jdk : 1.8.0_161 hadoop : 2.6.4 部署时使用的用户名为hadoop,下文中需要使用用户名的地方请更改为 ...

  9. emacs安装及配置

    目录 平台 安装 基本配置 配置文件结构 elpa仓库管理 主题配色 字体显示配置(解决中文卡顿) 插件配置 markdown 简介 markdown-mode markdown-toc org导出m ...

随机推荐

  1. WPF案例 (四) 模拟Windows7桌面任务栏

    原文:WPF案例 (四) 模拟Windows7桌面任务栏 这个程序模彷了Windows7的桌面任务栏,当在桌面上双击某个快捷方式时,将打开一个新的子界面,并且在任务栏里创建一个链接到此界面的任务栏图标 ...

  2. 为何要fork()两次来避免产生僵尸进程?

    为何要fork()两次来避免产生僵尸进程?   当我们只fork()一次后,存在父进程和子进程.这时有两种方法来避免产生僵尸进程: 父进程调用waitpid()等函数来接收子进程退出状态. 父进程先结 ...

  3. Hdu 4738【求无向图的桥】.cpp

    题目: 曹操在长江上建立了一些点,点之间有一些边连着.如果这些点构成的无向图变成了连通图,那么曹操就无敌了.刘备为了防止曹操变得无敌,就打算去摧毁连接曹操的点的桥.但是诸葛亮把所有炸弹都带走了,只留下 ...

  4. 百度富文本编辑器UEditor1.3上传图片附件等

    今天一直在整我的一个项目的编辑器上传图片,我用的是百度UEditor 1.3版本号的:如今已经有了1.4的了,只是还算比較新吧,可是官网上面没有上传图片这些的教程,而网上对于这方面的资料非常少啊,折腾 ...

  5. cocos2dx手写js绑定C++

    这两天连续查阅了js绑定c++的非常多文章  , 有手动与自己主动两种方式 . 本来想用自己主动绑定的 , 可是NDK一直下载不下来.....就给算了 . 以下总结一下手动绑定的实现过程 : 一共三步 ...

  6. Jetty:开发指导Handlers

    Rewrite Handler RewriteHandler匹配一个基于该请求的规则集合,然后根据匹配规则的变更请求. 最常见的要求是改写URI.但不限于:规则可以被配置为重定向响应.设置cookie ...

  7. 高版本jQuery设置checkbox状态注意事项

    jQuery 1.9 以后, 使用 .attr(“checked”, true) 或  attr(“checked”, “checked”) 将无法正确设置 checkbox的状态, 同样的, 使用 ...

  8. android系统reboot

    这里所说的reboot指的是软件重启,并非断电重启.我们知道android系统的几个功能,比如:回复出厂设置.OTA升级等都需要重启系统,而且重启后要进入recovery模式,有的手机还带有重启进入f ...

  9. el表达式 分页提交 中文乱码

    el表达式 分页提交 中文乱码 网上找了很多资料,没能解决我的问题.并不是说网上的那些资料不好.而是不适用于我的问题吧. 看看的的问题: 原始页面 单击下一页 , 乱码. 引起的原因则是因为自己的js ...

  10. Windows Phone开发(31):画刷

    原文:Windows Phone开发(31):画刷 画刷是啥玩意儿?哈,其实画刷是用来涂鸦,真的,没骗你,至于你信不信,反正我信了. 本文通过价绍几个典型的画刷,使你明白画刷就是用来涂鸦的. 一.纯色 ...