NAT: Keine Kommunikation zwischen LAN und öffentlicher Router IP

sim4000

sim4000

Lebende Foren Legende
Moin zusammen,

ich beschäftige mich gerade ein wenig mit iptables und NAT und habe mir dazu einen NAT-Router gebastelt. Es sind bereits einige Portfreigaben eingerichtet, was auch alles super funktioniert.

Aufbau
Code:
öffentlich (eth0)  127.0.0.1     intern (eth1)
91.9.65.78 --- der router --- 192.168.101.1
                                   |--- www.lan.lokal (192.168.101.105)
                                   '--- mail.lan.lokal (192.168.101.101)

Iptables Konfiguration
Code:
# Firewall
*filter
:INPUT DROP [5194:432663]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [3302:462576]


#--> INPUT Chain
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT

-A INPUT -s 127.0.0.0/8 -j ACCEPT
-A INPUT -d 127.0.0.0/8 -j ACCEPT

-A INPUT -s 192.168.101.0/24 -j ACCEPT
-A INPUT -d 192.168.101.0/24 -j ACCEPT

#--> Local Network
-A INPUT -i eth1 -j ACCEPT
-A INPUT -p tcp -i eth1 --dport 53 -j ACCEPT
-A INPUT -p udp -i eth1 --dport 53 -j ACCEPT
-A INPUT -p udp -i eth1 --dport 123 -j ACCEPT

COMMIT
# Filter ende

# Network Address Translation
*nat
:PREROUTING ACCEPT [40:2598]
:POSTROUTING ACCEPT [3:160]
:OUTPUT ACCEPT [19:1291]

#--> Webserver

# HTTP
-A PREROUTING -p tcp -i eth0 --dport 80 -j DNAT --to-destination 192.168.101.105:80

# HTTPS
-A PREROUTING -p tcp --dport 443 -j DNAT --to-destination 192.168.101.105:443

#--> SFTP Apache
-A PREROUTING -i eth0 -p tcp -m tcp --dport 6364 -j DNAT --to-destination 192.168.101.105:22

#--> Mail
# SMTP
-A PREROUTING -i eth0 -p tcp -m tcp --dport 25 -j DNAT --to-destination 192.168.101.101:25   
# POP3
-A PREROUTING -i eth0 -p tcp -m tcp --dport 110 -j DNAT --to-destination 192.168.101.101:110 
# IMAP
-A PREROUTING -i eth0 -p tcp -m tcp --dport 143 -j DNAT --to-destination 192.168.101.101:143 
# SMTPs
-A PREROUTING -i eth0 -p tcp -m tcp --dport 465 -j DNAT --to-destination 192.168.101.101:465 
# IMAPs
-A PREROUTING -i eth0 -p tcp -m tcp --dport 993 -j DNAT --to-destination 192.168.101.101:993 
# POP3s
-A PREROUTING -i eth0 -p tcp -m tcp --dport 995 -j DNAT --to-destination 192.168.101.101:995

-A POSTROUTING -o eth0 -j MASQUERADE 
COMMIT
# NAT ende

Von einer internen Maschine ins WWW und umgekehrt funktioniert wunderbar. Möchte ich jetzt aber von www.lan.lokal eine Domain aufrufen die auf www.lan.lokal gehostet ist, gibt es ein Connection Refused. Ein Portscan mit nmap zeigt auch, dass von hier auf Port 80 (Portforwarding Port) auf dem Router geschlossen ist.

Hat jemand eine Idee woran das liegen kann?

Viele Grüße
Christian
 
So, Ursache gefunden.

Code:
*nat
:PREROUTING ACCEPT [40:2598]
:POSTROUTING ACCEPT [3:160]
:OUTPUT ACCEPT [19:1291]
:WANPREROUTING - [0:0]
:WANPOSTROUTING - [0:0]

-A PREROUTING -d 91.9.65.78 -j WANPREROUTING
-A POSTROUTING -s 192.168.101.1/255.255.255.0 -j WANPOSTROUTING

# HTTP
-A WANPREROUTING -p tcp --dport 80 -j DNAT --to-destination 192.168.101.105:80
-A WANPOSTROUTING -p tcp --dport 80 -d 192.168.101.105 -j SNAT --to-source 91.9.65.78

# HTTPS
-A WANPREROUTING -p tcp --dport 443 -j DNAT --to-destination 192.168.101.105
-A WANPOSTROUTING -p tcp --dport 443 -d 192.168.101.105 -j SNAT --to-source 91.9.65.78

-A WANPREROUTING -j RETURN
-A WANPOSTROUTING -j RETURN

# Adress translation for outgoing packets
-A POSTROUTING -o eth0 -j MASQUERADE

COMMIT

Abscheidend hat das Interface als Bedingung (-i eth0) nicht gereicht. Ich habe jetzt zwei neue Chains angelegt welche als Bedingung die öffentliche bzw interne IP benutzen. Jetzt Funktionieren alle drei Fälle. WWW->Intern, Intern->WWW, Intern->Intern.

Viele Grüße
Christian
 

Ähnliche Themen

Port Forwarding mit iptables

ip6tables Problem

iptables verständniss frage, xrdp nicht erreichbar.

[SOLVED][CentOS 7] Samba server nicht erreichbar trotz firewall regeln.

Wired-Lan komisches Verhalten

Zurück
Oben