Enabling packet forwarding on linux VM

1

I have a linux VM running on my mac.

I enabled port forwarding to forward any traffic to my machine to my virtual machine, where I had a netcat server logging the traffic to the console.

This worked and I was able to write every incoming packet to the console.

I then tried to enable packet forwarding in order to forward tunneled packets out to the internet and back, with no success.

I enabled ip forwarding on the linux VM by running:

sysctl -w net.ipv4.ip_forward=1

And then I used iptables to try and forward packets from one interface to the other using:

iptables -A FORWARD -i eth0 -o eth1 -j ACCEPT
iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT

Where eth0 was the interface where the netcat server was listening on and eth1 was the interface to forward the traffic to the internet.

However, after this config (and trying some variations on the ip table rules) I am unable to forward the packets to the internet.

From my understanding, I am simply trying to forward a tunneled packet destined for my machine, whose payload is another ip packet, by writing the packet from one interface to the other?

Any suggestions on getting this setup to forward the packets to the internet?

cg14

Posted 2018-07-24T15:30:13.647

Reputation: 29

No answers