首 页 网站运营 网络编程 网页制作 图象媒体 数据库 建站资源 网管专区 下载专区 最新资讯
IT学堂|红色黑客联盟
设为首页
加入收藏
联系站长
您所在的位置:首页>网管专区>网络组建>文章内容
使用HTun通过http代理服务器建立vpn连接
来源: 作者: 发布时间:2007-04-11

HTun 允许你把数据封装在HTTP/1.1 或者HTTP/1.0协议中再通过一个 HTTP proxy 的80端口出去,建立两台机器之间建立IP VPN连接,通过这样的办法,可以成功避免防火墙的封锁。

这个软件是对于内部网络只开通了http代理来访问外部网络(比如squid),或者内部网络对网络监管得特别严,只允许标准的http数据出去,而你又想连到外网玩CS、QQ游戏、上QQ时的穿透利器。虽然一些vpn软件也支持http代理,比如openvpn也支持http代理,但是它必须使用http代理的connect功能,很多http代理服务器就没有开通connect功能,所以openvpn在这样的网络环境下是不能连接到外部网络中的。HTun使用了标准的http中的post/get,可以成功穿透防火墙!

以上为原理示意图

HTun 建立通过一个合法的HTTP请求的数据传送来建立两台机器之间的点对点连接。HTun服务器放置在外部的Internet 网络中,它监听在80端口接受HTun客户端的连接请求。HTun客户端运行在一个内部网络中,它通过http代理连接到HTun服务器。

HTun只能在linux下运行,使用HTun,必须要求外网有一台HTun服务器正常工作,下面为安装和设置的方法:

1、你的linux内核必须支持tun,加载tun驱动。

2、下载htun的源码,解压、编译、安装

wget http://htun.runslinux.net/dist/htun-0.9.6.tar.gz

#>tar -xvzf htun-0.9.6.tar.gz

#>cd htun-0.9.6/src
#>make

#>cp htund /usr/local/bin
#>cp ../doc/htund.conf /etc

以下为网络示意图:

下面为htun服务器的配置文件:
shashank@zidler:# cat /etc/htund.conf
options {
    daemonize no                   
    logfile /var/log/htund.log     
    tunfile /dev/net/tun
    debug yes
}              

server {
    iprange 192.168.254.0/24
    server_port 8888                     #both server_port and secondary_port must be specified.
    secondary_port 8889                  #Make sure u have given access to these ports in squid.
    max_clients 10
    redirect_host mia.ece.uic.edu
    redirect_port 80
    max_pending 40
    idle_disconnect 1800
    clidata_timeout 20
    min_nack_delay 150
    packet_count_threshold 10
    packet_max_interval 10
    max_response_delay 200
}
--------------------------------------------
shashank@mia:#> cat /etc/htund.conf
options {
    daemonize no
    logfile /var/log/htund.log
    tunfile /dev/net/tun
    debug yes
}              

client {
    do_routing no
    protocol 2
    proxy_ip 131.193.50.187          #Ip address of spiff
    proxy_port 3128                  #Default port for squid

# Only uncomment proxy_user and proxy_pass if you need to authenticate with
# the proxy. Having them set unnecessarily creates extra HTTP overhead.
#   proxy_user joeblow
#   proxy_pass SuperSecret123

    server_ip 131.193.50.184
    server_port 8888
    secondary_server_port 8889

    if_name eth0
    iprange 192.168.254.0/24

    connect_tries 2
    reconnect_tries 4
    reconnect_sleep_sec 30
    channel_2_idle_allow 30
    min_poll_interval_msec 200
    max_poll_interval 30
    poll_backoff_rate 3
    ack_wait 10
}
  1. 启动 htun 服务器:
    #>htund -d
    
  2. 检查tun0界面是否启动.
    [shashank@mia shashank]# ifconfig
    --SNIP--
    tun0      Link encap:Point-to-Point Protocol  
              inet addr:192.168.254.1  P-t-P:192.168.254.0  Mask:255.255.255.255
              UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
              RX packets:6 errors:0 dropped:0 overruns:0 frame:0
              TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:10 
              RX bytes:504 (504.0 b)  TX bytes:504 (504.0 b)
    
  3. 然后手动添加路由表. For example, on zidler I use the command
    shashank@zidler:# route add -net 192.168.0.0 netmask 255.255.255.0 gw 192.168.254.1
    
    Similarly on mia, I will use the command:
    shashank@mia:# route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.254.0
    
  4. Also check if the routes have been established properly using netstat -rn command and ping.
  5. To kill htund, just use ps -A | grep htund, look at the process number and kill -9 processNumber.
  6. 在建立了vpn以后,可以在htun客户端添加默认路由表,让除了到proxy的数据都通过vpn出去,然后使用iptables设置nat,最后将其它电脑的网关都设置为htun客户端的IP地址,这样不用代理服务器,所有的数据包都是通过vpn NAT出去,你就可以突破封锁,开心的玩游戏了!!


[推荐] [返回顶部] [打印本页] [关闭窗口]
热点文章
·动态域名更新的实现方法
·site to site ipsec vpn
·hosspot设置说明
·设置ROUTEROS为透明桥接防火墙
·虚拟路由冗余协议 Virtual Router Red
·使用ROUTEROS建立PPPOE服务器
·如何在ROUTEOS中做IP转向
·ROS下实现数据镜像
·routeros和radius对接设置
·routeros端口映射内网无法访问自身公
相关文章
·IGD的另一個選擇 MiniUPnP
·代理软件强中强----WinRoute
·PPPOE BRAS-1000接入系统安装使用说明
·Windows 2003路由设置
·Zeroshell 集成radius服务器的全能Lin
·Windows 2003作路由局域网共享上
·CafeRadius 一款基于web用户认证的整
·win下的hotspot web界面认证登录网络
·限制rp-pppoe服务器每一个连接的带宽
·用m0n0做软件路由
文章检索
Google
相关文章
·IGD的另一個選擇 MiniUP
·代理软件强中强----WinR
·PPPOE BRAS-1000接入系
·Windows 2003路由设置
·Zeroshell 集成radius服
·Windows 2003作路由局域
·CafeRadius 一款基于web
·win下的hotspot web界面
·限制rp-pppoe服务器每一
·用m0n0做软件路由
·PPPoE Server + FreeRAD
·重新编译monowall扩大mo
·DSMARK队列规定(DSMARK
·如何使用OpenBSD3.2作AD
·Linux下配置多ppp(oe)链