• route all traffic to a internal socket

    From Mohsen Pahlevanzadeh@21:1/5 to All on Wed Apr 30 11:30:02 2025
    Dear all,


    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.

    I don't want to use set proxy in firefox and other application, but I
    want to send any packets to 127.0.0.1:7777 and my program itself send to
    eth0.


    How can I implement it?


    Yours,

    Mohsen

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Nicolas George@21:1/5 to All on Wed Apr 30 13:10:01 2025
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jonathan Dowland@21:1/5 to Mohsen Pahlevanzadeh on Wed Apr 30 15:00:02 2025
    On Wed Apr 30, 2025 at 10:19 AM BST, Mohsen Pahlevanzadeh wrote:
    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 can use socat¹ to listen on a port and forward received packets elsewhere. But…

    I don't want to use set proxy in firefox and other application, but I
    want to send any packets to 127.0.0.1:7777 and my program itself send
    to eth0.

    But to what address on the Internet do you wish the packets to go?

    [1] https://packages.debian.org/bookworm/socat

    --
    Please do not CC me for listmail.

    šŸ‘±šŸ» Jonathan Dowland
    āœŽ jmtd@debian.org
    šŸ”— https://jmtd.net

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mohsen Pahlevanzadeh@21:1/5 to Jonathan Dowland on Wed Apr 30 19:30:01 2025
    On 4/30/25 4:29 PM, Jonathan Dowland wrote:
    On Wed Apr 30, 2025 at 10:19 AM BST, Mohsen Pahlevanzadeh wrote:
    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 can use socat¹ to listen on a port and forward received packets elsewhere. But…

    I don't want to use set proxy in firefox and other application, but I
    want to send any packets to 127.0.0.1:7777 and my program itself send
    to eth0.

    But to what address on the Internet do you wish the packets to go?

    Any destination. When packets are released from 127.0.0.1:7777 , No
    difference to which dst.



    [1] https://packages.debian.org/bookworm/socat


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Ritter@21:1/5 to Mohsen Pahlevanzadeh on Wed Apr 30 22:40:01 2025
    Mohsen Pahlevanzadeh wrote:
    On 4/30/25 4:29 PM, Jonathan Dowland wrote:

    On Wed Apr 30, 2025 at 10:19 AM BST, Mohsen Pahlevanzadeh wrote:

    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 can use socat¹ to listen on a port and forward received packets
    elsewhere. But…

    I don't want to use set proxy in firefox and other application, but
    I want to send any packets to 127.0.0.1:7777 and my program itself
    send to eth0.

    But to what address on the Internet do you wish the packets to go?

    I don't want to send one type packet and one destination. any packet
    and any destination.When packets are released from 127.0.0.1:7777 ,
    this should be sent anywhere.

    OK, there is an underlying assumption that you are not telling
    us.

    Why do you want to do this? What is the program at :7777 going
    to accomplish differently from connecting sockets to the actual
    remote IP addresses?

    -dsr-

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Tim Woodall@21:1/5 to Mohsen Pahlevanzadeh on Thu May 1 04:40:01 2025
    On Wed, 30 Apr 2025, Mohsen Pahlevanzadeh wrote:


    On 4/30/25 4:29 PM, Jonathan Dowland wrote:
    On Wed Apr 30, 2025 at 10:19 AM BST, Mohsen Pahlevanzadeh wrote:
    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 can use socat? to listen on a port and forward received packets
    elsewhere. But?

    I don't want to use set proxy in firefox and other application, but I want >>> to send any packets to 127.0.0.1:7777 and my program itself send to eth0. >>
    But to what address on the Internet do you wish the packets to go?

    Any destination. When packets are released from 127.0.0.1:7777 , No difference to which dst.

    It's not available in the default debian package but have a look at how
    squid can do this when it's an intercepting proxy. (--with-openssl to
    configure i think)

    It uses the (must be local) nat rules to work out where the packet was originally intended for.

    Make the squid host the default route for your traffic.
    On the squid host, nat everything to the proxy port

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Tim Woodall@21:1/5 to Tim Woodall on Thu May 1 10:30:01 2025
    On Thu, 1 May 2025, Tim Woodall wrote:

    On Wed, 30 Apr 2025, Mohsen Pahlevanzadeh wrote:


    On 4/30/25 4:29 PM, Jonathan Dowland wrote:
    On Wed Apr 30, 2025 at 10:19 AM BST, Mohsen Pahlevanzadeh wrote:
    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 can use socat? to listen on a port and forward received packets
    elsewhere. But?

    I don't want to use set proxy in firefox and other application, but I
    want to send any packets to 127.0.0.1:7777 and my program itself send to >>>> eth0.

    But to what address on the Internet do you wish the packets to go?

    Any destination. When packets are released from 127.0.0.1:7777 , No
    difference to which dst.

    It's not available in the default debian package but have a look at how squid can do this when it's an intercepting proxy. (--with-openssl to configure i think)

    It uses the (must be local) nat rules to work out where the packet was originally intended for.

    Make the squid host the default route for your traffic.
    On the squid host, nat everything to the proxy port


    Now I'm not posting in my sleep :-) I suspect that squid handles this in
    the regular debian package too when configured as a transparent proxy.
    The changes are only necessary if you want to do egress filtering of
    https.

    Tim.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Ritter@21:1/5 to Mohsen Pahlevanzadeh on Thu May 1 13:40:01 2025
    Mohsen Pahlevanzadeh wrote:
    I don't want to use set proxy in firefox and other application, but
    I want to send any packets to 127.0.0.1:7777 and my program itself
    send to eth0.

    OK, there is an underlying assumption that you are not telling
    us.

    Why do you want to do this? What is the program at :7777 going
    to accomplish differently from connecting sockets to the actual
    remote IP addresses?

    My program on :7777 is socks5 and ssh tunnel.


    Each program using a socks5 interface needs to be written to be
    able to use the socks5 protocol.

    Each program needs to be configured to use the socks5 proxy as a
    proxy. Otherwise they use the normal networking system.

    Your stated desires conflict with each other.

    -dsr-

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)