Прошу помочь решить одну простую задачу - необходимо пробросить порт SSH на другую машину, чтобы можно было коннектиться снаружи.
Машина, которая смотрит в инет имеет внешний адрес eth0 - 87.87.87.87 eth1- 192.168.0.50 eth2 - 192.168.1.5
Дистрибутив gentoo, я ядре все что можно в netfilter указать - указал, /proc/sys/net/ipv4/ip_forward - 1.
Что есть:
iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Команды для проброса порта
iptables -t nat -A PREROUTING -d 87.87.87.87 -p tcp --destination-port 2222 -j DNAT --to-destination 192.168.0.2:22
iptables -t nat -A PREROUTING -d 192.168.1.5 -p tcp --destination-port 2223 -j DNAT --to-destination 192.168.0.2:22
iptables -t nat -L -n -v
Chain PREROUTING (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
25 1164 DNAT tcp -- * * 0.0.0.0/0 87.87.87.87 tcp dpt:3389 to:192.168.0.2
1 44 DNAT tcp -- * * 0.0.0.0/0 192.168.0.50 tcp dpt:3390 to:192.168.1.226:3389
2 88 DNAT tcp -- * * 0.0.0.0/0 87.87.87.87 tcp dpt:2222 to:192.168.0.2:22
0 0 DNAT tcp -- * * 0.0.0.0/0 192.168.1.5 tcp dpt:2223 to:192.168.0.2:22
Chain POSTROUTING (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
1 44 MASQUERADE all -- * * 192.168.0.2 0.0.0.0/0
Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
87.87.87.87 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth2
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 87.87.87.254 0.0.0.0 UG 0 0 0 eth0
Что интересно - изнутри локалной сети, когда destination ip вутрений - то работает, если внешний - то нет. Что для ssh, что для rdp. Понимаю, что где-то надо прописать маршрутизацию - а где, незнаю