Monday, 14 September 2015

Setting Up VLANs and DHCP server in ScreenOS

In this example I wanted to created a VLAN attached to e0/1 for use with my KVM lab.  You'll notice I give this interface an IP address, this is so that I can have my ScreenOS device do all the routing / NATing / firewalling in isolated VLANs. I also create a DHCP server.  I make the interface pingable as it may well be the internet gateway for anything inside the VLAN.

Create new zone and interface set zone name vlan69
set int ethernet0/1.1 tag 69 zone vlan69
set int e1.1 ip 10.10.69.254/24
set int e1.1 route
set int e1.1 manage ping
save

Setting Up DHCP Server
set int e1.1 dhcp server service
set int e1.1 dhcp server enable
set int e1.1 dhcp server option lease 71582788 #unlimted lease
set int e1.1 dhcp server option gateway 10.10.69.254
set int e1.1 dhcp server option netmask 255.255.255.0
set int e1.1 dhcp server option dns1 8.8.8.8
set int e1.1 dhcp server ip 10.10.69.10 to 10.10.69.240
set int e1.1 dhcp server config next-server-ip #unsets this
unset int e1.1 dhcp server config updatable
save

Checking DHCP Server Config # Check config options
get int e1.1 dhcp server option

# Check allocated leases
get int e1.1 dhcp server ip allocate

Saturday, 8 August 2015

OpenSUSE XDM SSH_ASKPASS

Every year or so I rebuild my machine and forget how to enable the ssh-askpass tool with ssh-agent from XDM display manager

cp /etc/X11/xdm/sys.xsession ~/.xession

cp ~/.xinitrc.template ~/.xinitrc

# Add ssh agent config for loading keys

if test -S "$SSH_AUTH_SOCK" -a -x "$SSH_ASKPASS"; then
        ssh-add ~/.ssh/id_nameofprivatekey < /dev/null
fi

Sunday, 12 July 2015

Passing CFLAGS and LDFLAGS to cgo

I was trying to build https://github.com/systemfreund/go-libshout which wraps the C libshout library with Go.  On Linux this worked fine, but on OpenBSD this was a bit more of a challenge as cgo could not find libshout.  (install libshout with pkg_add first)

Although -lshout is specified as an LDFLAG  in the go source code, I needed to to specify the include path for libshout and also link to libspeex (-lsppex)

CFLAGS and LDFLAGS can be passed to go build as environmental variables so I set:

export CGO_CFLAGS='-I/usr/local/include'
export CGO_LDFLAGS='-L/usr/local/lib -lshout -lspeex'

Then I is was able to do

go build -x  github.com/systemfreund/go-libshout

(the -x is very useful for checking was gets passed to cgo)

Monday, 1 June 2015

Ansible ad-hoc commands

Create an inventory file

host1.something
host2.something
[group1]
group1host.something
group2host.something

Run a command on all hosts
ansible -i inventory_file all -m command -a "uptime"

This specifies the inventory file (-i) run on all hosts (all) and run the command module (runs a remote command) with the module argument uptime (-a)

Run a command on all hosts simpler
ansible -i inventory_file all  -a "uptime"

Same as above.  Notice that the module name was not specified as the command module is used by default

Run a command on hosts in group1 with sudo
ansible -i inventory_file group1 -s -K -a "service rsyslog status"

-s Use sudo
-K ask for the sudo password (can be omitted if not required)

Copy a file to all hosts
ansible -i inventory_file all -m copy -a "src=~/.vimrc dest=~"




Sunday, 8 March 2015

Real Time Scheduling for audio in openSUSE

I was getting the following message from jack / hydogen
Cannot use real-time scheduling

To solve this I added the following to  /etc/security/limits.conf
@audio - rtprio 99
@audio - memlock 250000
@audio - nice -10

and also added myself to the audio group (sudo usermod -a -G audio jon)

Saturday, 8 November 2014

Bulk Filename Rewriting

In zsh you'll find zmv (autoload zmv) and in zmv it's easy to rewrite bulk files.  For example, I had some downloaded files that were something.mp3?id=8795294528 etc and wanted to cut off the cruft at the end.

zmv '(*.mp3)*' '$1'

Saturday, 18 October 2014

Strip comments from an XML file

Ever had an xml file bloated with comments? Here's a great one-liner for striping them.

tidy -quiet -asxml -xml -indent -wrap 1024 --hide-comments 1 file.xml

Thanks to http://stackoverflow.com/questions/1464697/stripout-comments-from-xml