Pegar Ip Publico via Comando

Using wget

wget -q -O – checkip.dyndns.org|sed -e ‘s/.*Current IP Address: //’ -e ‘s/<.*$//’

Using curl

curl -s checkip.dyndns.org|sed -e ‘s/.*Current IP Address: //’ -e ‘s/<.*$//’

curl -s http://whatismyip.org/

Using Lynx

lynx -dump checkip.dyndns.org

lynx -dump www.whatismyip.com | grep ‘Your IP’

Crédito : http://go2linux.garron.me/what-is-my-public-ip-address-with-linux

Nat Iptables Fora Proxy

iptables -t nat -I PREROUTING -d 81.25.144.138 -j ACCEPT

Named Logs – named network unreachable resolving

CentOS 5.3 upgrades to CentOS 5.4 causing named or BIND DNS server to producing a lot of “network unreachable resolving … ” errors in system logs /var/log/messages causing the log file increasing in size tremendously on busy system.

 

Root Caused of the issue :

According to the change log of BIND for CentOS 5.4 updates (bind-chroot-9.3.6-4.P1.el5_4.1) , the latest BIND DNS server as default is now enable for IPV6 DNS resolving. Any DNS query will caused the program to also resolved IPV6 IP although the host server or client is not IPV6 enable or capable

Workaround / Solution :

Disable the IPV6 in BIND. For CentOS 5.4, edit the /etc/sysconfig/named file and add the following options into the BIND startup

OPTIONS=”-4″

This will cause the BIND server to only resolve or use IPV4 and disable IPV6 support. Save the file and restart BIND server.

That will stop those annoying error message.

Créditos : http://www.hafizonline.net/blog/?p=164

Link Script Perl “loco”

https://launchpad.net/ubuntu/+source/loco

Correção do erro da biblioteca libevent

error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory

The solution for this on Debian/Ubuntu (and probably most other linux distros) is this…

On a 32 bit system:

ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib/libevent-2.0.so.5

On a 64 bit system:

ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5

Créditos : http://www.nigeldunn.com/2011/12/11/libevent-2-0-so-5-cannot-open-shared-object-file-no-such-file-or-directory/

XenServer – Complementares

[root@xenserver /]# cat /etc/rc.local

# usb_storage
modprobe -r usb_storage
modprobe usb_storage

# auto start vm
# pool auto_start
xe pool-param-set uuid=cb7ba7a3-5cf5-b738-2806-3f74e8d71cfd other-config:auto_poweron=true
sleep 20
# vms manual_start
xe vm-start uuid=b8f68d5c-c764-9135-67a5-a050c397d23f
sleep 20
xe vm-start uuid=c7261f28-1207-59f9-8c29-bd7c1ef7f376

# mount usb_storage
sleep 60
/etc/init.d/usbautomount.sh attach

[root@xenserver /]# xe vm-list
[root@xenserver /]# xe pool-list
[root@xenserver /]# xe sr-list

30 22 * * 0,2,4 /usr/bin/php /usr/local/bin/purgeBackup.php
45 22 * * 0,2,4 /usr/bin/perl /usr/local/bin/backup.pl

 

Erro – /bin/bash^M: bad interpreter: no such file or directory

Quando tentei executar um script .sh o seguinte erro ocorreu:

/bin/bash^M: bad interpreter: no such file or directory

Causa

Provavelmente o arquivo .sh foi editado no windows utilizado algum editor como o notepad, o caractere ^M representa algum ctrl+v realizado no windows.

Solução

A solução é converter estes caracteres utilizando o programa dos2unix

Exemplo para o arquivo backup.sh:

dos2unix backup.sh

Créditos : http://ldiasrs.wordpress.com/2011/08/24/linuxbash-erro-binbashm-bad-interpreter-no-such-file-or-directory/

Script Backup VMs – Xenserver

Original Script : http://community.citrix.com/display/xs/0+downtime+snapshot+based+
XENServer+5.5+backup+script.

Script Modificao : xenserverbkp.tar.gz

SendEmail & Patch AppGoogle

Link SendEmail : http://caspian.dotconf.net/menu/Software/SendEmail/

$ yum install perl perl-Net-SSLeay perl-IO-Socket-SSL make automake gcc g++

Se você estiver testando o SendEmail e estiver obtendo a mensagem “ERROR => Received: 535 5.7.0 Error: authentication failed: bad protocol / cancel” mesmo após ter revisado exaustivamente seus argumentos, você pode ter encontrado o bug descrito aqui.
Este bug afeta o SendEmail após este incorporar o recurso TLS. Consiste em uma falha na forma como SendEmail codifica as linhas que envia durante o processo de autenticação.
A boa notícia é que, caso você esteja usando a versão 1.55, você poderá usar o patch postado no link acima para corrigir este problema.
Para efetuar o patch você precisará do pacote patch:

$ yum install patch

Em seguida faça o download do patch disponibilizado no link acima. Sugiro que coloque o path no seu /tmp. Para aplicar o patch bastará executar a seguinte instrução:

$ patch -b -p1 </tmp/sendEmail.patch

A instrução poderá emitir um prompt perguntando pelo arquivo a ser “atualizado”. Informe /usr/bin/sendEmail, que – como vimos acima – é o local onde fica instalado o script do SendEmail.
Então estará concluído. Refaça seu teste. Se a falha se devia ao bug do TLS, seu teste deverá funcionar. De qualquer forma, se não estiver satisfeito com o patch, ele poderá ser desfeito, uma vez que a opção -b usada acima fez com que o patch criasse uma cópia do sendEmail, antes de aplicar a atualização. Esta cópia deverá estar na pasta /usr/bin com o nome de sendEmail.orig, (podendo variar, conforme a distro que estiver usando).

Créditos : http://sistemasecia.freehostia.com/component/jccmultilanguagecontent/article/51-sendemail.html?start=1

Script Perl para Apagar Fila Postfix

Traditionally you use the “sendmail -q” command to flush mail queue under Sendmail MTA. Under Postfix MTA, just enter the following command to flush the mail queue:
# postfix flush
OR
# postfix -f

To see mail queue, enter:
# mailq

To remove all mail from the queue, enter:
# postsuper -d ALL

To remove all mails in the deferred queue, enter:
# postsuper -d ALL deferred

postfix-delete.pl script

Following script deletes all mail from the mailq which matches the regular expression specified as the first argument (Credit: ??? – I found it on old good newsgroup)

  1. #!/usr/bin/perl
  2. $REGEXP = shift || die “no email-adress given (regexp-style, e.g. bl.*\@yahoo.com)!”;
  3. @data = qx</usr/sbin/postqueue -p>;
  4. for (@data) {
  5. if (/^(\w+)(\*|\!)?\s/) {
  6. $queue_id = $1;
  7. }
  8. if($queue_id) {
  9. if (/$REGEXP/i) {
  10. $Q{$queue_id} = 1;
  11. $queue_id = “”;
  12. }
  13. }
  14. }
  15. #open(POSTSUPER,”|cat”) || die “couldn’t open postsuper” ;
  16. open(POSTSUPER,”|postsuper -d -“) || die “couldn’t open postsuper” ;
  17. foreach (keys %Q) {
  18. print POSTSUPER “$_\n”;
  19. };
  20. close(POSTSUPER);

For example, delete all queued messages from or to the domain called fackspamdomain.com, enter:
./postfix-delete.pl fackspamdomain.com
Delete all queued messages that contain the word “xyz” in the e-mail address:
./postfix-delete.pl xyz

Updated for accuracy.

Créditos : http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html