Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    How to know the interface name from tcp socket desc

    I am writting a telnet server. I need a way to know from what interface a client is sending the message(eth0, eth1, ppp, usb etc). All I have is the socket descriptor in the server. Is there any structure that would give the interface name?

  2. #2
    Just Joined!
    Join Date
    Dec 2009
    I am not aware of a structure that would tell you the interface name. The more I think about it, this would actually be a layer violation.

    That being said, can you explain why you care on what interface the incoming connection is?

    If you are looking for your server to behave differently depending on the interface on which the connection is established, then I would think a way to do it would be to bind your server to a specific IP address and pass the desired behavior as an option on the command line.

  3. #3
    Linux User
    Join Date
    Nov 2008
    Tokyo, Japan
    The only way I can think to do this is to build a back-door into your telnet client. The server alone can't do it. If you build a back-door triggered by an escape code into the client that could, for example, execute the "ifconfig" command and return the result to the server, you could match the interface to the IP address of the incoming socket.

  4. $spacer_open

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts