Skip to content

Instantly share code, notes, and snippets.

@ipcpu
ipcpu / cidr_whitelist.php
Last active January 10, 2017 08:18 — forked from markbrody/cidr_whitelist.php
php whitelist that supports cidr notation
<?php
////判断IP是不是在白名单内的算法-PHP
////$_SERVER['REMOTE_ADDR'] = $_SERVER['argv'][1];
$ip="10.1.1.1";
$client = sprintf('%u', ip2long($ip));
$whitelist = array('127.0.0.0/10', '10.0.0.0/8', '192.168.1.0/24','60.207.94.32/27');
$whitelisted = false;
foreach ($whitelist as $range) {
@ipcpu
ipcpu / nsclient_update.sh
Created February 24, 2017 03:18 — forked from mbrownnycnyc/nsclient_update.sh
script for use with `nsupdate` to update linux client DNS on a DNS server... in this instance, I am targeting a Windows Server DNS server 2003/2008/2012+. I have manually created the PTR and A records once, and granted the Everyone ACE the "Write" permission in the DACL of the PTR and A records.
#!/bin/sh
#original from http://community.spiceworks.com/topic/262635-linux-does-not-register-on-the-windows-ad-dns
# reply of Phil6196 Oct 1, 2012 at 12:41 AM (EDT)
ADDR=`/sbin/ifconfig eth0 | grep 'inet addr' | awk '{print $2}' | sed -e s/.*://`
HOST=`hostname`
echo "update delete $HOST A" > /var/nsupdate.txt
echo "update add $HOST 86400 A $ADDR" >> /var/nsupdate.txt
echo "update delete $HOST PTR" > /var/nsupdate.txt
echo "update add $HOST 86400 PTR $ADDR" >> /var/nsupdate.txt
nsupdate /var/nsupdate.txt
@ipcpu
ipcpu / Nginx http to https redirect
Created March 24, 2017 01:40 — forked from neilstuartcraig/Nginx http to https redirect
Nginx http to https redirect (maintaining hostname, path and query string - using an HTTP 301)
server {
# Listen on port 80 for any IPv4 address on this server
# listen docs: http://wiki.nginx.org/HttpCoreModule#listen
listen 80;
# Listen on only the selected hostname...
server_name <HOSTNAME>;
# ...or use the catchall character if you want to handle multiple hostnames
# server_name _;