LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices



Reply
 
Search this Thread
Old 06-24-2009, 09:47 AM   #1
dlugasx
Member
 
Registered: Dec 2008
Location: Germany/Poland
Distribution: CentOS / Debian / Solaris / RedHat
Posts: 250

Rep: Reputation: 18
iptables - redirection port from alias - problem


hi all,

does anybody knows how can I forward port using iptables ?

in my server I have three interfaces


eth0 xx.xx.xx.xx

eth1 xx.xx.xx.xx

eth0:1 xx.xx.xx.xx

eth0:2 88.88.88.88 (ip is not real just for example)

I would like to redirect port from interface eth0:2 to 192.168.1.12:80.
I know how to do it with normal interface, I mean eth0, eth1 etc etc. Iptables doesnt work correctly with alias eth0:2 on my machine.


How can I redirect port 80 from IP: 88.88.88.88 from interface eth0:2 to local address 192.168.1.12:80 ???

It have to be NAT...


help ...
 
Old 06-25-2009, 04:19 AM   #2
centosboy
Senior Member
 
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137

Rep: Reputation: 116Reputation: 116
Quote:
Originally Posted by dlugasx View Post
hi all,

does anybody knows how can I forward port using iptables ?

in my server I have three interfaces


eth0 xx.xx.xx.xx

eth1 xx.xx.xx.xx

eth0:1 xx.xx.xx.xx

eth0:2 88.88.88.88 (ip is not real just for example)

I would like to redirect port from interface eth0:2 to 192.168.1.12:80.
I know how to do it with normal interface, I mean eth0, eth1 etc etc. Iptables doesnt work correctly with alias eth0:2 on my machine.


How can I redirect port 80 from IP: 88.88.88.88 from interface eth0:2 to local address 192.168.1.12:80 ???

It have to be NAT...


help ...
The beauty of linux is several ways to do one thing.

One way would be

Code:
iptables -i eth0 -t nat -A PREROUTING -p tcp -d 15.45.23.67 --dport 80 -j DNAT --to-destination 192.168.1.1:80
specifying port and incoming ip is optional..

Code:
iptables -i eth0 -t nat -A PREROUTING -p tcp  -j DNAT --to-destination ipaddr/ipaddrrange/port/portrange

man iptables




actually.....i dont think i have even answered your question....i just read it properly...

Last edited by centosboy; 06-25-2009 at 04:32 AM.
 
  


Reply

Tags
alias, iptables, network, redirect


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
iptables redirection? prayag_pjs Linux - Newbie 3 04-17-2008 12:10 AM
Port redirection with iptables not working as expected. Eric-Mtl Linux - Networking 1 08-16-2007 08:42 AM
Port redirection, iptables, apache questions? sarajevo Linux - Security 2 09-22-2006 07:02 AM
Help:iptables redirection swmok Linux - Networking 2 11-24-2004 08:47 AM
Iptables, Port redirection... and I'm a nimrod finegan Linux - Networking 3 09-14-2003 02:48 PM


All times are GMT -5. The time now is 09:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration