Skip to content

Instantly share code, notes, and snippets.

View jeffbrl's full-sized avatar

Jeff Loughridge jeffbrl

View GitHub Profile
@jeffbrl
jeffbrl / prepare_droplet.sh
Created July 22, 2014 00:02
One time configuration of DigitalOcean droplet for IPv6 connectivity in docker containers
#!/bin/bash
#
# Jeff Loughridge
# July 2014
# jeffl at brooksconsulting-llc.com
# enable IPv6 forwarding and ND proxying
echo net.ipv6.conf.all.proxy_ndp=1 >> /etc/sysctl.conf
echo net.ipv6.conf.all.forwarding=1 >> /etc/sysctl.conf
@jeffbrl
jeffbrl / set_nd_proxy_entries.sh
Last active August 29, 2015 14:04
Script to configure IPv6 ND proxy
#!/bin/bash
#
# Jeff Loughridge
# July 2014
# jeffl at brooksconsulting-llc.com
# This script provides an example of setting up IPv6 static
# ND proxy entries. Edit the V6_START to match
# what you see in the DO control panel
@jeffbrl
jeffbrl / container-up.sh
Created July 22, 2014 00:47
Bring up IPv6-enabled docker container
#!/bin/bash
#
# Jeff Loughridge
# July 2014
# jeffl at brooksconsulting-llc.com
# first argument to script must be IPv6 address from DO-allocated
# space that is not part of the first /126 (e.g. 0x4 to 0xF as last
# hex character
@jeffbrl
jeffbrl / ncclient_demo.py
Last active December 7, 2016 05:38
Executing Arbitrary Junos 'Show' Commands with PyEZ and ncclient
#!/usr/bin/env python
# Demonstrates the use of the 'command' tag to execute arbritrary 'show' commands.
# This code was inspired by Ebben Aries's command-jnpr.py at
# https://github.com/leopoul/ncclient/blob/master/examples/juniper/command-jnpr.py
#
# usage: python ncclient_demo.py <show command> <xpath expression>
# python ncclient_demo.py 'show route 2600::/64' '//rt-entry/nh'
#
# Jeff Loughridge
# August 2014
@jeffbrl
jeffbrl / mdserv
Last active August 29, 2015 14:10 — forked from smoser/mdserv
#!/usr/bin/python
"""
To use this to mimic the EC2 metadata service entirely, run it like:
# where 'eth0' is *some* interface. if i used 'lo:0' i got 5 second or so delays on response.
sudo ifconfig eth0:0 169.254.169.254 netmask 255.255.255.255
sudo ./mdserv 169.254.169.254:80
Then:
wget -q http://169.254.169.254/latest/meta-data/instance-id -O -; echo
curl --silent http://169.254.169.254/latest/meta-data/instance-id ; echo
@jeffbrl
jeffbrl / virsh-get-ip.sh
Created November 22, 2014 17:37
Obtain KVM guest IPv4 or IPv6 from MAC adddress
#!/bin/bash
#
function get_ip {
# Obtain the IPv4 or IPv6 address
VERSION=$1
# Use arp to find the IP address you're looking for via its MAC address:
IP=$(ip -$VERSION neighbor show | grep $MAC_ADDRESS | awk '{ print $1 }' )
@jeffbrl
jeffbrl / sprayer.lua
Created January 5, 2015 01:13
First Example for Snabbswitch Getting Started Guide - sprayer.lua
#!/usr/bin/env snabbswitch
local app = require("core.app")
local config = require("core.config")
local pcap = require("apps.pcap.pcap")
local link = require("core.link")
local RawSocket = require("apps.socket.raw")
local c = config.new()
config.app(c, "capture", pcap.PcapReader, "input.pcap")
@jeffbrl
jeffbrl / get_flow.py
Created April 23, 2015 18:16
Pyez parsing lxml Element example
#!/usr/bin/env python
from jnpr.junos import Device
def build_dict(xml):
jflow = {}
# 1st entry in xml is <inline_jflow_flow_information>
inline_jflow_flow_information = xml[0]
@jeffbrl
jeffbrl / get_rsvp.py
Created April 24, 2015 18:40
Pyez RSVP Table/View
#!/usr/bin/env python
import yaml
from jnpr.junos.factory.factory_loader import FactoryLoader
from jnpr.junos import Device
yml = '''
---
RsvpTable:
rpc: get-rsvp-session-information
@jeffbrl
jeffbrl / pyez_set.py
Created June 26, 2015 15:48
PyEZ Configuration actions
#!/usr/bin/env python
import sys
from jnpr.junos.utils.config import Config
from jnpr.junos import Device
from jnpr.junos.exception import *
jdev = Device(user='jeffl', host='10.10.10.1', password='pass123')
jdev.open(gather_facts=False)