|
公司所在的网络安装有监控,由于HTTP协议明文特性,监控可以记录到Url ,User-Agent,甚至是Cookies等信息,很容易实现中间人攻击。虽然HTTPS可以避免敏感信息泄露,但有些网站没有HTTPS无法避免敏感信息被中间人监控到,那么可以采用隧道传输的方式尽量避开中间人。。。
正好有一台3M小水管云主机,如果全部通过隧道传输,那么主机带宽吃不消,那么如何用端口分流的方式,只让特定端口(HTTP/TCP:80 DNS/UDP:53)走隧道,或许是一个可行的方案。
那么安装好了服务端,路由器上安装了Open-vp.n Client,配置好连接文件
- dev tun
- proto tcp
- remote xxx.xxx.xx
- ...
- #放弃服务端推送路由以免全部都走服务器路由
- route-nopull
- #添加server所在网段路由
- route 172.17.2.0 255.255.255.0 virtual**_gateway
- verb 3
- auth-user-pass
复制代码
连接成功!路由器成功ping上tun0的网关
- [root@8C78:/root]#route -n
- Kernel IP routing table
- Destination Gateway Genmask Flags Metric Ref Use Iface
- 0.0.0.0 192.168.2.1 0.0.0.0 UG 0 0 0 eth0.2
- 172.17.2.0 172.17.2.14 255.255.255.0 UG 0 0 0 tun0
- 172.17.2.14 0.0.0.0 255.255.255.255 UH 0 0 0 tun0
- 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 br-lan
- 192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0.2
- 192.168.2.1 0.0.0.0 255.255.255.255 UH 0 0 0 eth0.2
- [root@8c78:/root]#ping 172.17.2.1
- PING 172.17.2.1 (172.17.2.1): 56 data bytes
- 64 bytes from 172.17.2.1: seq=0 ttl=128 time=42.801 ms
- 64 bytes from 172.17.2.1: seq=1 ttl=128 time=41.401 ms
- 64 bytes from 172.17.2.1: seq=2 ttl=128 time=41.561 ms
- --- 172.17.2.1 ping statistics ---
- 3 packets transmitted, 3 packets received, 0% packet loss
- round-trip min/avg/max = 41.401/41.921/42.801 ms
复制代码
那么问题来了。。。
路由器下面的客户端ping不通tun0的网关172.17.2.1
怎么设置端口分流?
- C:\Users\admin>ping 172.17.2.1
- 正在 Ping 172.17.2.1 具有 32 字节的数据:
- 来自 192.168.1.1 的回复: 无法连到端口。
- 来自 192.168.1.1 的回复: 无法连到端口。
- 来自 192.168.1.1 的回复: 无法连到端口。
复制代码
由于对iptables不是很熟悉,用了几个网友分享的防火墙规则,均失败了,
- iptables -I FORWARD -o tun0 -j ACCEPT
- iptables -t nat -I POSTROUTING -s 192.168.1.0/24 -d 172.17.2.0/24 -o tun0 -j MASQUERADE
- iptables -t nat -I POSTROUTING -o tun0 -j MASQUERADE
- iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT -to 172.17.2.1
复制代码 还请各位排忧解难
|
|