Skip to main content
added 248 characters in body
Source Link
harrymc
  • 1
  • 31
  • 579
  • 995

RAW sockets are bound to interfaces. When a message arrives on the interface, the kernel will find all raw sockets that are bound to the protocol number seen in the packet or have issued "connect" to the sending IP.

Any and all raw sockets that match these will receive the packets.

For more precise rules, this text is taken from Microsoft's TCP/IP Raw Sockets:

Received datagrams are copied into all SOCK_RAW sockets that satisfy the following conditions:

  • The protocol number specified in the protocol parameter when the socket was created should match the protocol number in the IP header of the received datagram.
  • If a local IP address is defined for the socket, it should correspond to the destination address as specified in the IP header of the received datagram. An application may specify the local IP address by calling the bind function. If no local IP address is specified for the socket, the datagrams are copied into the socket regardless of the destination IP address in the IP header of the received datagram.
  • If a foreign address is defined for the socket, it should correspond to the source address as specified in the IP header of the received datagram. An application may specify the foreign IP address by calling the connect or WSAConnect function. If no foreign IP address is specified for the socket, the datagrams are copied into the socket regardless of the source IP address in the IP header of the received datagram.

For Linux, there is a less-detailed description in raw(7) - Linux manual page:

All packets or errors matching the protocol number specified for the raw socket are passed to this socket.

RAW sockets are bound to interfaces. When a message arrives on the interface, the kernel will find all raw sockets that are bound to the protocol number seen in the packet or have issued "connect" to the sending IP.

Any and all raw sockets that match these will receive the packets.

For more precise rules, this text is taken from Microsoft's TCP/IP Raw Sockets:

Received datagrams are copied into all SOCK_RAW sockets that satisfy the following conditions:

  • The protocol number specified in the protocol parameter when the socket was created should match the protocol number in the IP header of the received datagram.
  • If a local IP address is defined for the socket, it should correspond to the destination address as specified in the IP header of the received datagram. An application may specify the local IP address by calling the bind function. If no local IP address is specified for the socket, the datagrams are copied into the socket regardless of the destination IP address in the IP header of the received datagram.
  • If a foreign address is defined for the socket, it should correspond to the source address as specified in the IP header of the received datagram. An application may specify the foreign IP address by calling the connect or WSAConnect function. If no foreign IP address is specified for the socket, the datagrams are copied into the socket regardless of the source IP address in the IP header of the received datagram.

RAW sockets are bound to interfaces. When a message arrives on the interface, the kernel will find all raw sockets that are bound to the protocol number seen in the packet or have issued "connect" to the sending IP.

Any and all raw sockets that match these will receive the packets.

For more precise rules, this text is taken from Microsoft's TCP/IP Raw Sockets:

Received datagrams are copied into all SOCK_RAW sockets that satisfy the following conditions:

  • The protocol number specified in the protocol parameter when the socket was created should match the protocol number in the IP header of the received datagram.
  • If a local IP address is defined for the socket, it should correspond to the destination address as specified in the IP header of the received datagram. An application may specify the local IP address by calling the bind function. If no local IP address is specified for the socket, the datagrams are copied into the socket regardless of the destination IP address in the IP header of the received datagram.
  • If a foreign address is defined for the socket, it should correspond to the source address as specified in the IP header of the received datagram. An application may specify the foreign IP address by calling the connect or WSAConnect function. If no foreign IP address is specified for the socket, the datagrams are copied into the socket regardless of the source IP address in the IP header of the received datagram.

For Linux, there is a less-detailed description in raw(7) - Linux manual page:

All packets or errors matching the protocol number specified for the raw socket are passed to this socket.

Source Link
harrymc
  • 1
  • 31
  • 579
  • 995

RAW sockets are bound to interfaces. When a message arrives on the interface, the kernel will find all raw sockets that are bound to the protocol number seen in the packet or have issued "connect" to the sending IP.

Any and all raw sockets that match these will receive the packets.

For more precise rules, this text is taken from Microsoft's TCP/IP Raw Sockets:

Received datagrams are copied into all SOCK_RAW sockets that satisfy the following conditions:

  • The protocol number specified in the protocol parameter when the socket was created should match the protocol number in the IP header of the received datagram.
  • If a local IP address is defined for the socket, it should correspond to the destination address as specified in the IP header of the received datagram. An application may specify the local IP address by calling the bind function. If no local IP address is specified for the socket, the datagrams are copied into the socket regardless of the destination IP address in the IP header of the received datagram.
  • If a foreign address is defined for the socket, it should correspond to the source address as specified in the IP header of the received datagram. An application may specify the foreign IP address by calling the connect or WSAConnect function. If no foreign IP address is specified for the socket, the datagrams are copied into the socket regardless of the source IP address in the IP header of the received datagram.