* [9front] [PITCH] ip/null
@ 2022-11-16 3:42 Jacob Moody
0 siblings, 0 replies; only message in thread
From: Jacob Moody @ 2022-11-16 3:42 UTC (permalink / raw)
To: 9front
As I play around more with 9front as my router, I found myself reaching for some
kind of 'firewall'. I find that we already have a pretty good interface in the kernel
in the form of ipmux. But there isn't too many ways of making use of it as is. I hacked up
something quick to just drop packets matching a filter on to the floor. If others find it
useful I can make up a man page and present again with a bit more polish.
Some examples:
# Drop inbound private range
ip/null 'ifc=my.external.ip;dst=192.168.0.0&255.255.0.0|10.0.0.0&255.0.0.0'
# google verboden
ip/null 'ifc=my.internal.ip;dst=8.8.8.8;src=192.168.0.0&255.255.0.0'
thanks,
moody
--- /dev/null
+++ b//sys/src/cmd/ip/null.c
@@ -1,0 +1,36 @@
+#include <u.h>
+#include <libc.h>
+
+void
+usage(void)
+{
+ fprint(2, "usage: %s filter\n", argv0);
+ exits("usage");
+}
+
+void
+main(int argc, char **argv)
+{
+ char buf[64 * 1024];
+ int fd;
+
+ ARGBEGIN{
+ default:
+ usage();
+ break;
+ }ARGEND
+ if(argc < 1)
+ usage();
+
+ fd = dial(smprint("ipmux!%s", argv[0]), nil, nil, nil);
+ if(fd < 0)
+ sysfatal("dial: %r");
+
+ for(;;)
+ switch(read(fd, buf, sizeof buf)){
+ case -1:
+ sysfatal("read: %r");
+ case 0:
+ return;
+ }
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-11-16 3:48 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-16 3:42 [9front] [PITCH] ip/null Jacob Moody
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).