ssh 端口转发

本地转发

image.png

setup telnet server 80.13

yum install telnet-server
systemctl start telnet.socket
[root@80_13 ~]# ss -nlt | grep 23
LISTEN     0      128       [::]:23                    [::]:*                  
iptables -A INPUT -s 192.168.80.11 -j REJECT
#在80.11上不能telnet80.13
[root@80_11 ~]# telnet 192.168.80.13
Trying 192.168.80.13...
telnet: connect to address 192.168.80.13: Connection refused

建立ssh隧道 80.11

ssh -L 9527:192.168.80.13:23 192.168.80.12 -fN
telnet 127.0.0.1 9527

远程转发

image.png

建立端口转发隧道 on 80.12

ssh -R 9527:192.168.80.13:80 192.168.80.11

在80.11上访问80.13

telent 192.168.80.13

模拟科学安全上网

image.png

环境准备

1.在80.13上

yum install httpd
systemctl start httpd
echo 'www.google.com' > /var/www/html/index.html
# 加入防火墙策略禁止192.168.80.11访问
iptables -A INPUT -s 192.168.80.11 -j REJECT
  1. 在80.11上设置proxy 80.12
ssh -D 9527 192.168.80.12 -fN

# 设置网关代理
ssh -gD 9527 192.168.80.12 -fN

# 使用代理服务器上网
curl --socks5 127.0.0.1:9527 http://192.168.80.13
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。