I have an alias for eth0
called eth0:0
.
Short version: I want to route packets from one virtual interface to another through an external gateway and not through the loopback interface.
Detailed: I want to route packets from eth0:0
(by using LD_PRELOAD
, I can change the src IP address) to eth0
. But this is handled by lo
interface and I don't want that. What I want is that packets from eth0:0
should go to some default gateway which will then send process the packets and then send to eth0
.
I can send packets with the source IP address of the eth0:0
alias but the complete setup is not working since I cannot allocate different MAC
addresses for the eth0
and eth0:0
and so when the external gateway has to send the packets back, it can't figure out where to send the packets to.
What is a good way of achieving this?
EDIT: I have been told that the question was not clear.
eth0: IP address: 10.0.0.1
eth0:1: IP address: 10.0.0.2
Gateway: 10.0.0.10
I want to send packets from 10.0.0.2 to 10.0.0.1 through the external gateway 10.0.0.10 so that I can do some processing on the packets and then send to 10.0.0.1.
Basically, 10.0.0.0.2 <-> gateway <-> 10.0.0.1