Skip to content

Instantly share code, notes, and snippets.

@rilindo
rilindo / iptables_forward
Created November 13, 2011 20:35
A sample file of forwarding traffic from a specific to another IP.
# Generated by iptables-save v1.4.7 on Sat Nov 12 18:15:09 2011
*nat
:PREROUTING ACCEPT [17:1680]
:POSTROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [2:176]
-A PREROUTING -s 192.168.15.31/32 -p tcp -m state --state NEW,RELATED,ESTABLISHED -m tcp --dport 80 -j DNAT --to-destination 192.168.15.33:8080
-A POSTROUTING -j MASQUERADE
COMMIT
# Completed on Sat Nov 12 18:15:09 2011
# Generated by iptables-save v1.4.7 on Sat Nov 12 18:15:09 2011
@rilindo
rilindo / Verifying StartTLS
Created November 18, 2011 20:58
This is what I used to verify starttls with an openldap client.
# To verify TLS, use the following. If you have issues, add -d -1
ldapsearch -d -1 -vvvvv -w PASSWORD -ZZZ -H ldap://ldap.example.com -D "cn=root,dc=example,dc=com" "(uid=joeuser)"
#We want to make sure that the client certificate is valid:
openssl verify cacert.pem
#Tetheral is very useful to verify whether the data is encrypted or not:
@rilindo
rilindo / genmac-kvm.sh
Created December 4, 2011 20:04
This generates a mac address for KVM
for i in `openssl rand -hex 3`; do echo 52:54:00:`echo $i | cut -c1-2`:`echo $i | cut -c3-4`:`echo $i | cut -c5-6`; done
@rilindo
rilindo / vir-install-nfs
Created December 4, 2011 20:34
Example vir-install installations
#Scientific Linux
virt-install --name vmtest --disk path=/home/vms/vmtest,size=8 --vnc --vcpus=1 --ram=512 --network bridge=virbr0,mac=52:54:00:91:95:30 --location=nfs:192.168.15.100:/exports/sl/6.1/x86_64/os -x "ks=nfs:192.168.15.100:/exports/sl/ks/ks-t-kvm.cfg"
# Fedora
virt-install --name fpvmtest --disk path=/home/vms/fpvmtest,size=8 --vnc --vcpus=1 --ram=1024 --network bridge=virbr0,mac=52:54:00:F5:59:B5 --location=nfs:192.168.15.100:/exports/fedora/16/Fedora/x86_64/os -x "ks=nfs:192.168.15.100:/exports/ks/f16ks.cfg"
# Fedora nfs/http install hybrid
@rilindo
rilindo / RemoveIPfromKnownHosts
Created December 4, 2011 22:02
Removes Hosts IP and backups existing known_hosts file
sed -i .`date "+%m%d%H%M%Y.%S"` 's/192.168.15.61\(.*\)//' ~/.ssh/known_hosts
@rilindo
rilindo / getdomtoip.rb
Created December 11, 2011 21:00
List KVM domains and their IPs. Note that the mac and IP must be in the arp table
#!/usr/bin/ruby
require 'libvirt'
require 'xml'
def maptoip(mac,vm)
IO.popen("ip neigh").each do | line|
if (line.split(/\s+/)[4] == mac)
puts "#{line.split(/\s+/)[0]} - #{mac} - #{vm}"
break
@rilindo
rilindo / vncdom.rb
Created December 12, 2011 03:22
Pulls list of active and inactive domains in KVM for use to connect with VNC
#!/usr/bin/ruby
require 'rubygems'
require 'libvirt'
require 'xml'
conn = Libvirt::open('qemu:///system')
puts "List of inactive domains:"
conn.list_domains.each do |domid|
dom = conn.lookup_domain_by_id(domid)
@rilindo
rilindo / gist:1473728
Created December 13, 2011 20:25 — forked from cookbooks/gist:731502
Grit clone example
# Since Git is well structured, Grit uses a method missing (Grit::Git#method_missing) to 'systematically' execute Git commands:
require 'grit'
include Grit
gritty = Grit::Git.new('/tmp/filling-in')
gritty.clone({:quiet => false, :verbose => true, :progress => true, :branch => '37s'}, "git://github.com/cookbooks/cc-aws.git", "/tmp/cc-aws2")
# => "Initialized empty Git repository in /tmp/cc-aws2/.git/\n"
Dir.entries('/tmp/cc-aws2').size
# => 10
@rilindo
rilindo / enableldapauth
Created December 17, 2011 21:14
Enable LDAP Authentication via commandline
authconfig --enablecache --enableldap --enableldaptls --ldapserver=kerberos.example.com --ldapbasedn="dc=example,dc=com" --update
@rilindo
rilindo / Ref61.cfg
Created December 17, 2011 23:31
Kickstart Reference System 6.1
# Kickstart file automatically generated by anaconda.
#version=RHEL6
install
url --url http://192.168.15.100/mirrors/centos/6.1/os/x86_64/
lang en_US.UTF-8
keyboard us
text
#skipx
network --device eth0 --bootproto dhcp --hostname centos61.test.monzell.com