Skip to content

Instantly share code, notes, and snippets.

# show routes used for bestpath, multipath from bgp peers
show ip bgp neighbors | include BGP neighbor is|Used as
# show interfaces with Proxy ARP enabled
sh ip int | incl is up|Proxy ARP is enabled
# show interfaces with IP unreachables enabled
sh ip interface | incl is up|ICMP unreachables are always sent
# clean interface config/set default
@mdpuma
mdpuma / change ip address
Last active April 23, 2019 04:24
cpanel useful commands
#!/bin/bash
# change ip address for accounts (included DNS records)
grep $OLD_IP /var/cpanel/users/* | cut -d: -f1 | xargs -n1 basename | xargs -tI{} /usr/local/cpanel/bin/setsiteip -u {} $NEW_IP
@mdpuma
mdpuma / gist:e246f7cbc37fa628def9e618525006f9
Created May 4, 2016 15:34
Apache memory leak mod_rewrite recursion
# ISSUE:
# Example of bad rewrite rule
# first, check if url is not file or directory, if not then do rewrite!
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule "^(\S*)\s+(\S*\s.*)$" $1-$2 [N]
# if is set N flag, do this rewrite indefinitely (limited to 32000 iterations in apache >= 2.4.8)
@mdpuma
mdpuma / etc-modules
Last active July 11, 2023 07:59
proxmox-vfio
pci_stub
vfio
vfio_iommu_type1
vfio_pci
kvm
kvm_intel
@mdpuma
mdpuma / Integrate rspamd with cpanel
Last active August 31, 2025 09:14
Integrate rspamd with cpanel
1) go to whm -> exim configuration manager
* choose advanced editor
2) search spamd & replace with this:
set smtputf8_advertise_hosts = *
spamd_address = 127.0.0.1 11333 variant=rspamd retry=30s tmo=3m
* find and disable acl_smtp_data:default_check_message_pre
* find and disable acl_smtp_data:no_forward_outbound_spam_over_int
@mdpuma
mdpuma / change ttl for domains
Last active December 22, 2016 12:50
vesta useful commands
#!/bin/bash
TTL=600
USERS="`/usr/local/vesta/bin/v-list-users plain | awk '{ print $1 }'`"
for user in $USERS; do
/usr/local/vesta/bin/v-list-dns-domains $user plain | awk '{ print $1 }' | xargs -I{} v-change-dns-domain-ttl $user {} $TTL
done
@mdpuma
mdpuma / ipmitool-sdr.py
Last active January 29, 2017 13:10 — forked from varesa/gist:2c473b70ffd771e6ffa071654c970aaa
ipmitool sdr for collectd
#!/bin/env python
import os
import subprocess
import time
# subprocess.check_output is not exist in python 2.6 which is on centos6
# hostname = os.getenv("COLLECTD_HOSTNAME", subprocess.check_output(["hostname", "-f"]).strip())
p = subprocess.Popen(["hostname", "-f"], stdout=subprocess.PIPE)
@mdpuma
mdpuma / CentOS.txt
Created February 5, 2017 15:49
Different configuration of ip addresses on distros
# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
BOOTPROTO="static"
HWADDR="00:26:6C:F3:11:A8" # match network interface by mac address
ONBOOT="yes"
TYPE="Ethernet"
IPADDR=XXX.XXX.XXX.XXX
PREFIX=24
GATEWAY=XXX.XXX.XXX.XXX
DNS1=8.8.8.8
@mdpuma
mdpuma / kill_long_mysql_queries.sh
Created April 18, 2017 18:16
kill_long_mysql_queries.sh
#!/bin/bash
IFS='|'
# Id | User | Host | db | Command | Time | State | Info | Progress
mysqladmin pr | sed -E 's/\s+//g' | grep -v '\-\-\-' | grep -vi Time | while read -r id1 id user host db command time state info progress; do
[ -z "$time" ] && continue;
[ "$command" = "Sleep" ] && continue;
if [ "$time" -gt 300 ]; then
mysql -e "kill $id"
echo "killing $id ($db) $info"
@mdpuma
mdpuma / extensions.lua
Created May 11, 2017 18:02 — forked from igmar/extensions.lua
Asterisk LUA dialplan
require("lsqlite3")
-- Igmar: Wanneer closen we dat DB object eigenlijk ?
db = sqlite3.open('/etc/asterisk/users.sqlite')
--CONSOLE = "Console/dsp" -- Console interface for demo
--CONSOLE = "DAHDI/1"
--CONSOLE = "Phone/phone0"
TRUNK = "DAHDI/G1"