Skip to content

Instantly share code, notes, and snippets.

View sebastianw's full-sized avatar

Sebastian Wiesinger sebastianw

View GitHub Profile
@sebastianw
sebastianw / rev-zone.py
Created October 19, 2021 11:23
IPv4 DNS Reverse Zone generation
#! /usr/bin/env python3
import ipaddress
subnet = ipaddress.IPv4Network("192.168.0.0/22", strict=False)
if subnet.prefixlen > 24:
raise ValueError("No Zone for subnets >/24")
elif subnet.prefixlen > 16:
zone_length = 24
@sebastianw
sebastianw / mtusize.sh
Last active November 24, 2020 12:50
MTU Size
function mtusize {
#set -x
[ -z "$1" ] && { echo "mtusize <host> [<initial data size> <step length>]"; return 1; }
ip=$1
size=${2:-1345}
step=${3:-64}
count=0
minfailed=999999
rstring=("" " failed")
while true; do
@sebastianw
sebastianw / objectlist.py
Created August 31, 2018 12:06
A python object which forwards all get/set requests (and functions) to a list of (identical) child objects
class ObjectList(object):
def __init__(self, child_objects):
self.child_objects = child_objects
def __getattr__(self, name):
def looper(*args, **kwargs):
for obj in self.child_objects:
attr = getattr(obj, name)
attr(*args, **kwargs)
return looper
@sebastianw
sebastianw / rfc2047-decode.py
Created June 2, 2017 10:44
Decode RFC2047 (formerly RFC1342) encoded mail headers - requires Python 3.3 or later
#! /usr/bin/env python3
# Decode RFC2047 (formerly RFC1342) encoded mail headers
# Requires >= python 3.3
import sys
from email.header import decode_header
def recode_utf8(subj):
output = ''
for s, enc in decode_header(subj):
@sebastianw
sebastianw / netconf-merge-wrapper.sh
Created May 11, 2017 08:19
Netconf Merge Wrapper
#! /bin/bash
# Use like: bgpq3 ... stuff | netconf-merge-wrapper.sh | ssh admin@router netconf
cat <<_END
<rpc>
<load-configuration action="merge" format="text">
<configuration-text>
_END
cat -
cat <<_END
</configuration-text>