Skip to content

Instantly share code, notes, and snippets.

View tiernano's full-sized avatar

Tiernan OToole tiernano

View GitHub Profile
18 ;;; 7/0 goes to WAN1
chain=prerouting action=mark-connection new-connection-mark=WAN1_conn passthrough=yes
dst-address-type=!local in-interface=LAN1 connection-mark=no-mark
per-connection-classifier=both-addresses-and-ports:7/0
19 ;;; 7/1 goes to WAN2
chain=prerouting action=mark-connection new-connection-mark=WAN2_conn passthrough=yes
dst-address-type=!local in-interface=LAN1 connection-mark=no-mark
per-connection-classifier=both-addresses-and-ports:7/1
@tiernano
tiernano / gist:8217968
Created January 2, 2014 11:35
mikrotik script for sending from a particular address list to a particular WAN link
9 ;;; WAN1 address list -> WAN1
chain=prerouting action=mark-routing new-routing-mark=to_WAN1 passthrough=no
dst-address=!192.168.0.0/16 dst-address-list=WAN1
10 ;;; WAN2 address list -> WAN2
chain=prerouting action=mark-routing new-routing-mark=to_WAN2 passthrough=no
dst-address=!192.168.0.0/16 dst-address-list=WAN2
11 ;;; WAN3 address list -> WAN3
chain=prerouting action=mark-routing new-routing-mark=to_WAN3 passthrough=no
@tiernano
tiernano / gist:4344701
Created December 20, 2012 11:08
IPv6 Firewall rules for a MikroTik router to allow outgoing connections, but block incoming, unless they are responses...
/ipv6 firewall filter
add action=accept chain=input comment="Allow established connections" connection-state=established disabled=no
add action=accept chain=input comment="Allow related connections" connection-state=related disabled=no
add action=accept chain=input comment="Allow limited ICMP" disabled=no limit=50/5s,5 protocol=icmpv6
add action=accept chain=input comment="Allow UDP" disabled=no protocol=udp
add action=drop chain=input comment="" disabled=no
add action=accept chain=forward comment="Allow any to internet" disabled=no out-interface=sit1
add action=accept chain=forward comment="Allow established connections" connection-state=established disabled=no
add action=accept chain=forward comment="Allow related connections" connection-state=related disabled=no
add action=drop chain=forward comment="" disabled=no
@tiernano
tiernano / gist:4267157
Created December 12, 2012 11:40
take a compressed protobuf file (local), uncompress and then deserialize
using (FileStream fs = new FileStream(location, FileMode.Open))
{
using (GZipStream gz = new GZipStream(fs, CompressionMode.Decompress))
{
var result = Serializer.Deserialize<objectType>(gz);
//work with result here...
}
}
@tiernano
tiernano / gist:4267147
Created December 12, 2012 11:38
convert the object (obj) into a serialized protobuf object, compress and then write to tmpFile
using (MemoryStream serialized = new MemoryStream())
{
Serializer.Serialize(serialized, obj);
byte[] data = serialized.ToArray();
using (FileStream fs = new FileStream(tmpFile, FileMode.Create))
{
using (GZipStream zip = new GZipStream(fs, CompressionMode.Compress))
{
zip.Write(data, 0, data.Length);
}

Keybase proof

I hereby claim:

  • I am tiernano on github.
  • I am tiernano (https://keybase.io/tiernano) on keybase.
  • I have a public key whose fingerprint is BAAE 36B5 95BA F1FE 68A6 DE86 DDB1 22F7 277D 9175

To claim this, I am signing this object:

; <<>> DiG 9.10.6 <<>> 1.67.186.185.in-addr.arpa PTR
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 42465
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1452
;; QUESTION SECTION:
;1.67.186.185.in-addr.arpa. IN PTR
@tiernano
tiernano / post-receive
Created January 16, 2013 06:56
post-receive hook for GIT to generate site using Jekyll and then push to NFSN using RSYNC. dont forget the / at the end of public_www or a new directory will be created in your public folder... if you want the contents uploaded to the public folder, include the /!
GIT_REPO=$HOME/repositories/<sitename>.git
TMP_GIT_CLONE=$HOME/tmp/<sitename>
PUBLIC_WWW=/var/wwwsites/<sitename>/
git clone $GIT_REPO $TMP_GIT_CLONE
cd $TMP_GIT_CLONE && jekyll --no-auto $TMP_GIT_CLONE $PUBLIC_WWW
cd ~ && rm -rf $TMP_GIT_CLONE
rsync -avz -e ssh $PUBLIC_WWW <NFSNUSERNAME>@ssh.phx.nearlyfreespeech.net:/home/public/
@tiernano
tiernano / gist:8581643
Created January 23, 2014 16:25
MikroTik Router VPN Stuff
/interface l2tp-client add name="vpn" max-mtu=1460 max-mru=1460 mrru=disabled connect-to=servername user="username" password="password" profile=default-encryption add-default-route=no dial-on-demand=no allow=pap,chap,mschap1,mschap2
/interface l2tp-client enable [/interface l2tp-client find name ="vpn"]
/ip firewall mangle add chain=prerouting action=mark-routing new-routing-mark=vpn passthrough=yes src-address=networkaddress/24 dst-address=!networkaddress/24
/ip route add dst-address=0.0.0.0/0 gateway=vpn gateway-status=vpn distance=1 scope=30 target-scope=10 routing-mark=vpn
/ip firewall nat add chain=srcnat action=masquerade out-interface=vpn
#!/bin/sh
USER=<serverusername>
PASS=<serverpassword>
HOST=<serverip>
COOKIE=`curl -k --data "WEBVAR_USERNAME=$USER&WEBVAR_PASSWORD=$PASS" https://$HOST/rpc/WEBSES/create.asp 2> /dev/null | grep SESSION_COOKIE | cut -d\' -f 4`
curl -k --cookie Cookie=SessionCookie=$COOKIE https://$HOST/Java/jviewer.jnlp -o $HOST.jviewer.jnlp
javaws $HOST.jviewer.jnlp