Skip to content

Instantly share code, notes, and snippets.

View afresh1's full-sized avatar

Andrew Hewus Fresh afresh1

View GitHub Profile
@afresh1
afresh1 / openbsd-httpd-fastcgi-notes.md
Created July 12, 2020 21:26
Notes on how OpenBSD's httpd handles its FastCGI parameters. Debugging it with slowcgi.

These examples all live in a default server block in your httpd.conf(5).

server "default" {
	listen on * port 80
	... # all the location blocks can together right here
}

We'll be using slowcgi(8) as the example, because with the -d flag it helpfully spits out the FastCGI environment it got from httpd(8) and what it's planning to do with that.

@afresh1
afresh1 / !README.md
Last active January 3, 2024 21:52
CenturyLink PPPoE and 6rd on an OpenBSD router

Replacing the CenturyLink provided ethernet router with OpenBSD

Unfortunately CenturyLink provisions their fiber to the home with a PPPoE authentication over vlan 201, this makes replacing the router more difficult than it should be. I also had to call CenturyLink support to get the password for the PPPoE connection.

cnmac0 is the egress interface on my EdgeRouter Lite.

You also need to add match on pppoe0 scrub (max-mss 1452)

@afresh1
afresh1 / ips_in_range
Last active December 24, 2023 01:07
A simple IPv4 calculator. Takes an IP and netmask and calculates some details about the network in ksh.
#!/bin/ksh
set -o errexit -o pipefail -o nounset -o noclobber -o noglob
set +o monitor
export PATH=/usr/bin:/bin:/usr/sbin:/sbin
# Convert the IP to an integer so do calculations on it
dottedQuad2int() {
local IFS=.
local ip
set -A ip $* 0 0 0 0
@afresh1
afresh1 / agent-TWP-refactor.pl
Last active September 13, 2023 01:03
mwl posted a script on his blog (https://mwl.io/archives/23082) that seems to indicate that he actually runs it.
#!/usr/bin/env perl
use v5.16;
use warnings;
#manages the narcissistic bibliography MIB
#deploy as:
#rocommunity megadweeb 0.0.0.0/0 1.3.6.1.4.1.55030
#rocommunity6 megadweeb 0::/0 1.3.6.1.4.1.55030
#pass_persist .1.3.6.1.4.1.55030.1.1.1 /usr/local/scripts/persistwp.pl
@afresh1
afresh1 / setup_images.sh
Created July 23, 2013 02:30
Scripts to setup OpenBSD flashrd images and start qemu instances for each of them.
#!/bin/sh
# Andrew Fresh <andrew AT afresh1.com> - https://gist.github.com/afresh1
# This uses qemu, so pkg_add qemu
# Download and extract flashrd, either from github or here:
# http://www.nmedia.net/flashrd/
# Grab a flashrd image from here:
# http://www.nmedia.net/flashrd/images/
@afresh1
afresh1 / serve_this.sh
Last active June 4, 2023 22:00
A Mojolicious One Liner to serve static files from the current directory
#!/bin/sh
exec perl -Mojo -E '$m=a("/");$m->static->paths(["."]);$m->start' daemon
@afresh1
afresh1 / HTTP-Tiny-nc.pm
Last active May 2, 2023 23:56
A monkey patch to let perl's HTTP::Tiny to use the OpenBSD netcat with TLS support to access https sites without installing IO::Socket::SSL and Net::SSLeay.
use v5.16;
use warnings;
package HTTP::Tiny::nc;
use parent 'HTTP::Tiny';
our $VERSION = v0.0.3;
# Copyright (c) 2019-2023 Andrew Hewus Fresh <afresh1@openbsd.org>
#
# Permission to use, copy, modify, and distribute this software for any
@afresh1
afresh1 / workaround_vlan_trunk_bug.sh
Created February 26, 2023 20:15
A small shellscript to work around a FreeBSD bug (208910) that requires you to move the vlan onto an epair member of the bridge, not on the physical interface in the bridge.
#!/bin/sh
set -o errexit -o pipefail -o nounset -o noclobber -o noglob
# Copyright (c) 2023 Andrew Hewus Fresh <andrew@afresh1.com>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
@afresh1
afresh1 / vmctl-ssh
Created May 4, 2022 02:46
Provide a helper to ssh into an OpenBSD vmm vm by name without knowing what IP vmm assigned. It doesn't allow scp or things like that, haven't figured out how yet.
#!/usr/bin/perl
use v5.30;
use warnings;
use OpenBSD::Pledge;
use OpenBSD::Unveil;
# Copyright (c) 2021 Andrew Hewus Fresh <andrew@afresh1.com>
#
# Permission to use, copy, modify, and distribute this software for any
@afresh1
afresh1 / Installing_an_OpenBSD_VM_under_FreeNAS.md
Last active May 4, 2022 02:32
Installing OpenBSD in a bhyve VM under FreeNAS