Mohsen Pahlevanzadeh (HE12025-04-30):
> I have a debian machine and my program listen to 7777 such as: 127.0.0.1
> 
> I want to send any packet to 127.0.0.1:7777 and it sends my packets to
> internet. my outgoing interface is eth0.

You need to set up a virtual network interface, using /dev/net/tun, and
configure it to be the default route.

Then you will have to encapsulate all you get from /dev/net/tun into a
packet for your program listening on 127.0.0.1:7777 to attach all the
headers that do not fit into UDP or TCP. But at this point you might as
well realize that your initial goal of sending everything to a UDP or
TCP server was a mistake and just do the job directly from the data on
/dev/net/tun.

You will also need to let your program itself bypass so that the packets
it tries to really send will not loop back to itself. This will probably
require routing and firewall rules.

What you are trying to achieve looks a lot like VPN software, look it
up.

Regards,

-- 
  Nicolas George

Reply via email to