Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Zu blöd für iptables (Port forwarding)
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German)
View previous topic :: View next topic  
Author Message
BlaZoR
n00b
n00b


Joined: 06 May 2004
Posts: 30
Location: Paderborn, NRW, Germany

PostPosted: Wed Mar 03, 2010 8:56 am    Post subject: Zu blöd für iptables (Port forwarding) Reply with quote

Hiho,

Ich bin gerade irgendwie zu blöd für iptables.

Folgende Situation:
Ich verbinde meinen Heimserver via OpenVPN mit meinem Rootserver. Nun möchte ich, dass wenn ich versuche zu dem Rootserver eine SSH Verbindung aufzubauen auf Port 20022, dass er auf meinen Heimserver weiterleitet, also 10.1.0.11:22. Was tun?

Ich habs u.a. hiermit probiert (auf dem Rootserver):
Quote:
iptables -t nat -A PREROUTING -p tcp -i eth0 --dport 20022 -j DNAT --to-destination 10.1.0.11:22
iptables -A FORWARD -p tcp -d 10.1.0.11 --dport 22 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT



Aber funzt nicht, bekomme einen Timeout beim Connectversuch :(

Jemand ne Idee?

Gruß
BlaZoR
Back to top
View user's profile Send private message
papahuhn
l33t
l33t


Joined: 06 Sep 2004
Posts: 626

PostPosted: Wed Mar 03, 2010 9:54 am    Post subject: Reply with quote

DNAT ändert die Zieladresse aber nicht die Quelladresse. D.h. selbst wenn das Paket von Quelle Q über den Tunnel bei deinem Heimserver ankommt, sieht dein Heimserver diese Quelladresse und versucht Antwortpakete an Q zu schicken. Q kann diese Pakete aber nicht zuordnen, er erwartet ja Antworten vom Rootserver. Du müsstest also beides NATen, source und destination.
_________________
Death by snoo-snoo!
Back to top
View user's profile Send private message
BlaZoR
n00b
n00b


Joined: 06 May 2004
Posts: 30
Location: Paderborn, NRW, Germany

PostPosted: Wed Mar 03, 2010 10:08 am    Post subject: Reply with quote

Und das stell ich mit SNAT an richtig?

Dann hab ich jetzt das hinzugefügt:
Quote:
iptables -A POSTROUTING -s 10.1.0.0/24 -o eth0 -j SNAT --to-source $ext_serveripadresse


Funktioniert aber immernoch nicht :(
Back to top
View user's profile Send private message
papahuhn
l33t
l33t


Joined: 06 Sep 2004
Posts: 626

PostPosted: Wed Mar 03, 2010 10:51 am    Post subject: Reply with quote

Die Quelle ist doch bestimmt nicht aus dem 10.1.0.0/24er Netz, oder doch?
_________________
Death by snoo-snoo!
Back to top
View user's profile Send private message
BlaZoR
n00b
n00b


Joined: 06 May 2004
Posts: 30
Location: Paderborn, NRW, Germany

PostPosted: Wed Mar 03, 2010 10:54 am    Post subject: Reply with quote

10.1.0.0/24 ist halt das VPN Netz. Verwechsel ich das gerade irgendwie?
Back to top
View user's profile Send private message
papahuhn
l33t
l33t


Joined: 06 Sep 2004
Posts: 626

PostPosted: Wed Mar 03, 2010 11:05 am    Post subject: Reply with quote

Scheint so.
"-s a.b.c.d" matcht doch die Quelladresse eines Paketes. Wenn da eine Anfrage aus dem wilden Internet reinkommt, ist die Quelladresse irgendwas aus dem öffentlichen Netz, z.B. T-Online, und nicht 10.x.y.z.
_________________
Death by snoo-snoo!
Back to top
View user's profile Send private message
AmonAmarth
l33t
l33t


Joined: 03 Mar 2005
Posts: 727

PostPosted: Wed Mar 03, 2010 10:25 pm    Post subject: Reply with quote

was steht in
Code:
cat /proc/sys/net/ipv4/ip_forward
? sollte für deine Zwecke eine "1" sein...
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum