Linux從入門到放棄 iptables DNAT端口轉發

配置

[root@7 ~]# iptables -t nat -A PREROUTING -d 192.168.1.1 -p tcp --dport 777 -j DNAT --to-destination 172.16.1.7:22
[root@7 ~]# iptables -t nat -nL 
Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination         
PREROUTING_direct  all  --  0.0.0.0/0            0.0.0.0/0           
PREROUTING_ZONES_SOURCE  all  --  0.0.0.0/0            0.0.0.0/0           
PREROUTING_ZONES  all  --  0.0.0.0/0            0.0.0.0/0           
DNAT       tcp  --  0.0.0.0/0            192.168.1.1            tcp dpt:777 to:172.16.1.7:22
[root@7 ~]# sysctl  -p
net.ipv4.ip_forward = 1

測試

Xshell 6 (Build 0101)
Copyright (c) 2002 NetSarang Computer, Inc. All rights reserved.

Type `help' to learn how to use Xshell prompt.
[E:\~]$ ssh 192.168.1.1 777


Connecting to 192.168.1.1:777...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.

WARNING! The remote SSH server rejected X11 forwarding request.
Last login: Wed Feb 12 17:12:56 2020 from 192.168.1.1
[root@web01 ~]# 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章