I’m trying to pull a certain routing stunt where I want my Linux server to respond to arp requests for 10.0.0.1
on eth0
, although
10.0.0.1
is not the configured IP foreth0
(in which case the kernel would do this nevertheless) and10.0.0.1
is not routed to some other interface of this server (in which case arp proxying would help).
The effect should be that other devices on eth0
would route packages to 10.0.0.1
to my server, where I can then handle them in PREROUTING
and other tables.
Can I do that, preferably without an additional daemon?
As requested, here is my motivation (but note that this question is not about suggestions how to achieve this by different means – I really am interested in knowing if above is possibly, not whether it is sensible :-)).
Assume 10.0.0.1
to be a public IP address, and the only one routed to the machine in question. The system (host
) contains a virtual machine (guest
). I want guest
to believe 10.0.0.1
is his, so giving it a different IP and doing nat is not what I want to do. Instead, I host
to
- have another ip address (
192.168.0.1
), not publicly routed, - act towards
eth0
as if it had10.0.0.1
, - redirect any access to
10.0.0.1:2222
to192.168.0.1
, i.e. handle it locally, - route any other traffic to
10.0.0.1
towards the virtual interface thatguest
is attached to.
This explains the two constraints in the question: The guest
machine may not always be up, so the mentioned route will not always be there – this is what rules out Proxy ARP. Also, I cannot assing 10.0.0.1
to eth0
, as it is really difficult to make Linux route a package away that is destined to an address that the kernel thinks is local. The local
routing table has priority 0 according to ip rule
, for instance.
What about using IP Aliases such as eth0:1 ? That would cause the interface to respond to ARPs and allow you to manage its behavior with iptables.
Also, its not clear why proxy-arp won't help you here as you could interrupt the expected behavior with the iptables rules.
Can you explain more what you are attempting to accomplish?