Quote:
Originally Posted by alouks
I have a web server currently set to a static ip (x.x.x.45) on eth0:1
On eth0:2 i have another ip address (x.x.x.67) When the .67 address is accessed, i need it to route traffic to ANOTHER web server (x.x.x.130)
|
Code:
iptables -t nat -A PREROUTING -i eth0:2 -d x.x.x67 -j DNAT --to x.x.x.130
Now about the routing part for which you want these x.x.x.130 packets to traverse out from a selective interface;
(only if you do not want these packets to traverse out via default route)
Create a rule for this;
Code:
ip ru add to x.x.x.130 table 100
& route for the above mentioned table;
Code:
ip route via <gateway-ip-of-the-interface-you-want-this-to-go-out> table 100
& if you happen to have same gateway-ip for different ips; then you can also mention dev eth<x> in the above ip route command.
run
Code:
#ip rou flush cache
& thts it you are done !!!
// The reason for creating the rule for this route to be processed prior to the default route(static kernel routing tables).