Назад | Перейти на главную страницу

Перенаправить порт удаленного управления с iptable

У меня следующий сценарий - это маршрутизатор, который пересылает iptable удаленного управления на MS Server 2008, но я не смог заставить его работать с текущим правилом iptable, которое у меня есть:

-A PREROUTING -p tcp --dport 3389 --destination 192.168.0.5
-A PREROUTING -p udp --dport 3389 --destination 192.168.0.5

192.168.0.5 - это адрес MS Server, поэтому я пытаюсь перенаправить на него запрос. Любое предложение.

редактировать

это то, что выдает /etc/init.d/iptable status с 3389 grp

10   ACCEPT     tcp  --  0.0.0.0/0            192.168.0.5         tcp dpt:3389
113  ACCEPT     tcp  --  192.168.0.0/24       0.0.0.0/0           multiport dports 21,25,110,1143,143,2082,2095,2525,3306,3389,7080,7777
11   DNAT       tcp  --  0.0.0.0/0            190.181.129.51      tcp dpt:3389 to:192.168.0.5:3389
12   DNAT       udp  --  0.0.0.0/0            190.181.129.51      udp dpt:3389 to:192.168.0.5:3389

Попробуйте выполнить этот сценарий: -

    #!/bin/bash

    #Uncomment the following line to enable ip forwarding if it is not already enabled.
    #echo 1 > /proc/sys/net/ipv4/ip_forward

    #nat rules to change destination ip address to the ip address of MS server
    iptables -t nat -A PREROUTING -p tcp -d <IP Address of the router/machine on which you are planning to execute this script> --dport 3389 -j DNAT --to 192.168.0.5


    #Allow response from MS server to router/machine on which you execute this script 
    iptables -t nat -A POSTROUTING -d 192.168.0.5 -j MASQUERADE

Если приведенный выше сценарий не работает, очистите приведенные выше правила и попробуйте следующий сценарий: -

    #!/bin/bash

    #Uncomment the following line to enable ip forwarding if it is not already enabled.
    #echo 1 > /proc/sys/net/ipv4/ip_forward

    #nat rules to change destination ip address to the ip address of MS server
    iptables -t nat -A PREROUTING -p tcp -d <IP Address of the router/machine on which you are planning to execute this script> --dport 3389 -j DNAT --to 192.168.0.5:3389


    #Allow response from MS server to router/machine on which you execute this script 
    iptables -t nat -A POSTROUTING -d 192.168.0.5 -j MASQUERADE
iptables -t nat -A PREROUTING -p tcp -d <IP_OF_YOUR_ROUTER> --dport 3389 -j DNAT --to-destination 192.168.0.5:3389
iptables -A FORWARD -p tcp -d 192.168.0.5 --dport 3389 -j ACCEPT