0

Is it somehow possible to use Xinetd (or any other solution) to listen to incoming Packets for an IP Adress which is not assigned to an interface, and start up a daemon (like Xinetd) does?

So my Linux Machine is the default GW, all Packets are sent to it. I would like to recognize specific packets with a destination IP, which is not bound to an interface and react to it (start up a daemon)

Thanks!

Manuel
  • 111
  • 2

2 Answers2

0

Yes, enable a net.ipv4.ip_nonlocal_bind setting:

echo "net.ipv4.ip_nonlocal_bind = 1" > /etc/sysctl.d/enable-nolocal-bind.conf"
sysctl net.ipv4.ip_nonlocal_bind=1

(the latter is "enable it now", the first line is to make this persistent). Now you can bind daemons to any IP address.

However, this might not work as you expected. In the same LAN computers don't use the default gw to communicate. They send packets directly, e.g. making ARP queries to findd out MAC address of the system where to send a packet. If there is no reply, it won't revert to sending a packet to a default gw. It will fail with the error instead.

Nikita Kipriyanov
  • 8,033
  • 1
  • 21
  • 39
0

On Linux, routes of type local are loopback, and will be delivered to localhost. Also known as AnyIP.

Route as large of a prefix as desired. If using IPv6, perhaps reserve an entire /64 for the purpose, say 2001:db8:bdd2:c0e::/64. Route that to this host (the Linux box), and in the Linux box send it to local.

Configure xinetd to listen on the desired port.

End result, any IP in that net, say 2001:db8:bdd2:c0e::138, will terminate on this box, and start the server program.

John Mahowald
  • 30,009
  • 1
  • 17
  • 32