ssh本地端口转发
实现外网能够访问内网的一台主机,但需要防火墙放行sshd的22端口,外网线路径传输的数据是被 ssh协议加密的
192.168.43.17
yum install telnet-server -y
systemctl start telnet.socket
iptables -A INPUT -s 192.168.43.6 -j REJECT
useradd zs && echo zs |passwd --stdin zs
192.168.43.7
yum install telnet -y
192.168.43.6
yum install telnet -y
ssh -L 9527:192.168.43.17:23 192.168.43.7 -fN
telnet 127.0.0.1 9527
192.168.43.17
yum install postfix
vim /etc/postfix/main.cf
inet_interfaces = all
#inet_interfaces = localhost
systemctl restart postfix
192.168.43.6
ssh -L 9000:192.168.43.17:25 192.168.43.7 -fN
telnet 模拟邮件客户端发邮件
[root@Centos6-43-6 ~]# telnet 127.0.0.1 9000
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
220 Centos7-43-17.linux ESMTP Postfix
helo a.com
250 Centos7-43-17.linux
mail from:mayun@alibaba.com
250 2.1.0 Ok
rcpt to:zs
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
from:mayun
to:zs
subject:test
Welcom to alibaba.
.
250 2.0.0 Ok: queued as 61B7A53D7B
quit
221 2.0.0 Bye
Connection closed by foreign host.
邮件被转发到 zs@192.168.43.17上,查证
ssh远程端口转发
实现外网能够访问内网的一台主机,外网线路径传输的数据是被 ssh协议加密的
192.168.43.17
yum install httpd -y
echo welcome to www.xuepeng.com > /var/www/html/index.html
systemctl start httpd
iptables -A INPUT -s 192.168.43.6 -j REJECT
192.168.43.7
ssh -R 9500:192.168.43.17:80 192.168.43.6 -fN
192.168.43.6
curl 192.168.43.17
curl: (7) couldn't connect to host
curl 127.0.0.1:9500
welcome to www.xuepeng.com
ssh动态端口转发
实现 192.168.43.6 能够上网,用了一台机主机作代理,可以访问互联网的所有机器
192.168.43.17
yum install httpd -y
echo welcome to www.xuepeng.com > /var/www/html/index.html
systemctl start httpd
iptables -A INPUT -s 192.168.43.6 -j REJECT
192.168.43.6
curl 192.168.43.17
curl: (7) couldn't connect to host
ssh -D 6666 192.168.43.7 -fN
curl --socks5 127.0.0.1:6666 http://192.168.43.17
welcome to www.xuepeng.com
实现 windows 机器 能够上网,用了2台机器作代理,能够访问互联网的所有主机
192.168.43.17
yum install httpd -y
echo welcome to www.xuepeng.com > /var/www/html/index.html
systemctl start httpd
iptables -A INPUT -s 192.168.43.6 -j REJECT
iptables -A INPUT -s 192.168.43.1 -p tcp --dport 80 -j REJECT
192.168.43.6
ssh -D 9999 192.168.43.7 -fNg
192.168.43.1
火狐浏览器 ->打开菜单->选项->网络设置
192.168.43.7
ssh -D 1080 192.168.43.7 -gfN
192.168.43.1
IE浏览器
工具->选项->连接 ->局域网设置->