From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED autolearn=no autolearn_force=no version=3.4.4 Received: (qmail 12915 invoked from network); 16 Nov 2022 03:48:57 -0000 Received: from 9front.inri.net (168.235.81.73) by inbox.vuxu.org with ESMTPUTF8; 16 Nov 2022 03:48:57 -0000 Received: from mail.posixcafe.org ([45.76.19.58]) by 9front; Tue Nov 15 22:45:14 -0500 2022 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=posixcafe.org; s=20200506; t=1668570444; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=yBhtyODl4ohMLauCvg2/EF0CbB3xYN3FYBrpJHgKOK4=; b=I6rYYnYqYTrCLlgRx4QEv7yed894gKxrRy8Eb9ksneAAGpqkRR5bRLvrGvAa8uO9z7t1ZF FUu6ywuT181TXjWNDROIwZGqNnPR3XTV5UlfZsdxaYo+G8EqpsH17xBPro+Z8YFPPulCV3 qgYl8V4CNDWoSBPbcDXLo+1Bh1Lvy84= Received: from [192.168.168.200] (161-97-205-25.mynextlight.net [161.97.205.25]) by mail.posixcafe.org (OpenSMTPD) with ESMTPSA id 6d577499 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for <9front@9front.org>; Tue, 15 Nov 2022 21:47:24 -0600 (CST) Message-ID: Date: Tue, 15 Nov 2022 20:42:52 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Content-Language: en-US To: 9front@9front.org From: Jacob Moody Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: social cloud markup event-oriented frontend Subject: [9front] [PITCH] ip/null Reply-To: 9front@9front.org Precedence: bulk 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 +#include + +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; + } +}