wiki'd

by JoKeru

ISG New Zone

[cc lang='bash']
get zone \<- get next available zone id

set zone id 1005 "MUT_SERV_DI"
set zone "MUT_SERV_DI" tcp-rst
set interface "aggregate1.3" tag 241 zone "MUT_SERV_DI"
set interface aggregate1.3 ip 192.168.241.254/24
set interface aggregate1.3 route
[/cc]

Server & Services monitoring with Monit

[cc lang='bash']
\$ apt-get install monit
\$ vi /etc/default/monit
\$ vi /etc/monit/monitrc
\$ /etc/init.d/monit start
[/cc]

/etc/monit/monitrc
[cc lang='bash']
set daemon 60 # check services at 1 minute intervals
set logfile syslog facility log_daemon # log to /var/log/daemon.log
set mailserver localhost port …

socket(): Too many open files

[cc lang="bash"]
\$ ulimit -n
1024
\$ echo "root soft nofile 10240" >> /etc/security/limits.conf
\$ echo "root hard nofile 10240" >> /etc/security/limits.conf

# LogOut & LogIn
\$ ulimit -n
10240
[/cc]

Linux BackUp Script

/root/backup/cfg
[cc lang='bash']
named /etc/named.conf /var/named/jokeru.ro
postfix /etc/postfix/conf/
dkim /etc/mail/dkim-milter/dkim-filter.conf
[/cc]

/root/backup/run.sh
[cc lang='bash']
#!/bin/bash
host='wiki'
here='/root/backup/'

cd \$here
while read line
do
name=`echo \$line | awk '{print …

Twisted DNS Authoritative Server

[cc lang='bash']
\$ yum install python-twisted

\$ vi test.zone
\$ twistd dns --pyzone test.zone --interface 127.0.0.1 --port 53053
\$ netstat -tulnp | grep 53053
tcp 0 0 127.0.0.1:53053 0.0.0.0:* LISTEN 14391/python
udp 0 0 127.0.0.1:53053 0.0 …

DNS Filtering

A simple DNS Proxy that returns NXDOMAIN if the master offers an IP from a specified blacklist.

[cc lang='bash']
\$ yum install python-twisted
\$ wget https://github.com/lamby/dns-filter/zipball/master
\$ unzip master
\$ cd lamby-dns-filter-9c5d40d
\$ vi dns-filter.conf
\$ ./run.sh &

\$ netstat -tulnp | grep 53
udp 0 0 0.0.0 …

Install RAR / UnRAR on CentOS

Go to http://pkgs.repoforge.org/rpmforge-release/ and get latest rpm

[cc lang="bash"]
\$ wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
\$ rpm -i rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
\$ yum install rar unrar
[/cc]

Add SSL to Postfix

[cc lang="bash"]
\$ vi /etc/postfix/master.cf
\$ /etc/init.d/postfix restart

\$ netstat -tulnp | grep master
tcp 0 0 0.0.0.0:465 0.0.0.0:* LISTEN 5398/master
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 5398/master

\$ openssl s_client -connect …

Add SASL Auth to Postfix

[cc lang="bash"]
\$ apt-get install libsasl2-2 libsasl2-modules libsasl2-modules-sql sasl2-bin libpam-mysql
\$ mkdir -p /var/spool/postfix/var/run/saslauthd
\$ vi /etc/default/saslauthd
\$ vi /etc/pam.d/smtp
\$ vi /etc/postfix/sasl/smtpd.conf

\$ adduser postfix sasl
\$ /etc/init.d/postfix restart
\$ /etc/init.d/saslauthd restart
[/cc]

/etc/default/saslauthd …

Test SMTP Auth

[cc lang="bash"]
\$ perl -MMIME::Base64 -e 'print encode_base64("\000test\@jokeru.ro\000password")'
AHRlc3RAam9rZXJ1LnJvAHBhc3N3b3Jk

\$ telnet mail.jokeru.ro 25 \<- no security
or
\$ openssl s_client -crlf -connect mail.jokeru.ro:25 -quiet \<- SSL
or
\$ openssl s_client -crlf -starttls smtp -connect mail.jokeru.ro:25 -quiet \<- TLS

EHLO testing
AUTH PLAIN AHRlc3RAam9rZXJ1LnJvAHBhc3N3b3Jk …