server:192.168.30.35 us:192.168.66.128 client:192.168.30.35 server: vim /etc/ssh/sshd_config 125 Per
server:192.168.30.35 us:192.168.66.128 client:192.168.30.35
server: vim /etc/ssh/sshd_config
125 PermitTunnel yes
service sshd restart
client: ssh -Nf -w 2:3 192.168.30.35
ifconfig -a 查看tun2的网卡是否已存在
为tun2的网卡设置ip,以及指定建立隧道的ip
ifconfig tun2 192.168.200.1(服务端的ip) 192.168.200.2(tun2的ip) netmask 255.255.255.0
ifconfig tun2
设置路由 route add -net 192.168.66.0/24 gw 192.168.200.2
server:ifconfig tun3 192.168.200.2 192.168.200.1 netmask 255.255.255.0
sysctl -a |grep ip_for 查看是否开启转发
如果没有开启:
vim /etc/sysctl.conf
7 net.ipv4.ip_forward = 1
iptables -S 查看是否允许转发,
如果不允许: iptables -D FORWARD 1
做伪装: iptables -t nat -I POSTROUTING -s 192.168.200.0/24 -j MASQUERADE
这样client就能访问 us:192.168.66.128了 并且数据是经过加密的.