C TCP Socket - Get packet destination name

tier1

This is more hypothetical at this point but lets say I have a TCP server written in C running on Linux. Is it possible to obtain the destination name from an individual packet? For example, if client connects and my server is located at www.example.com. I would like to be able to obtain "www.example.com" from the incoming packet.

My end goal is to separate network traffic by destination name similar to the way that IIS does on Windows with bindings for websites.

It would be nice to have multiple services running on the same machine and be accessible through the same port: 443, but be able to be separated by domain name. If I can obtain the destination name from the packet, I'm pretty sure that I can write something like this fairly easily.

--Edit I have done a little bit of research but have come up empty. I've looked through previous servers that I have written and I don't think I can do it with the existing Linux socket layer. I might have to go lower than that.

Roddy

No, because the destination hostname is never sent.

The sender uses DNS to find the IP address for the host it wants to communicate with, then sends a packet to that IP address. (Lower level still, the IP address is translated to a MAC address, which is what the hardware layer uses)

Your TCP sockets layer should allow you to see the source and destination IP addresses for the socket, and you'd then have to do a reverse-DNS lookup to translate that back to a hostname. But remember that one IP address could translate to multiple host names...

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Socket TCP Communication packet splitted

From Dev

TCP socket programming regarding the packet and buffer size

From Dev

What does it mean to get such a high TCP packet

From Dev

How to know packet loss stats of specific TCP socket in Linux?

From Dev

C Threaded Sockets - tcp with TLS, Can't get ip/ether packet headers

From Dev

How do you force linux to treat a tcp packet as if it were at the destination ip?

From Dev

Raw socket packet receiver in C, strange output

From Dev

Raw socket packet receiver in C, strange output

From Dev

C-Server Socket become wrong Packet

From Dev

How to get packet.tcp.payload and packet.http.data as string?

From Dev

Python - socket.recvfrom() get entire IP/UDP packet?

From Dev

Send packet from server to a specific client using TCP c#

From Dev

How to disable packet loss prevention TCP c#

From Dev

TCP checksum is incorrect when trying to send packet in C

From Dev

Does windows TCP stack sends ACK when the packet is received by the kernel or after the socket read?

From Dev

Is it possible to create a single socket, single thread, TCP/IP packet reader for multiple clients?

From Dev

Get the server name from socket

From Dev

Reading the maximum size of an expected packet from a C socket

From Dev

Creating TCP packet with POX

From Dev

Parsing a TCP Packet data

From Dev

Print TCP Packet Data

From Dev

reassembly of tcp packet

From Dev

Send TCP packet in PHP

From Dev

TCP FIN in separate packet

From Dev

segmentation fault in linux (socket programming (TCP) in C)

From Dev

C# TCP Socket stream message confusion

From Dev

send struct over tcp socket in c

From Dev

Windows TCP Socket Timeout C++

From Dev

C socket, send message after file, TCP

Related Related

HotTag

Archive