Eu tenho um servidor web escondido atrás de um firewall. Uma regra DNAT no meu firewall torna acessível para visitantes da Internet. A regra funciona para o tráfego da internet. Infelizmente, ele não funciona (ou apenas em partes) para o tráfego proveniente da mesma sub-rede que o destino real. Por alguma razão, o netfilter não restaura o endereço de destino original e, portanto, o cliente / remetente desconsidera o pacote de resposta.
O que estou fazendo de errado?
Layout de rede
192.168.101.0/24 # LOCAL Lan
192.168.101.16 # Client
192.168.101.18 # Server
192.168.101.254 # firewall
144.256.256.1 # firewall (Not the real IP)
(Internet)
| 144.256.256.1 |
| |
| Firewall |
| |
| 192.168.101.254 |
|
|
----------------------
| |
192.168.101.16 192.168.101.18
(Client) (Server)
Regras do iptables
-t nat -A PREROUTING -d 144.256.256.1 --dport 81 -j DNAT destination 192.168.0.2
-t nat -A POSTROUTING -s 192.168.0.0/16 ! -d 192.168.0.0/16 -j MASQUERADE (Should be irrelevant)
Szenario não está funcionando
(Client) 192.168.101.16 trying to reach (Server) 144.256.256.1/81
tcpdump no firewall
192.168.101.16.57631 > 144.256.256.1.81: Flags [S], seq 1884612678
192.168.101.16.57631 > 192.168.101.18.81: Flags [S], seq 1884612678
192.168.101.16.57631 > 144.256.256.1.81: Flags [S], seq 1884612678
192.168.101.16.57631 > 192.168.101.18.81: Flags [S], seq 1884612678
(Seems okay. tcpdump was on -i any. Incoming packet to orginal destination 144.xx Outgoing packet to new destination. But for some reason we're not seeing the responses)
tcpdump no destino (servidor)
IP 192.168.101.16.57874 > 192.168.101.18.81: Flags [S], seq 4243879528,
IP 192.168.101.18.81 > 192.168.101.16.57874: Flags [S.], seq 595099059, ack 4243879529,
IP 192.168.101.16.57874 > 192.168.101.18.81: Flags [R], seq 4243879529, win 0, length 0
(Seems good)
tcpdump na origem (cliente)
IP 192.168.101.16.57874 > 144.256.256.1.81: Flags [S], seq 4243879528
IP 192.168.101.18.81 > 192.168.101.16.57874: Flags [S.], seq 595099059, ack 4243879529, (WTF packet. The source should be 144.x again. For some reason netfilter didn't restore the orignal destination address for the response packet.)
IP 192.168.101.16.57874 > 192.168.101.18.81: Flags [R], seq 4243879529