3 ms·
Note that this is a bashism, netcat is (a bit, due to BSD vs GNU) more portable. I think Hurd can provide similar functionality at the filesystem level thanks
by MayeulC 6y ago
Note that this is a bashism, netcat is (a bit, due to BSD vs GNU) more portable. I think Hurd can provide similar functionality at the filesystem level thanks to its translators. Plan 9 likely can, too, and it would be possible to cook something together with FUSE.
I leveraged this some time ago to sent WOL packets. I think it went something like:
echo -e [16 times the target MAC written as \xFF] > /dev/udp/255.255.255.255/9
BTW, I'm not entirely sure how broadcast IPv4 addresses work. I think they are set by the DHCP server, and the computer sends packets to these addresses as MAC broadcasts? (leaving the dest IP as the configured broadcast one).
- zamadatix 6y agoThe broadcast address of a given subnet is "!netmask | hostIp" e.g. if the host IP is 192.168.1.12/24 then it's 192.168.1.12 | 0.0.0.255 = 192.168.1.255. The "human" way of thinking about it is it's the last address in the subnet. The IP4 broadcast address for the current network (even if the client doesn't known what it is) is 255.255.255.255. Once the packet arrives at the destination subnet (which can be immediately or several routing hops away) it will (in the case of Ethernet) you're right that's to the FF:FF:FF:FF:FF:FF destination MAC. In the case of DHCP client <-> server on different subnets there is a special "DHCP relay" role configured in the network and that relay is what handles broadcast to unicast conversions https://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol#Relaying https://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Pro...
- LukeShu 6y ago> netcat is (a bit, due to BSD vs GNU) more portable Note that GNU doesn't have a netcat implementation. There's a netcat implementation that calls itself "GNU netcat", but it isn't actually associated with GNU, and the authors are jerks for naming it that. But also, there are more netcat implementations than just 2! - OpenBSD netcat - "GNU" Netcat (http://netcat.sourceforge.net http://netcat.sourceforge.net) - BusyBox netcat - Nmap's `ncat` - Netcat6 (http://www.deepspace6.net/projects/netcat6.html http://www.deepspace6.net/projects/netcat6.html) And all of them are just different enough from eachother...
- MayeulC 6y agoThanks for that tidbit about "GNU" netcat. That's quite strange, I'll look more into this. I like the fact that Solaris netcat supports socks proxies, that's really useful, especially in combination with `ssh -D`.
- sergeykish 6y agoOn Plan 9 it would be { netdir=/net/tcp/`{cat} echo connect $ip!$port >$netdir/ctl || exit 'cannot connect' echo GET / HTTP/1.1 > $netdir/data echo > $netdir/data cat $netdir/data } < /net/tcp/clone It used for example in IRC client implemented in rc shell http://web.archive.org/web/20060620053701/http://plan9.bell-labs.com/sources/contrib/fgb/rc/ircrc http://web.archive.org/web/20060620053701/http://plan9.bell-...