Ярлыки

Memories ( 25 ) Unix ( 14 ) FreeBSD ( 8 ) www ( 4 ) Scripts ( 3 ) GEOM ( 2 ) PART ( 2 ) smtp ( 2 ) Cacti ( 1 ) Jabber ( 1 ) KVM ( 1 ) Kohana ( 1 ) RAID ( 1 ) Sip ( 1 ) Ubuntu ( 1 ) Zyxel ( 1 ) nginx ( 1 ) php-fpm ( 1 ) portwfd ( 1 ) rewrite ( 1 ) security ( 1 )

Поиск по этому блогу

четверг, 25 ноября 2010 г.

Удаленная переустановка FreeBSD через SSH


Возникла задача удаленного реинсталла сервера c установленной FreeBSD, осложнявшаяся отсутствием KVM как класса и сложностью доступа к серверу.
Погуглив, было найдено это описание. То, что и было нужно. Нам понадобятся две вещи:


вторник, 23 ноября 2010 г.

Защита от SYN flood при помощи iptables

В один прекрасный момент наблюдаю большую, ничем не обоснованную загрузку http сервера. В логах наблюдаем большое количество запросов стартовой страницы.

Защитимся динамическим правилом в фаерволе, создаем файл /etc/iptables.rules:

Защита от SIP Bruteforce при помощи iptables на CentOS

В один прекрасный момент наблюдаю картину в логе SIP сервера:

[Nov 23 04:04:00] NOTICE[2930] chan_sip.c: Registration from '"529" ' failed for 'xxx.xxx.xxx.xxx' - No matching peer found
[Nov 23 04:04:00] NOTICE[2930] chan_sip.c: Registration from '"529" ' failed for 'xxx.xxx.xxx.xxx' - No matching peer found
[Nov 23 04:04:00] NOTICE[2930] chan_sip.c: Registration from '"529" ' failed for 'xxx.xxx.xxx.xxx' - No matching peer found
[Nov 23 04:04:00] NOTICE[2930] chan_sip.c: Registration from '"529" ' failed for 'xxx.xxx.xxx.xxx' - No matching peer found
[Nov 23 04:04:00] NOTICE[2930] chan_sip.c: Registration from '"529" ' failed for 'xxx.xxx.xxx.xxx' - No matching peer found
[Nov 23 04:04:00] NOTICE[2930] chan_sip.c: Registration from '"529" ' failed for 'xxx.xxx.xxx.xxx' - No matching peer found
[Nov 23 04:04:00] NOTICE[2930] chan_sip.c: Registration from '"529" ' failed for 'xxx.xxx.xxx.xxx' - No matching peer found
....... около 50 строк в секунду .......................................
Защитимся динамическим правилом в фаерволе, создаем файл /etc/iptables.rules:

воскресенье, 21 ноября 2010 г.

Apache2 + SSL + Multiple Virtualhosts = mod_gnutls

Столкнулся с проблемой, когда надо на разные виртуалхосты повесить разные сертификаты SSL. Апач в любом случае берет первый сертификат из конфига и ставит его на все виртуальные SSL-хосты (домены).

четверг, 18 ноября 2010 г.

вторник, 9 ноября 2010 г.

FreeBSD + portfwd + rc-скрипт

Потребовалось однажды сделать на одном серваке с FreeBSD port mapping, причем везде участвовали реальные IP адреса и везде были задействованы одни и те же интерфейсы. То есть  трасса проходила так: inet -> (eth0)Real-IP1,2,3.... -> serv1 -> (eth0)Real-IP1 -> inet -> (eth0)Real-IP4 -> serv2 и обратно в случае firewall кроме редиректа пришлось бы еще городить прямой и обратный NAT. NAT там не был настроен, возиться с подъёмом natd или pf не хотелось, я решил поставить portfwd из портов. Хотя portfwd и работает в режиме демона, но она почему-то не ставит rc-скрипт для запуска себя самой.

среда, 3 ноября 2010 г.

nginx + php 5.2 + php-fpm + zendoptimizer on Centos 5

Добавляем репозитории:

rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
rpm -ihv http://centos.alt.ru/repository/centos/5/x86_64/centalt-release-5-3.noarch.rpm

Обновляемся

yum update

Ставимся

yum install php php-fpm php-common php-mhash php-mcrypt php-mysql php-gd php-bcmath

yum install mysql-server

yum install nginx

yum-install php-zend

yum install php-ioncube - по желанию

Читать:
http://centos.alt.ru
readme.txt
Epel

воскресенье, 3 октября 2010 г.

Возвращаем привычный вид окон в Ubuntu 10.04

К счастью, легко вернуть все к привычному отображению. Достаточно запустить одну команду:
gconftool-2 --set "/apps/metacity/general/button_layout" --type string "menu:minimize,maximize,close"

Для любителей GUI можно запустить gconf-editor и в нем изменить ключ: apps > metacity > general > button layout > menu:minimize,maximize,close

среда, 22 сентября 2010 г.

Cacti: migrating settings and RRD history

I was having a hard time figuring out how to migrate Cacti from one box to another, or more specifically I could do the migration by the book but nothing was working, so after much head scratching and googling I’m going to collate my notes here. This assumes Debian to Debian, and we’ll call the boxes oldcacti and newcacti.

Step 1 is to setup Cacti, RRDTool, SNMP etc on newcacti. This is outside the scope of this post.

Step 2 is to migrate your database, so dump it, scp it to newcacti:

oldcacti:/etc/cacti# mysqldump -u cacti -p > cacti.sql

Enter password:

oldcacti:/etc/cacti# scp cacti.sql root@newcacti:/etc/cacti/

root@newcacti's password:

cacti.sql 100% 463KB 462.5KB/s 00:00

oldcacti:/etc/cacti#

and restore it:

newcacti:/etc/cacti# mysql -u cacti -p < cacti.sql

Enter password:

newcacti:/etc/cacti#

Step 3 All of your settings should now be across, but you'll likely want to keep your RRD history too. Unfortunately you cannot just scp the files across as you'll likely get complaints about the RRD files being created on a different arch:

COMMENT:From 2008/06/18 14:05:32 To 2008/06/19 14:05:32\c

ERROR: Garbage ':05:32 To 2008/06/19 14:05:32\c' after command:

COMMENT:From 2008/06/18 14:05:32 To 2008/06/19 14:05:32\c

ERROR: This RRD was created on other architecture

ERROR: This RRD was created on other architecture

ERROR: This RRD was created on other architecture

ERROR: This RRD was created on other architecture

ERROR: Garbage ':05:41 To 2008/06/19 14:05:41\c' after command:

COMMENT:From 2008/06/18 14:05:41 To 2008/06/19 14:05:41\c

ERROR: Garbage ':05:41 To 2008/06/19 14:05:41\c' after command:

So we need to export the files to xml and then reimport them:

rrdtool dump filename.rrd > filename.xml

rrdtool restore filename.xml > filename.rrd

But if you’ve got dozens, hundreds or even thousands of RRD files, doing them one by one is going to get tired, very quickly. So here we go:

oldcacti:/usr/share/cacti/site/rra/# ls -1 *.rrd | awk '{print "rrdtool dump "$1" > "$1".xml"}' | sh -x

scp *.xml root@newcacti:/usr/share/cacti/site/rra/

followed by:

newcacti:/usr/share/cacti/site/rra/# rm *.rrd

newcacti:/usr/share/cacti/site/rra/# ls -1 *.rrd.xml | sed 's/\.xml//' | awk '{print "rrdtool restore "$1".xml "$1}' | sh -x

newcacti:/usr/share/cacti/site/rra/# rm *.xml

newcacti:/usr/share/cacti/site/rra/# chown www-data:www-data *

That should be it, the final chown ensures that Apache can actually open the files and present them. Assuming Cacti et al is configured right on newcacti, you should be seeing some pretty graphs :)


(С) http://www.rawiriblundell.com/

четверг, 19 августа 2010 г.

FreeBSD + HDD with 4k sector drives + gmirror - degraded I/O

Итак имеется два HDD WDC WD6400AARS с новомодной опцией ADF - "Advanced Disk Format". По неопытности отформатированные стандартным sysinstall при установке FreeBSD 8.1.  Все бы ничего, но дав нагрузку на сервер при помощи обычного cp -r наблюдаем практически 100% падение производительности всей системы, при детальном изучении проблемы видим, что процесс копирования занимает 100% I/O при этом другие процессы ожидают в очереди для доступа к HDD. Ну и естественно затормозил в первую очередь MySql выполняя простейшие запросы настолько долго что клиенты отваливались по тайм-ауту.

вторник, 22 июня 2010 г.

Zyxel ES-2108 - выпадание из сети менеджмента

Столкнулся с проблемой выпадания Zyxel ES-2108 из сети при передергивании питания, или семене влана на порту свича - он перестает пинговаться но успешно продолжает работать и пробрасывать vlan-ы. При этом сам свич не отзывается по ip менеджмента и помогает только передергивание down-линка на вышестоящем свиче. Есть другое решение, которое устраняет эту проблему!
На порту аплинка(Advanced Application -> VLAN -> VLAN Port Setting) должно стоять: Acceptable Frame Type=[ALL] вместо [Tag Only]. Для безопасности ставим PVID=1 и снимаем галку с ACTIVE на 1м vlan в секции "Static VLAN".