Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[RISOLTO] iptables port forwarding
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
This topic is locked: you cannot edit posts or make replies.    Gentoo Forums Forum Index Forum italiano (Italian) Forum di discussione italiano
View previous topic :: View next topic  
Author Message
koma
Advocate
Advocate


Joined: 06 Jun 2003
Posts: 2700
Location: Italy

PostPosted: Mon Jun 04, 2012 4:15 pm    Post subject: [RISOLTO] iptables port forwarding Reply with quote

Ciao a tutti :),

E' parecchio che non smanetto con iptables e quindi ho bisogno di un ripassino.

Ho due macchine in due parti diverse del pianeta.
Per pura comodità devo forwardare tutte le richieste in arrivo sulla porta 8081 della macchina A alla porta 80 della macchina B.
NB:
non sono sulastessa lan quindi non devo fare nat.

Tant'evvero che queste stringe di iptables sulla macchina A.A.A.A non funzicano in quanto mi maschera i pacchetti con l'ip del client di provenienza e quindi il mio server B.B.B.B risponde su un gateway che non sa cosa farsene di quei pacchetti :D.
Code:

/sbin/iptables -t nat -A PREROUTING -p tcp -i eth0  --dport 8081 -j DNAT --to B.B.B.B:80
/sbin/iptables -A FORWARD -p tcp -i eth0 -d B.B.B.B --dport 80 -j ACCEPT

Suggerimenti?
_________________
Remember! Gnu is not Unix!
http://www.youtube.com/watch?v=_yoJI-Tl94g GLORY GLORY HYPNOTOAD
Linux Counter[code:1]
User n° #466586
ID 375005 EkatombeII
ID 375006 Apocalypto
ID 375007 KHP[/code:1]


Last edited by koma on Mon Jun 04, 2012 4:37 pm; edited 1 time in total
Back to top
View user's profile Send private message
koma
Advocate
Advocate


Joined: 06 Jun 2003
Posts: 2700
Location: Italy

PostPosted: Mon Jun 04, 2012 4:37 pm    Post subject: Reply with quote

Mi rispondo da solo!

Code:
iptables -t nat -A PREROUTING --dst $YourIP -p tcp --dport $YourPort -j DNAT --to-destination $TargetIP:$TargetPort
iptables -t nat -A POSTROUTING -p tcp --dst $TargetIP --dport $TargetPort -j SNAT --to-source $YourIP
iptables -t nat -A OUTPUT --dst $YourIP -p tcp --dport $YourPort -j DNAT --to-destination $TargetIP:$TargetPort

_________________
Remember! Gnu is not Unix!
http://www.youtube.com/watch?v=_yoJI-Tl94g GLORY GLORY HYPNOTOAD
Linux Counter[code:1]
User n° #466586
ID 375005 EkatombeII
ID 375006 Apocalypto
ID 375007 KHP[/code:1]
Back to top
View user's profile Send private message
ago
Developer
Developer


Joined: 01 Mar 2008
Posts: 1493
Location: Cosenza, Italy

PostPosted: Tue Jun 05, 2012 9:15 am    Post subject: Reply with quote

Moved from Forum italiano (Italian) to Forum di discussione italiano.
_________________
Contattami se vuoi contribuire in:
-Arch tester
-Chromium tester
-Traduzione doc. it
-Security
Back to top
View user's profile Send private message
.:deadhead:.
Advocate
Advocate


Joined: 25 Nov 2003
Posts: 2960
Location: Milano, Italy

PostPosted: Tue Jun 12, 2012 10:28 am    Post subject: Reply with quote

koma wrote:
Mi rispondo da solo!

Marzulliano :D

grazie per aver condiviso anche la risposta!
_________________
Proudly member of the Gentoo Documentation Project: the Italian Conspiracy ! ;)
Back to top
View user's profile Send private message
djinnZ
Advocate
Advocate


Joined: 02 Nov 2006
Posts: 4720
Location: not so far from an evil, world famous volcano. Under dictatorship, idiocracy, property of banks...

PostPosted: Tue Jun 12, 2012 12:46 pm    Post subject: Reply with quote

.:deadhead:. wrote:
koma wrote:
Mi rispondo da solo!
grazie per aver condiviso anche la risposta!
Non per essere il solito puntiglioso ... ma non si ringrazia una persona per aver mostrato civiltà e buona educazione (oltre che aver capito come deve andare un forum come questo), ci si congratula o lo si elogia.

:twisted: :twisted: :twisted:
_________________
scita et risus abundant in ore stultorum sed etiam semper severi insani sunt:wink:
mala tempora currunt...mater stultorum semper pregna est :evil:
Murpy'sLaw:If anything can go wrong, it will - O'Toole's Corollary:Murphy was an optimist :wink:
Back to top
View user's profile Send private message
.:deadhead:.
Advocate
Advocate


Joined: 25 Nov 2003
Posts: 2960
Location: Milano, Italy

PostPosted: Wed Jun 13, 2012 9:09 am    Post subject: Reply with quote

elogiare comportamenti positivi ne favorisce la diffusione - anche se possono sembrare comportamenti normali o ovvi.
_________________
Proudly member of the Gentoo Documentation Project: the Italian Conspiracy ! ;)
Back to top
View user's profile Send private message
Display posts from previous:   
This topic is locked: you cannot edit posts or make replies.    Gentoo Forums Forum Index Forum italiano (Italian) Forum di discussione italiano 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