Re: Regras de NAT para acesso a 2º servidor
1) é um servidor Dell comprado especificamente para ser nosso servidor de banco de dados. Nenhuma placa é wireless.
2) pg_hba.conf:
host all all 0/0 md5
postgresql.conf:
listen_addresses = '*'
port = 5432
3) Só consigo acessar o PG pela interface interna de rede (10.1.1.49). Pela externa não responde (187.7.131.35). É exatamente esse meu problema. Necessitome conectar ao banco externamente.
Re: Regras de NAT para acesso a 2º servidor
Talvez eu não tenha entendido direito, configure uma máquina na sua rede (uma estação de trabalho) com ip 187.7.131.x e tenta pingar para o IP 187.7.131.35. Por favor, faça esse teste.
No PostgreeSQL já está atuando, digo, já tem banco de dados, tabelas e dados já sendo acessados e etc???
Re: Regras de NAT para acesso a 2º servidor
minha rede está assim:
server linux (187.7.131.36 - funcionando como server de NET/firewall) ---> switch ---> estações + roteador wifi + server windows (2 placas 187.7.131.35 e 10.1.1.49)
O server linux não pinga o IP externo do server windows!
O PG está funcionando com o sistema que estou desenvolvendo e tem várias partes funcionais! Tem tabelas com mais de 1 milhão de registros já! Só que somente internamente!
Minha primeira idéia era desligar aplaca externa do server windows e deixar somente a interna e o Linux fazer NAT para ele. Mas não estou conseguindo fazer isso!
Re: Regras de NAT para acesso a 2º servidor
1) O servidor Linux só tem 1 interface de rede mesmo? Ele recebe o link de internet em que interface? Explique melhor, se possível.
2) Você tentou configurar uma máquina cliente da rede com um IP qualquer (187.7.131.X) para poder pingar para o host 187.7.131.35? Faça este teste por favor, pois desejo saber, se configurando um máquina da rede interna com um IP 187.7.131.X, apartir dela se consegue pingar para o IP 187.1.131.35.
3) Apartir do servidor Linux aplique um traceroute para o IP 187.7.131.35 e cole aqui no fórum se possível.
4) Apartir do servidor Linux rode o seguinte comando para realizar uma varredura no servidor Windows:
# nmap -sV -P0 187.7.131.35
E cole o resultado aqui.
Re: Regras de NAT para acesso a 2º servidor
1) O servidor linux tem DUAS interfaces de rede:
eth0 recebe o link da internet (187.7.131.36)
eth1 é o cabo qeu vai para o switch (10.1.1.1)
2) configurei uma máquina para 187.7.131.37 e tentei pingar o servidor windows! Ele pinga normalmente. Na realidade o servidor Windows é 157.7.131.34 ed não 35 como disse anteirormente.
3)
Código :
[B]root@serverlinux:/etc# traceroute 187.7.131.34
traceroute to 187.7.131.34 (187.7.131.34), 30 hops max, 60 byte packets
1 serverlinux (187.7.131.36) 3002.218 ms !H 3002.200 ms !H 3002.179 ms !H
root@serverlinux:/etc# ping 187.7.131.34
PING 187.7.131.34 (187.7.131.34) 56(84) bytes of data.
From 187.7.131.36 icmp_seq=1 Destination Host Unreachable
From 187.7.131.36 icmp_seq=2 Destination Host Unreachable
From 187.7.131.36 icmp_seq=3 Destination Host Unreachable
cFrom 187.7.131.36 icmp_seq=4 Destination Host Unreachable
From 187.7.131.36 icmp_seq=5 Destination Host Unreachable
From 187.7.131.36 icmp_seq=6 Destination Host Unreachable
^C
--- 187.7.131.34 ping statistics ---
8 packets transmitted, 0 received, +6 errors, 100% packet loss, time 7040ms
pipe 3
root@serverlinux:/etc# [/B]
4)
Código :
root@serverlinux:/etc# nmap -sV -P0 187.7.131.34
Starting Nmap 5.21 ( http://nmap.org ) at 2011-03-11 16:03 BRT
Nmap done: 1 IP address (0 hosts up) scanned in 0.29 seconds
root@serverlinux:/etc#
Re: Regras de NAT para acesso a 2º servidor
1) Cola denovo as regras de iptables, tu tem o script também? Cola aqui novamente. Isso parece ser no iptables e desejo analisar todas as regras.
2) Esse é o outro IP do servidor Windows, o 10.1.1.49, certo? Apartir do servidor roda esses comandos:
Verifique se pinga.
# ping 10.1.1.49
# nmap -sV -P0 10.1.1.49
E cola eles aqui. Desejo ver como a interface interna responde.
Re: Regras de NAT para acesso a 2º servidor
1) as regras do IPTables são as do firestarter. Não tenho um script para elas.
Se quiser posso te passar o resultado do iptables, mas script não possuo.
2)
Código :
root@serverlinux:/etc# ping 10.1.1.49
PING 10.1.1.49 (10.1.1.49) 56(84) bytes of data.
64 bytes from 10.1.1.49: icmp_req=1 ttl=128 time=0.378 ms
64 bytes from 10.1.1.49: icmp_req=2 ttl=128 time=0.238 ms
64 bytes from 10.1.1.49: icmp_req=3 ttl=128 time=0.213 ms
^C
--- 10.1.1.49 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1998ms
rtt min/avg/max/mdev = 0.213/0.276/0.378/0.073 ms
root@serverlinux:/etc# nmap -sV -P0 10.1.1.49
Starting Nmap 5.21 ( http://nmap.org ) at 2011-03-11 16:58 BRT
Nmap scan report for 10.1.1.49
Host is up (0.014s latency).
Not shown: 979 closed ports
PORT STATE SERVICE VERSION
111/tcp open rpcbind 2-4 (rpc #100000)
135/tcp open msrpc Microsoft Windows RPC
139/tcp open netbios-ssn
445/tcp open netbios-ssn
1039/tcp open status 1 (rpc #100024)
1047/tcp open nlockmgr 1-4 (rpc #100021)
1048/tcp open mountd 1-3 (rpc #100005)
1801/tcp open unknown
2049/tcp open nfs 2-3 (rpc #100003)
2103/tcp open msrpc Microsoft Windows RPC
2105/tcp open msrpc Microsoft Windows RPC
2107/tcp open msrpc Microsoft Windows RPC
3389/tcp open ms-term-serv?
5432/tcp open postgresql?
49152/tcp open msrpc Microsoft Windows RPC
49153/tcp open msrpc Microsoft Windows RPC
49154/tcp open msrpc Microsoft Windows RPC
49155/tcp open msrpc Microsoft Windows RPC
49156/tcp open msrpc Microsoft Windows RPC
49157/tcp open msrpc Microsoft Windows RPC
49176/tcp open msrpc Microsoft Windows RPC
MAC Address: B8:AC:6F:94:B4:33 (Unknown)
Service Info: OS: Windows
Service detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 92.92 seconds
root@serverlinux:/etc#
Re: Regras de NAT para acesso a 2º servidor
Código :
root@serverlinux:/etc# iptables -v -n -L
Chain INPUT (policy DROP 4 packets, 572 bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT tcp -- * * 201.10.120.2 0.0.0.0/0 tcp flags:!0x17/0x02
0 0 ACCEPT udp -- * * 201.10.120.2 0.0.0.0/0
0 0 ACCEPT tcp -- * * 201.10.128.3 0.0.0.0/0 tcp flags:!0x17/0x02
6 748 ACCEPT udp -- * * 201.10.128.3 0.0.0.0/0
0 0 ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0
0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmp type 8 limit: avg 1/sec burst 5
0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmp type 0 limit: avg 1/sec burst 5
0 0 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 udp dpt:33434
0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmp type 3
0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmp type 3 code 1
0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmp type 13
0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmp type 14
0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmp type 17
0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmp type 18
0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmp type 5 limit: avg 2/sec burst 5
0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmp type 4 limit: avg 2/sec burst 5
0 0 LSI icmp -- * * 0.0.0.0/0 0.0.0.0/0
0 0 DROP all -- * * 224.0.0.0/8 0.0.0.0/0
0 0 DROP all -- * * 0.0.0.0/0 224.0.0.0/8
0 0 DROP all -- * * 255.255.255.255 0.0.0.0/0
0 0 DROP all -- * * 0.0.0.0/0 0.0.0.0
0 0 DROP all -- * * 0.0.0.0/0 0.0.0.0/0 state INVALID
0 0 LSI all -f * * 0.0.0.0/0 0.0.0.0/0 limit: avg 10/min burst 5
8 1579 INBOUND all -- eth0 * 0.0.0.0/0 0.0.0.0/0
4 247 INBOUND all -- eth1 * 0.0.0.0/0 10.1.1.1
0 0 INBOUND all -- eth1 * 0.0.0.0/0 187.7.131.36
2 286 INBOUND all -- eth1 * 0.0.0.0/0 10.1.1.255
4 572 LOG_FILTER all -- * * 0.0.0.0/0 0.0.0.0/0
4 572 LOG all -- * * 0.0.0.0/0 0.0.0.0/0 LOG flags 0 level 6 prefix `Unknown Input'
Chain FORWARD (policy DROP 19 packets, 19665 bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmp type 8 limit: avg 1/sec burst 5
0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmp type 0 limit: avg 1/sec burst 5
0 0 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 udp dpt:33434
0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmp type 3
0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmp type 3 code 1
0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmp type 17
0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmp type 18
0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmp type 5 limit: avg 2/sec burst 5
0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmp type 4 limit: avg 2/sec burst 5
0 0 LSI icmp -- * * 0.0.0.0/0 0.0.0.0/0
138 6420 TCPMSS tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp flags:0x06/0x02 TCPMSS clamp to PMTU
0 0 ACCEPT tcp -- eth0 * 0.0.0.0/0 10.1.1.49 tcp dpts:1:6889
0 0 ACCEPT udp -- eth0 * 0.0.0.0/0 10.1.1.49 udp dpts:1:6889
8260 481K OUTBOUND all -- eth1 * 0.0.0.0/0 0.0.0.0/0
12535 16M ACCEPT tcp -- * * 0.0.0.0/0 10.1.1.0/24 state RELATED,ESTABLISHED
58 8516 ACCEPT udp -- * * 0.0.0.0/0 10.1.1.0/24 state RELATED,ESTABLISHED
0 0 LOG_FILTER all -- * * 0.0.0.0/0 0.0.0.0/0
0 0 LOG all -- * * 0.0.0.0/0 0.0.0.0/0 LOG flags 0 level 6 prefix `Unknown Forward'
Chain OUTPUT (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT tcp -- * * 187.7.131.36 201.10.120.2 tcp dpt:53
0 0 ACCEPT udp -- * * 187.7.131.36 201.10.120.2 udp dpt:53
0 0 ACCEPT tcp -- * * 187.7.131.36 201.10.128.3 tcp dpt:53
6 460 ACCEPT udp -- * * 187.7.131.36 201.10.128.3 udp dpt:53
0 0 ACCEPT all -- * lo 0.0.0.0/0 0.0.0.0/0
0 0 DROP all -- * * 224.0.0.0/8 0.0.0.0/0
0 0 DROP all -- * * 0.0.0.0/0 224.0.0.0/8
0 0 DROP all -- * * 255.255.255.255 0.0.0.0/0
0 0 DROP all -- * * 0.0.0.0/0 0.0.0.0
0 0 DROP all -- * * 0.0.0.0/0 0.0.0.0/0 state INVALID
10 2374 OUTBOUND all -- * eth0 0.0.0.0/0 0.0.0.0/0
4 1447 OUTBOUND all -- * eth1 0.0.0.0/0 0.0.0.0/0
0 0 LOG_FILTER all -- * * 0.0.0.0/0 0.0.0.0/0
0 0 LOG all -- * * 0.0.0.0/0 0.0.0.0/0 LOG flags 0 level 6 prefix `Unknown Output'
Chain INBOUND (4 references)
pkts bytes target prot opt in out source destination
8 1579 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
0 0 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
6 533 ACCEPT all -- * * 10.1.1.0/24 0.0.0.0/0
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:22
0 0 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 udp dpt:22
0 0 ACCEPT tcp -- * * 10.1.1.0/24 0.0.0.0/0 tcp dpt:53
0 0 ACCEPT udp -- * * 10.1.1.0/24 0.0.0.0/0 udp dpt:53
0 0 LSI all -- * * 0.0.0.0/0 0.0.0.0/0
Chain LOG_FILTER (5 references)
pkts bytes target prot opt in out source destination
Chain LSI (4 references)
pkts bytes target prot opt in out source destination
0 0 LOG_FILTER all -- * * 0.0.0.0/0 0.0.0.0/0
0 0 LOG tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp flags:0x17/0x02 limit: avg 1/sec burst 5 LOG flags 0 level 6 prefix `Inbound '
0 0 DROP tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp flags:0x17/0x02
0 0 LOG tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp flags:0x17/0x04 limit: avg 1/sec burst 5 LOG flags 0 level 6 prefix `Inbound '
0 0 DROP tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp flags:0x17/0x04
0 0 LOG icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmp type 8 limit: avg 1/sec burst 5 LOG flags 0 level 6 prefix `Inbound '
0 0 DROP icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmp type 8
0 0 LOG all -- * * 0.0.0.0/0 0.0.0.0/0 limit: avg 5/sec burst 5 LOG flags 0 level 6 prefix `Inbound '
0 0 DROP all -- * * 0.0.0.0/0 0.0.0.0/0
Chain LSO (0 references)
pkts bytes target prot opt in out source destination
0 0 LOG_FILTER all -- * * 0.0.0.0/0 0.0.0.0/0
0 0 LOG all -- * * 0.0.0.0/0 0.0.0.0/0 limit: avg 5/sec burst 5 LOG flags 0 level 6 prefix `Outbound '
0 0 REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
Re: Regras de NAT para acesso a 2º servidor
continuação (não coube em um só post)
Código :
Chain OUTBOUND (3 references)
pkts bytes target prot opt in out source destination
0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0
8123 470K ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
79 11613 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
72 3448 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0
root@serverlinux:/etc#
Re: Regras de NAT para acesso a 2º servidor
Faltou a tabela NAT!
# iptables -t nat -L -n
Re: Regras de NAT para acesso a 2º servidor
Falta na tabela FILTER e na chain FORWARD (exemplo como se fosse no iptables puro):
# iptables -t FILTER -A FORWARD -p tcp -m tcp --dport 5432 -j ACCEPT
Isso encaminhará o tráfego com destino à porta 5432 para o servidor Windows.
Na tabela NAT e na chain PREROUTING (exemplo como se fosse no iptables puro):
# iptables -t NAT -A PREROUTING -i eth0 -p tcp -m tcp --dport 5432 -DNAT --to-destination 10.1.1.49
Isso realizar o NAT nas conexões pra porta 5432, encaminhando todas para o IP 10.1.1.49.
Depois verifique se funcionou.
Re: Regras de NAT para acesso a 2º servidor
Código :
root@serverlinux:/etc# iptables -t nat -L -n
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpts:1:6889 to:10.1.1.49:1-6889
DNAT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpts:1:6889 to:10.1.1.49:1-6889
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
MASQUERADE all -- 0.0.0.0/0 0.0.0.0/0
root@serverlinux:/etc#
vou rodar os dois comandos que vocme indicou e ver como se comporta!
Re: Regras de NAT para acesso a 2º servidor
Os dois comandos sugeridos deram problemas! Segue abaixo a tela dos mesmos:
Código :
root@serverlinux:/etc# iptables -t FILTER -A FORWARD -p tcp -m tcp --dport 5432 -j ACCEPT
iptables v1.4.4: can't initialize iptables table `FILTER': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.
root@serverlinux:/etc# iptables -t NAT -A PREROUTING -i eth0 -p tcp -m tcp --dport 5432 -DNAT --to-destination 10.1.1.49
iptables v1.4.4: Cannot use -D with -A
Try `iptables -h' or 'iptables --help' for more information.
root@serverlinux:/etc#
Re: Regras de NAT para acesso a 2º servidor
Qual versão do Ubuntu está instalada no servidor ???
Ubuntu Server ou Ubuntu Desktop???
Re: Regras de NAT para acesso a 2º servidor
Ubuntu 10.10 Desktop!
Até instalei a versão server, mas de keito algum conseguia rodar a interface gráfica!
Re: Regras de NAT para acesso a 2º servidor
O ideal é que fique sem interface gráfica, pois assim, sobra mais memória. Pois o X consome muita memória.
Cria um script para o iptables, verá, que será melhor que o firestater, você terá mais liberdade para modificá-lo melhor e tirar suas dúvidas no Underlinux. Qualquer coisa estou aqui.