Skip to contentSkip to conversation

Redirecting traffic from a non-existent IP

DISCUSSION Julian Hagenauer 2 participants 2 messages Jun 5, 2006

lore
Share & tools
lore
#0 lore raw

Hi,
i am running Linux 2.6.11.12-xen0 (binary distribution).
I want to route all Traffic destined to 192.168.1.5 to 192.168.1.3.
192.168.1.5 is a non-existent IP/host, 192.168.1.3 is a Xen-VM running on localhost, so 192.168.1.5 should act as a kind of alias for 192.168.1.3 and be accessible from localhost. The following modules are loaded:

Module                  Size  Used by
iptable_filter          2432  0 iptable_nat            19932  1 ip_conntrack           38712  1 iptable_nat
ip_tables              20352  2 iptable_filter,iptable_nat
intel_agp              20124  1 agpgart                28968  1 intel_agp

I wrote and ran the following script on localhost:

#!/bin/bash
echo 1 > /proc/sys/net/ipv4/ip_forward MAP_FROM=192.168.1.5 # virtuelle IP MAP_TO=192.168.1.3 # IP einer VM
iptables -t nat -F
echo "Mappe $MAP_FROM nach $MAP_TO..."
iptables -t nat -A PREROUTING -d $MAP_FROM -j DNAT --to $MAP_TO echo "Aktuelle Nat-Regeln:"
iptables -t nat -L

But ping 192.168.1.5 or ssh 192.168.1.5 still does not work. I have no clue what's wrong.

Sincerely,
Julian

#1 lore raw

Hello,

Quoted 4 lines · Julian Hagenauer

Hi,
i am running Linux 2.6.11.12-xen0 (binary distribution).
I want to route all Traffic destined to 192.168.1.5 to 192.168.1.3.
192.168.1.5 is a non-existent IP/host, 192.168.1.3 is a Xen-VM running on localhost, so 192.168.1.5 should act as a kind of alias for 192.168.1.3 and be accessible from localhost.

[...]

Quoted 6 lines

iptables -t nat -A PREROUTING -d $MAP_FROM -j DNAT --to $MAP_TO echo "Aktuelle Nat-Regeln:"
iptables -t nat -L

But ping 192.168.1.5 or ssh 192.168.1.5 still does not work. I have no clue what's wrong.

I guess the problem is ARP. If nothing replies to the ARP requests for 192.168.1.5 sent by th host which want to send a packet to this address, then IP packets for this destination aren't even sent (that should produce Host Unreachable error messages).

Possible workarounds :
- set up some ARP daemon on the network that will reply for 192.168.1.3
- set a static ARP entry in the senders' ARP table (heavy)
- set a static route to 192.168.1.5 with gateway 192.168.1.3 (I know, that's ugly)
- maybe it is possible to use arptables on the NAT box to make it reply to the ARP requests (I don't know anything about this)

I guess IP aliasing is not an option.