LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   iptables - redirection port from alias - problem (https://www.linuxquestions.org/questions/linux-networking-3/iptables-redirection-port-from-alias-problem-735287/)

dlugasx 06-24-2009 08:47 AM

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 ...

centosboy 06-25-2009 03:19 AM

Quote:

Originally Posted by dlugasx (Post 3584688)
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... :)


All times are GMT -5. The time now is 04:33 AM.