Skip to content

Instantly share code, notes, and snippets.

@mangalaman93
mangalaman93 / setup.sh
Last active September 6, 2015 08:36
create a small cluster (using docker and virtualbox)
####### with Virtual box VMs #######
# fedora-ab => running sipp client #
# fedora-cd => running sipp server #
# fedora-ef => running snort-ids #
## starting virtual machine
VBoxManage startvm fedora-ab fedora-cd fedora-ef --type headless
## after some time, getting ip address and ssh
ssh docker@`VBoxManage guestproperty get "fedora-ab" "/VirtualBox/GuestInfo/Net/0/V4/IP" | awk '{ print $2 }'`
@mangalaman93
mangalaman93 / dockerovs.sh
Last active December 29, 2023 07:05
script to connect docker container with OpenFlow enabled OVS switches
#!/bin/sh
# Shell script to connect docker container with OpenFlow enabled OVS switches
#
# Inspired from http://ewen.mcneill.gen.nz/blog/entry/2014-10-07-ryu-and-openvswitch-on-docker/
# and http://ewen.mcneill.gen.nz/blog/media/docker-ovs/dockerovs
# Writen by Aman Mangal <amanmangal@gatech.edu>, Jan 3, 2015
#----------------------------------------------------------------------------
## Use cases
# ./dockerovs add-br <bridge> <CIDR>
@mangalaman93
mangalaman93 / gist:184d403501482a68f11a
Created September 25, 2015 09:34 — forked from kolyshkin/gist:bd25e9de97954b330d8a
How to run go pprof on Docker daemon
Enable port 8080 through the firewall:
firewall-cmd --add-port=8080/tcp
Run socat to make docker sock available via tcp port (note the IP to listen at)
socat -d -d TCP-LISTEN:8080,fork,bind=192.168.122.214 UNIX:/var/run/docker.sock
Run pprof on your client:
go tool pprof http://192.168.122.214:8080/debug/pprof/profile
Fetching profile from http://192.168.122.214:8080/debug/pprof/profile
Please wait... (30s)
package main
import (
"fmt"
"io/ioutil"
"os"
"path"
"strconv"
"syscall"
)
##### NETWORK SETUP #####
# we will use docker0 bridge for network connectivity
# pi is connected to the laptop over ethernet
# on host (laptop in this case)
sudo brctl addif docker0 eth0
# on pi
ifconfig eth0 172.17.42.234
./etcd -name etcd0 -data-dir data/0/ -advertise-client-urls http://127.0.0.1:2379 \
-listen-client-urls http://127.0.0.1:2379 \
-initial-advertise-peer-urls http://127.0.0.1:2380 \
-listen-peer-urls http://127.0.0.1:2380 \
-initial-cluster-token etcd-cluster \
-initial-cluster etcd0=http://127.0.0.1:2380,etcd1=http://127.0.0.1:2382,etcd2=http://127.0.0.1:2384 \
-initial-cluster-state new &> data/log0
./etcd -name etcd1 -data-dir data/1/ -advertise-client-urls http://127.0.0.1:2381 \
-listen-client-urls http://127.0.0.1:2381 \
@mangalaman93
mangalaman93 / sysserver.go
Last active May 14, 2024 02:39
setting low level socket options in golang (SO_PRIORITY, SO_REUSEADDR)
package main
import (
"bufio"
"fmt"
"net"
"os"
"syscall"
)
@mangalaman93
mangalaman93 / sysclient.go
Last active October 29, 2015 15:54
setting low level socket options in golang (SO_PRIORITY, SO_REUSEADDR)
package main
import (
"bufio"
"fmt"
"net"
"os"
"syscall"
)
@mangalaman93
mangalaman93 / venv
Last active November 2, 2015 04:30
virtual enviornment for golang
#!/bin/bash
if [[ $0 != "/bin/bash" ]]; then
echo "Error: source the script!"
exit 1
fi
if [[ ! -d $(pwd)/go/bin ]]; then
echo "Error: go installtion not found in the current directory!"
return
@mangalaman93
mangalaman93 / netfilter.py
Created April 24, 2016 18:35
Netfilter example in python
## Installation
# sudo apt-get install build-essential python-dev libnetfilter-queue-dev
# sudp pip install NetfilterQueue scapy
## References
# https://www.digitalocean.com/community/tutorials/how-to-list-and-delete-iptables-firewall-rules
# https://github.com/phaethon/scapy
# https://5d4a.wordpress.com/2011/08/25/having-fun-with-nfqueue-and-scapy/
# https://pypi.python.org/pypi/NetfilterQueue/0.3
# http://www.netfilter.org/documentation/HOWTO/netfilter-hacking-HOWTO-3.html