Skip to content

Instantly share code, notes, and snippets.

@kendokan
kendokan / asn-to-ipv4.py
Created January 27, 2018 01:41
Takes one or more BGP Atonomous System Numbers (ASN) as input and provides a cooresponding list of IPv4 network blocks.
#!/usr/bin/env python
import socket
import re
## https://tools.ietf.org/html/rfc3912
def whois_request(domain, server, port=43):
_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
_sock.connect((server, port))
_sock.send("%s\r\n" % domain)
@kendokan
kendokan / dyndns_monitor.php
Created December 3, 2017 06:51
Enables/disabled a dynamic DNS entry depending on the carp status of a specified interface (i.e. lan). Good for failover scenarios when you can't run carp on the WAN interface.
#!/usr/local/bin/php-cgi -f
<?php
require_once('functions.inc');
$opts = get_options();
$dyndns = &$config['dyndnses']['dyndns'][get_dyndns_id_by_host($opts['dyndns'])];
// This system must be master to enable specified dyndns hostname.
@kendokan
kendokan / wpa_auth.php
Last active January 11, 2020 17:14
Wired WPA (802.1x) authentication on a pfSense system, called from cron.
#!/usr/local/bin/php-cgi -f
<?php
/*
Performs 802.1x authentication on a pfSense system.
# php wpa_auth.php --hash testpass123
1efb50581482d84f9e57737b846a32b0
# php wpa_auth.php --interface vmx2 --identity myusername --password 1efb50581482d84f9e57737b846a32b0
@kendokan
kendokan / gist:1848c8376b23a480b85a788189a66a70
Created November 10, 2017 22:11
Docker host crontab for Nextcloud.
*/15 * * * * /usr/local/bin/docker-compose -f /home/docker/mystack/docker-compose.yaml -f /home/docker/mystack/docker-compose.volumes.yaml -f /home/docker/mystack/docker-compose.networks.yaml exec --user www-data nextcloud bash -c "php -f /var/www/html/cron.php"
@kendokan
kendokan / diskstatus.sh
Created November 2, 2017 20:08
This script uses smartctl to report current temperature and health of all disks as a JSON array. It can be used on FreeNAS systems with telegraf's exec input.
#!/usr/bin/env sh
# This script uses smartctl to report current temperature and health of all disks as a JSON array.
# It can be used on FreeNAS systems with telegraf's exec input.
#
# Example telegraf.conf input:
#
# [[inputs.exec]]
# name_override = "diskhealth"
# commands = ["/path/to/diskstatus.sh"]
@kendokan
kendokan / musicbrainz.proxy.conf
Created September 23, 2017 01:17
Nginx reverse proxy configuration for Musicbrainz for when you want to access it like http://your.host/musicbrainz. This is way harder than it should be.
location ^~ /musicbrainz/ {
set $musicbrainz_upstream musicbrainz;
set $musicbrainz_baseurl /musicbrainz;
rewrite /musicbrainz(.*) /$1 break;
proxy_pass http://$musicbrainz_upstream:5000;
proxy_set_header Accept-Encoding "";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;