[root@Centos6 ~] # ssh -R 9527:centos7:25 -fN centos6-1 #建立隧道,此过程确保Centos6可以公钥连接centos6-1,否则需要手动口令验证
[root@Centos6 ~] # ss -ntl #检查邮件服务,可以知道服务已经开启
LISTEN 0 100 ::1:25 :::*
LISTEN 0 100 127.0.0.1:25 *:*
[root@centos6-1 . ssh ] # ss -ntl #此时也可以看到跳板机Centos6-1上9527端口已经在监听
LISTEN 0 128 127.0.0.1:9527 *:*
LISTEN 0 128 ::1:9527 :::*
[root@centos6-1 ~] # ps -ef |grep ssh #查看一下ssh运行的进程
root 2288 1 0 09:58 ? 00:00:00 ssh -R 9527:centos7:25 -fN centos6-1
[root@centos6-1 . ssh ] # telnet 127.0.0.1 9527 #此时可以通过telnet连接Cetnos7绕过了防火墙
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]' .
220 centos7.localdomain ESMTP Postfix #如果想退出进入telnet> 快捷键ctrl + ]
[root@centos7 ~] # ss -nt
State Recv-Q Send-Q Local Address:Port Peer Address:Port
ESTAB 0 0 172.18.254.173:25 172.18.253.175:32898
ESTAB 0 96 172.18.254.173:22 172.18.0.100:58652
#此时在Centos7上发现有IP尾号为100的机子在连接实际上是Centos6-1在连接
#最后验证是否能成功发送邮件
[root@centos6-1 ~] # telnet localhost 9527 #给Centos7发送邮件
Trying ::1...
Connected to localhost.
Escape character is '^]' .
220 centos7.localdomain ESMTP Postfix
mail from:ceo@app.com
250 2.1.0 Ok
rcpt to:root@centos7
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
hello
.
250 2.0.0 Ok: queued as 86A5411EA866
quit
221 2.0.0 Bye
Connection closed by foreign host.
[root@centos7 ~] # mail #可以收到邮件信息
Heirloom Mail version 12.5 7 /5/10 . Type ? for help.
"/var/spool/mail/root" : 12 messages 12 new
>N 1 root Fri Mar 16 10:31 14 /496 "Output from your job 4"
N 2 (Cron Daemon) Sat Mar 17 08:00 25 /886 "Cron <root@zangfans> /root/bin/etcback.sh"
N 3 root Sat Mar 17 10:20 14 /506 "Output from your job 2"
N 4 (Cron Daemon) Tue Mar 20 08:00 25 /886 "Cron <root@zangfans> /root/bin/etcback.sh"
N 5 user@localhost. local Wed Mar 28 08:19 2129 /142373 "[abrt] kernel: WARNING: CPU: 1 PID: 0 at net/sched/sch_generic.c:300 dev"
N 6 user@localhost. local Fri Apr 6 19:41 1151 /90323 "[abrt] nautilus: nautilus-desktop killed by SIGSEGV"
N 7 HR@centos7.localdoma Tue Apr 10 14:44 16 /633 "*** SECURITY information for centos7 ***"
N 8 HR@centos7.localdoma Tue Apr 10 16:38 16 /637 "*** SECURITY information for centos7 ***"
N 9 HR@centos7.localdoma Tue Apr 10 16:38 16 /641 "*** SECURITY information for centos7 ***"
N 10 HR@centos7.localdoma Tue Apr 10 16:39 16 /637 "*** SECURITY information for centos7 ***"
N 11 HR@centos7.localdoma Tue Apr 10 16:39 16 /641 "*** SECURITY information for centos7 ***"
N 12 ceo@app.com Wed Apr 11 10:20 10 /314
& 12
Message 12:
From ceo@app.com Wed Apr 11 10:20:29 2018
Return-Path: <ceo@app.com>
X-Original-To: root@centos7
Delivered-To: root@centos7.localdomain
Status: R
hello
|