Skip to content

Instantly share code, notes, and snippets.

@ipcpu
ipcpu / node_exporter.init.d
Created May 28, 2020 02:10
node_exporter.init.d on centos 6
#!/bin/sh
# chkconfig: 2345 60 20
# description: node_exporter
# Source function library.
. /etc/init.d/functions
@ipcpu
ipcpu / _openvpn_server.conf
Last active May 25, 2020 03:11
openvpn LDAP用户自动固定客户端IP地址
#LDAP
plugin /usr/local/lib/openvpn-auth-ldap.so "/etc/openvpn/auth/ldap.conf"
#plugin /usr/local/lib/openvpn/openvpn-otp.so "password_is_cr=1 otp_secrets=/etc/openvpn/auth/otp-secrets"
#script-security 2
script-security 3
# untrusted state
#client-connect /etc/openvpn/scripts/client-connect.sh
@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 _;
@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 / 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) {