From nobody Thu Dec 29 02:31:01 2022 X-Original-To: freebsd-current@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4NjC7R4nTNz2kxxg for ; Thu, 29 Dec 2022 02:31:15 +0000 (UTC) (envelope-from bakul@iitbombay.org) Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NjC7R2ycWz43rf for ; Thu, 29 Dec 2022 02:31:15 +0000 (UTC) (envelope-from bakul@iitbombay.org) Authentication-Results: mx1.freebsd.org; none Received: by mail-pl1-x629.google.com with SMTP id b2so17676374pld.7 for ; Wed, 28 Dec 2022 18:31:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iitbombay-org.20210112.gappssmtp.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=ixYP9LwA5czUikEeatOgu0kf103Ka1Ni1XWLkQpGlco=; b=KI3YHoT4NLj2Hw7Z3vtXwLauNaxTPzlsl050EX6tVt5lfhxMExWoCzA9hiWsH+AKKa UivGYKTr2TIv/nsF5MADQ4wNChLaPQpkgGlq/FsBxUjY0k5hXPpvpzGzLBeDMbiY43ma qMuzXjGligl180ZK6X8zWHzFgjhunCAHIlCv99kQhtKawskUvEk4bf5f0h5pPGq5Jaik 0x92htw/y5u77LpyenWv5DE98ExZ110IXheTqCwvIMnCBqeMKB5tn29XUAb3ZHGnRqh2 rWBeX8rFR81ocSo4tkAI+aVmK0e+f/nssGt1liAjxTfTqqKXZcIFTcS3H7PR9ln5TGIq lBng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ixYP9LwA5czUikEeatOgu0kf103Ka1Ni1XWLkQpGlco=; b=CQ2kERczkmUrSB7lzeWz6vpQ3HIAtVhtbp3NicqEOwVaVYBPW90+21oATwAQ1BYmET D7wKje8XCfQZ0exE9jnHW/TlSb1Kkrhblav6P/Lk88ilfZ1atgzcbYxA7V/3FrJhCqWA NxIj9CqYQdFKtMFiZPsLTbhHCyyBnQuRfT9fm5K9uYJ8Rfvo+8e2mwjItAZLSUBZ6C+v Jt2FE7u1sF2V+BCDk0yY2l2GcaIftreF24tXQ3xq+/LDUMiJSTZ+uw5ULXvM9FpChbeA DL+5i3bmRjFQ6mfzXSdS9KIqItXej37unGkxCuR25dapYYHyccbzNFuZYHPxOqLLe9e4 AH5Q== X-Gm-Message-State: AFqh2kr7yOj4ynYGVvU9pH825ZCPTcAdbhsuwAnEn/tIwFAG5WSVXG5a uKY+zHpoXmlqGHiRdQyAwX9fj9AHp59ZQ/K7 X-Google-Smtp-Source: AMrXdXvNTdJR54Ta2IXizER9efFNOPSwqbaRf5KzVr/MjjWrkWre7QaOq1Bebb7vqvc1txC1LaQGrw== X-Received: by 2002:a17:903:230c:b0:192:64a9:62f5 with SMTP id d12-20020a170903230c00b0019264a962f5mr27859159plh.29.1672281073052; Wed, 28 Dec 2022 18:31:13 -0800 (PST) Received: from smtpclient.apple (107-215-223-229.lightspeed.sntcca.sbcglobal.net. [107.215.223.229]) by smtp.gmail.com with ESMTPSA id s19-20020a170903201300b00187197c4999sm11652859pla.167.2022.12.28.18.31.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Dec 2022 18:31:12 -0800 (PST) Content-Type: text/plain; charset=us-ascii List-Id: Discussions about the use of FreeBSD-current List-Archive: https://lists.freebsd.org/archives/freebsd-current List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-current@freebsd.org Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.300.101.1.3\)) Subject: Re: native recording of all network connections on freebsd From: Bakul Shah In-Reply-To: Date: Wed, 28 Dec 2022 18:31:01 -0800 Cc: freebsd-current@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: <4CC0832A-5852-43A2-ACD6-802BFD9E9BDA@iitbombay.org> References: To: Dan Mack X-Mailer: Apple Mail (2.3731.300.101.1.3) X-Rspamd-Queue-Id: 4NjC7R2ycWz43rf X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-ThisMailContainsUnwantedMimeParts: N On Dec 28, 2022, at 6:21 AM, Dan Mack wrote: >=20 > I'm wondering if anyone can help point me at a good way to continously = capture every inbound and outbound connection made to a freebsd system. = I'd prefer a way that is native in base if possible. I don't really = want to record all the packets, just the src:dest:rport:dport stats. I'd build a simple program using pcap(3), and compile a bpf program using pcap_compile and then do pcap_setfilter to capture just the packets I want. Then save the desired fields from captured packets (and use a hashtable if just {src,dst}{ip,port} are wanted). There are online examples one can start from.=