why iptables redirect rule jumps to 127.0.0.1?
by huria_heep from LinuxQuestions.org on (#576G8)
Hi everybody, I've been using Slackware for the last 15 years now but I've never bumped into this problem:
I've got multiple ssl sites on my desktop (Apache) so I decided to assign 2 ip addresses to the same eth (eth0 192.168.1.3 and eth1 192.168.1.33). Apache listens to ports 8088 and 443.
In httpd-vhosts.confthere are some
<VirtualHost *:8088>
...
"Redirect permanent / https://lg.site1.org/"
...
etc
I also thought it would be enough to put some rules in iptables to intercept the traffic directed to port 80 and redirect it to port 8088. And this indeed works except for the traffic to eth1 (the second ip address) the following rule
$IPTABLES -t nat -A PREROUTING -s $LOCAL_NET -d 192.168.1.33 -p tcp --dport 80 -j REDIRECT --to-ports 8088
redirects the traffic to port 8088, but to address 192.168.1.3 (which is eth0) Why?
Shall I have to go through Dnat, masquerade etc?
Thank you for watching and help.


I've got multiple ssl sites on my desktop (Apache) so I decided to assign 2 ip addresses to the same eth (eth0 192.168.1.3 and eth1 192.168.1.33). Apache listens to ports 8088 and 443.
In httpd-vhosts.confthere are some
<VirtualHost *:8088>
...
"Redirect permanent / https://lg.site1.org/"
...
etc
I also thought it would be enough to put some rules in iptables to intercept the traffic directed to port 80 and redirect it to port 8088. And this indeed works except for the traffic to eth1 (the second ip address) the following rule
$IPTABLES -t nat -A PREROUTING -s $LOCAL_NET -d 192.168.1.33 -p tcp --dport 80 -j REDIRECT --to-ports 8088
redirects the traffic to port 8088, but to address 192.168.1.3 (which is eth0) Why?
Shall I have to go through Dnat, masquerade etc?
Thank you for watching and help.