wiki'd

by JoKeru

sar

[cc lang='bash']
\$ apt-get install sysstat -y

# all cpus
\$ sar -u ALL 1
# per cpu
\$ sar -P ALL 1
# memory
\$ sar -r 1
# swap
\$ sar -S 1
# overall i/o
\$ sar -b -v 1
# individual i/o
\$ sar -d -p 1
# process, context switch
\$ sar -w 1
# run queue, load …

nf_conntrack: table full, dropping packet.

[cc land='bash']
\$ cat /proc/sys/net/ipv4/netfilter/ip_conntrack_max
65536
\$ sysctl net.netfilter.nf_conntrack_count
net.netfilter.nf_conntrack_count = 65536

\$ rmmod iptable_nat
\$ rmmod ipt_MASQUERADE
\$ rmmod nf_nat
\$ rmmod ipt_REDIRECT
\$ rmmod nf_nat
\$ rmmod nf_conntrack_ipv4
\$ rmmod nf_defrag_ipv4
\$ rmmod nf_conntrack
\$ rmmod xt_state
\$ rmmod nf_conntrack
[/cc]

Listing the nat tables with `iptables -t nat -L` will …

Run parallel cURL requests using PHP and BASH

[cc lang='php']
<?php< p ?>

// my linux curl
function my_curl (\$i, \$url, \$post_data, \$return=0, \$auth='', \$proxy='', \$timeout=5) {
\$curl="/usr/bin/curl -s";
if (\$post_data!='') \$curl.=" --data '\$post_data'";
if (\$timeout!='') \$curl.=" --connect-timeout \$timeout";
if (\$auth!='') {
list(\$user,\$pass)=explode(':',\$auth);
\$curl.=" --basic --user \$user:\$pass";
}
if (\$proxy!='') {

list(\$proxy_ip …

Get Web Server response code with wget

[cc lang='bash']
\$ wget --bind-address=1.2.3.4 --spider --server-response http://www.google.com 2>&1 | awk '/\^ HTTP/{print \$2}'
[/cc]

IP Accounting with pmacct

[cc lang='bash']
\$ apt-get install pmacct
\$ vi /etc/pmacct/pmacctd.conf
\$ vi /etc/pmacct/hosts
\$ /etc/init.d/pmacct restart

\$ pmacct -s
SRC_IP DST_IP PACKETS BYTES
0.0.0.0 5.4.3.2 1681 808962
0.0.0.0 1.2.3.4 25 2168
1.2.3.4 …

Webmin on Debian

[cc lang="bash"]
\$ apt-get install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl apt-show-versions python
\$ wget http://prdownloads.sourceforge.net/webadmin/webmin_1.610_all.deb
\$ dpkg --install webmin_1.610_all.deb

\$ vi /etc/webmin/miniserv.conf
- listen=10000
+ bind=10.20.30.40

\$ /usr/libexec/webmin/changepass.pl /etc/webmin root webmin_pass

\$ service webmin …

Dante SOCKS Server

[cc lang='bash']
\$ cd /usr/src/
\$ wget http://www.inet.no/dante/files/dante-1.3.2.tar.gz
\$ gunzip dante-1.3.2.tar.gz
\$ tar -xf dante-1.3.2.tar
\$ cd dante-1.3.2/
\$ ./configure
\$ make
\$ make install

\$ /usr/local/sbin/sockd -D -N 5 -f /etc/danted.conf
\$ tail …

MySQL Load Balancing and Read-Write Splitting with mysql-proxy

[cc lang='bash']
\$ apt-get install -y mysql-proxy
\$ vi /etc/default/mysql-proxy
\$ vi /etc/mysql-proxy
\$ chmod 0660 /etc/mysql-proxy
\$ /etc/init.d/mysql-proxy start
[/cc]

/etc/default/mysql-proxy
[cc lang='bash']
ENABLED="true"
OPTIONS="--defaults-file=/etc/mysql-proxy"
[/cc]

/etc/mysql-proxy
[cc lang='bash']
[mysql-proxy]

admin-address = 192.168.0.10:4041

proxy-address …

Squid3 Transparent Proxy

[cc lang='bash']
\$ apt-get install squid3
\$ iptables -t nat -A PREROUTING -i eth1 -p tcp -m tcp --dport 80 -j DNAT --to-destination 192.168.0.1:3128
[/cc]

/etc/squid3/squid.conf
[cc lang='bash']
http_port 3128 transparent
acl our_networks src 192.168.0.0/24
acl localnet src 127 …

JunOS New Aggregate Interface

[cc lang='bash']
ge-2/0/19 {
description FWLI94NOIMEPMUT002-eth1/4;
ether-options {
802.3ad ae43;
}
}

ae43 {
description "FWLI94NOIMEPMUT002-eth1/4";
unit 0 {
family ethernet-switching {
port-mode trunk;
vlan {
members [ 12 40 50 140 150 ];
}
}
}
}
[/cc]