Read post variables > if (isset($_POST[‘submit’]) ) { foreach($_POST as $key=>$value) { $$key = $value; }
Block Sites by IP Open httpd.conf and set AllowOverride All restart apache web server and create a .htaccess file on the directory you want to block by ip : order deny,allowallow from x.y.z.a deny from all
Rsync to synchronize directory Sync Files or folders to a remote host from local host : Rsync Syntax : #rsync options source destination -v, --verbose increase verbosity -q, --quiet decrease verbosity -c, --checksum always checksum -a, --archive archive mode. It is a quick way of saying you want recursion and want to preserve everything. -r, --recursive
Shell Script Disk Usage Notification > !/bin/sh Alert Email Address ALERT_EMAIL=”email address” ALERT_LEVEL=10 NO_MONITOR=”/dev/shm” #use pipe to separate multiple function calculate_usage() { while read raw_input; do used_space=$(echo $raw_input | awk ‘{ print $1}’ | cut -d’%’ -f1) partition=$(echo $raw_input | awk ‘{print $2}’) if [ $used_
Common Sendmail Issues ** DSN: Service unavailable** RESOLUTION: set hostname other than localhost -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- Relay host : open /etc/mail/sendmail.mc and configure SMART HOST to your relay and remove the dnl at the front. vi /etc/mail/sendmail.mc dnl define(SMART_HOST', relayserver.domain.com')dnl make it look
Create an ISO image in linux dd if=/dev/cdrom of=~/cdrom_image.iso or mkisofs -o /tmp/cd.iso /tmp/directory
Cisco ACL - Insert New line > 1. conf t 2. ip access-list {standard | extended} access-list-name 3. sequence-number acl 4. ip access-list resequence access-list-name starting-sequence-number increment eg. ip access-list resequence 111 100 15
mysql Backup restore mysql database > `mysqldump --databases db1 db2 db3 db4 > backup.sql``` > mysqldump --all-databases > backup.sql If you get an error that says : Got a packet bigger than ‘max_allowed_packet’ bytes then increase your max allowed packet either in my.cnf or in mysql shell mysql>set global
linux user no password Sudo Tips and Tricks In many cases, if you are writing shell scripts to do certain tasks, you might need to grant access to the user to some commands without requiring interaction. In that case you might want to grant access without requiring password. This is possible with sudo. visudo Go to command alias
mysql Vsftpd With Mysql backened Vsftpd With Mysql Backened EL 5 pam_mysql.so wget ftp://ftp.pbone.net/mirror/centos.karan.org/el5/extras/testing/i386/RPMS/pam_mysql-0.7-0.5.rc1.el5.kb.2.i386.rpm [ftp://ftp.pbone.net/mirror/centos.karan.org/el5/extras/testing/i386/RPMS/pam_mysql-0.7-0.5.
Setting default group permission on a directory Setting default group permission on a directory Set recursive sticky bit for the group on dir > chmod -R g+s /path/to/dir Recursively set group ownership of the directory > chown -R user:group /path/to/dir
Linux Set Time zone In Linux Setting Desired Time Zone In Linux View the list of available Timezones: ls /usr/share/zoneinfo cd /etc/<br></br> mv localtime localtime.old<br></br> ln -sf /usr/share/zoneinfo/GMT localtime<br></br> /sbin/hwclock --systohc&
linux copy files SCP 1. Copy files from your server to a remote server > scp -P -r <dir_name> user@remotehost:<remote_dir></remote_dir></dir_name> <dir_name><remote_dir> 2. Copy files from remote server to your machine<
Ip Authentication in Kamailio **IP baseed Authentication in Kamailio for Peers. ** > route[PEER]{ if (allow_trusted("$si","$(proto)")) { xlog("L_INFO","\n\n–Trusted IP – $si – $proto"); record_route(); route(LCR); }; if (allow_address("1", "$si", "$sp")) { xlog("
Create View for simplifying LCR tables **MySQL View to simplify Kamailio LCR Tables ** > create view openser.nt_dialplan As SELECT t.rule_id,r.lcr_id,prefix,from_uri,stopper,enabled,gw_id,priority,weight FROM lcr_rule r, lcr_rule_target t WHERE r.id = t.rule_id
iptables Iptables Neat Tips Separate Log File For Iptables : vi /etc/syslog.conf -------------------------------------------------------------------------------- Append to the file : kern.warning /var/log/iptables.log Restart syslog daemon. Now you can block any ip and log it to the file iptables -A INPUT -s x.x.x.x -m limit --limit 5/m --limit-burst 7
Kamailio Nat Traversal using RTPProxy 1. Install rtpproxy : > `http://b2bua.org/chrome/site/rtpproxy-1.2.1.tar.gz``` > tar -zxvf rtpproxy-1.2.1.tar.gz<br></br> cd rtpproxy-1.2.1<br></br> ./configure<br></br> make<br><
Using LCR with kamailio Follow the tutorial here to implement LCR with kamailio : 1. Add lcr.so to load module loadmodule lcr.so 2. Add required parameters to the module modparam(“lcr”,”db_url”,DBURL) modparam(“lcr”, “gw_uri_avp”, “$avp(i:709)”) modparam(“lcr”, “ruri_user_avp”, “$avp(i:500)”) modparam(“lcr”, “flags_
Compiling additional modules kamailio If you need to install additional modules you might need after you install kamailio : 1. cd /usr/local/src/kamailio-3.1.1 2.make FLAVOUR=kamailio cfg 3.make install-modules modules=modules/lcr Assuming that lcr is the module that you want to install additionally.
Using Ngrep To capture network activity You can use ngrep to diagnose your sip or other network activity : Dependency : libpcap-devel yum install libpcap-devel Download ngrep [http://downloads.sourceforge.net/project/ngrep/ngrep/1.45/ngrep-1.45.tar.bz2?r=http%3A%2F%2Fngrep.sourceforge.net%2Fdownload.html&ts=1296767443&use_mirror=voxel] wget http:
Install kamailio from source Centos <strong>Dependencies :</strong><br></br> Yum install bison pcre-devel libpcap-devel``` **Installation :** 1. Go to /usr/local/src/ 2. Download The latest version of kamailio 3.1.2 from source : [Download Latest Kamailio Source Here](http://www.kamailio.org/pub/kamailio/latest/src/
Rest Mysql root Password Reset Mysql Root Password 1. Kill the mysql daemon by loggin in as root 2. Start mysql in safe mode : mysqld_safe --skip-grant-tables 3. SSH using another session or login to another terminal<br></br> 4. Connect to mysql without password, you should be able to
Using grep to display line that doesnot start with a pattern If you want to display a line, that does not begin with a pattern you can use grep to achieve that. It is specially useful when you want to view the lines that are not commented in a configuration file. grep -v “^;” ( This will display lines that dont start with
Use cron to sync time using ntp Sync the Time once a day at 2.00 `0 2 * * * /usr/sbin/ntpdate -s -b -p 8 -u``` or 0 2 * * * /usr/sbin/ntpdate -s -b -p 8 -u 0.us.pool.ntp.org