I created a tap device using the following commands:
sudo ip tuntap add mode tap tap7
sudo ip link set tap7 up
sudo ip addr add 77.0.0.1/24 dev tap7
Now, I am using c++ sockets programming to write packets to tap7
and I am able to capture them with wireshark when it listens to tap7
interface.
What I need is to create a rule that any packet written to tap7
should be redirected to the ip 127.0.0.1
.
I tried the following commands:
sudo iptables -A PREROUTING -t nat -i tap7 -j DNAT --to 127.0.0.1
sudo iptables -A INPUT -i tap7 -j ACCEPT
However, when I listen on wireshark, I still see that packets are captured on tap7
and not captured from lo
device. Does anyone have an idea why?