Skip to main content


 

Article: Network Redirections in Bash.


by Anmol Sarma - software developer from Bengaluru ( #India ).

Preview/extract:

[...] it sends a UDP datagram containing a random number to port 1234 every 250 ms.

while true; do echo $RANDOM > /dev/udp/127.0.0.1/1234; sleep 0.25; done

I didn’t recall ever seeing a /dev/udp and so was a bit surprised that it worked.
Seemingly, a normal UDP socket was being created and written to using the regular sycall interface. That refuted my initial suspicion that some kind of a special file backed by the kernel was involved.
But who was actually creating the socket?
A peek at Bash’s code answered that question [...]

Tags: #linux #bash #ksh #scripting #script #networking #hacking #coding #code #codeanalyse #development #syscall #udp #tcp.