Кабель для подключения с разъёмами DB-9 мама на обоих концах, распиновка:
DB9 мама | DB9 мама |
pin 2 | pin 3 |
pin 3 | pin 2 |
pin 5 | pin 5 |
Устанавливаем minicom:
sudo apt-get update; sudo apt-get install minicom
Изменяем конфигурацию: minicom -s
Ставим порт /dev/ttyS0 скорость и чётность 9600 8N1
Подключаемся: sudo minicom
Полезные ссылки по настройке Foxgate S6224 :
Блокировка DHCP серверов на коммутаторах FoxGate
Настройка коммутатора Foxgate S6224-S2
Как ловить широковещательный флуд на коммутаторах FoxGate
Для избежания возможного использования сервера в различных зловредных целях не обязательно его полностью фаерволить, можно просто отконфигурить соответствующим образом. Достаточно закрыть возможность использовать клиентские команды и команды управления демоном извне.
Короткий рецепт выглядит приблизительно так:
- вписываем сервера для синхронизации
server ntp1.colocall.net
server ntp2.colocall.net
server ntp.time.in.ua
server ntp2.time.in.ua
- запрещаем доступ всем
restrict default ignore
- открываем полный доступ для локалхоста
restrict 127.0.0.1
-открываем доступ всем остальным, для начала тем серверам с которыми синхронизируемся
restrict ntp1.colocall.net nomodify noquery nopeer notrap
restrict ntp2.colocall.net nomodify noquery nopeer notrap
restrict ntp.time.in.ua nomodify noquery nopeer notrap
restrict ntp2.time.in.ua nomodify noquery nopeer notrap
restrict 0.ua.pool.ntp.org nomodify noquery nopeer notrap
restrict 1.ua.pool.ntp.org nomodify noquery nopeer notrap
restrict 2.ua.pool.ntp.org nomodify noquery nopeer notrap
restrict 3.ua.pool.ntp.org nomodify noquery nopeer notrap
restrict time.windows.com nomodify noquery nopeer notrap
restrict time.nist.gov nomodify noquery nopeer notrap
- можно открыть доступ для синхронизации времени из подсети
restrict 192.168.200.0 mask 255.255.255.0 nomodify noquery nopeer notrap
Проверяем и видим успешные конекты:
# ntpq -c peers
remote refid st t when poll reach delay offset jitter
==============================================================================
-ns4.pay-port.ki 193.190.230.65 2 u 47 64 377 0.679 12.676 0.845
193.27.209.211 .RMOT. 16 u - 64 0 0.000 0.000 0.000
shkvoren.tntu.e .INIT. 16 u - 64 0 0.000 0.000 0.000
alpha.lvivlan.n .RMOT. 16 u - 64 0 0.000 0.000 0.000
ntp1.colocall.n 62.149.0.30 2 u 42 64 377 0.666 13.765 0.778
servers-gw.colo 62.149.0.30 2 u 46 64 377 0.849 14.301 1.010
*ntp.time.in.ua .GPS. 1 u 42 64 377 0.798 13.666 0.729
+ntp2.time.in.ua .GPS. 1 u 39 64 377 0.695 12.768 1.155
212.111.205.73 .INIT. 16 u - 64 0 0.000 0.000 0.000
burka.carrier.k .INIT. 16 u - 64 0 0.000 0.000 0.000
x64.4.10.33 10.20.229.51 2 u 43 64 377 189.454 28.234 9.058
+nist1-chi.ustim .ACTS. 1 u 47 64 157 140.767 14.555 2.913
Значения директив из ман ntp.conf :
noquery Deny ntpq(8) and ntpdc(8) queries. Time service is not
affected.
nopeer Deny packets which would result in mobilizing a new asso-
ciation. This includes broadcast and symmetric active
packets when a configured association does not exist.
nomodify Deny ntpq(8) and ntpdc(8) queries which attempt to modify
the state of the server (i.e., run time reconfiguration).
Queries which return information are permitted.
notrap Decline to provide mode 6 control message trap service to
matching hosts. The trap service is a subsystem of the
ntpdq control message protocol which is intended for use
by remote event logging programs.
Уязвимость, или точнее, возможность использования, а также один из вариантов решения описаны здесь - http://freehost.com.ua/faq/articles/ataka-s-pomoschju-servera-vremeni-ntp-na-vashem-servere/ :
13 января 2014 года US-CERT выпустило предупреждение о новом способе DDOS атак, при помощи уязвимости в старых версиях протокола NTP. Данный протокол используется для синхронизации времени.
Атака основана на опции monlist, которая включена по умолчанию на старых версия протокола. Этот запрос получает список последних 600 клиентов воспользовавшихся сервисом. Вследствие поддельного адреса отправителя список отсылается жертве. Поскольку объем ответа многократно больше запроса, злоумышленнику удается усилить объем трафика направленного на жертву. Помимо увеличения трафика на сервере так же увеличивается, многократно нагрузка.
Поскольку ответами от сервера являются обычные данные, которые вполне могли запрашиватся у обычных серверов времени, данный тип атак особенно сложно «разоблачить». Решение является отключение возможности мониторинга серверов или обновление версии.
На платформе unix c помощью данной команды можно проверить наличие уязвимости:
# ntpdc -c monlist 127.0.0.1
# ntpdc -c monlist 127.0.0.1
remote address port local address count m ver code avgint lstint
===============================================================================
localhost 51569 127.0.0.1 1 7 2 0 0 0
x.x.x.x 4641 10.100.0.254 261324 3 3 180 30 2
.....................................................................................................
откллючаем функцию мониторинга
# vi /etc/ntp.conf
в конце файла добавиляем
disable monitor
Выполняем перезагрузку сервера
команда в зависимости от ОС. Обычно reboot
/etc/rc.d/ntpd restart
Проверить правильность выполненных действий можно так:
# ntpdc -c monlist 127.0.0.1
***Server reports data not found
---------------------------------------------------------------------------------------
Конфиг для копипаста(строгий, запросы времени отключены для всех):
##################################################
server ntp.time.in.ua
server ntp2.time.in.ua
server ntp1.colocall.net
server ntp2.colocall.net
restrict default ignore
restrict 127.0.0.1
restrict ntp.time.in.ua nomodify noquery nopeer notrap
restrict ntp2.time.in.ua nomodify noquery nopeer notrap
restrict ntp1.colocall.net nomodify noquery nopeer notrap
restrict ntp2.colocall.net nomodify noquery nopeer notrap
restrict 0.ua.pool.ntp.org nomodify noquery nopeer notrap
restrict 1.ua.pool.ntp.org nomodify noquery nopeer notrap
restrict 2.ua.pool.ntp.org nomodify noquery nopeer notrap
restrict 3.ua.pool.ntp.org nomodify noquery nopeer notrap
restrict time.windows.com nomodify noquery nopeer notrap
restrict time.nist.gov nomodify noquery nopeer notrap
################################################
Конфиг для копипаста(не строгий, запросы времени разрешены):
##################################################
server ntp.time.in.ua
server ntp2.time.in.ua
server ntp1.colocall.net
server ntp2.colocall.net
restrict default nomodify nopeer noquery notransfer notrap limited kod
restrict 127.0.0.1
Задача. Нужно скопировать права mysql пользователя
Для решения задачи, можно воспользоваться утилитой mk-show-grants из порта maatkit, который есть в репозиториях Gentoo.
Устанавливаем:# emerge --sync
# emerge -av maatkit
Запускаем: # mk-show-grants | grep "'user'@'192.168.0.10'" | sed 's/192.168.0.10/192.168.0.20/g' | mysql
За основу был взята статья отсюда:
http://blog.mohiva.com/2011/11/setting-up-mail-server-with-postfix.html
На момент написания, актуальные версии софта:
postfix-2.10.2
dovecot-2.2.10
postfixadmin-2.3.6
roundcube-0.9.5
echo "mail-mta/postfix mysql dovecot-sasl ssl" >> /etc/portage/package.use
echo "net-mail/dovecot mysql maildir ssl sieve managesieve" >> /etc/portage/package.use
echo "www-apps/postfixadmin mysql vhosts" >> /etc/portage/package.use
echo "mail-client/roundcube vhosts" >> /etc/portage/package.use
pdo gd sockets - required for roundcube
echo "dev-lang/php imap myqsqli pdo gd sockets" >> /etc/portage/package.use
emerge -av postfix postfixadmin dovecot amavisd-new
in mysql :
CREATE DATABASE `[postfixadmin]` CHARACTER SET `utf8` COLLATE `utf8_general_ci`; GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, INDEX ON `[postfixadmin]`.* TO '[postfixadmin]'@'[localhost]' IDENTIFIED BY '[secret]'; GRANT SELECT ON `[postfixadmin]`.* TO '[mailauth]'@'[localhost]' IDENTIFIED BY '[secret]';
В консоли
mkdir /var/vmail
useradd -d /var/vmail -U -s /bin/false vmail
chown vmail:vmail /var/vmail
chmod 770 /var/vmail
Before you start to edit the configuration files, Postfix must know where it should send mails to local users. Therefore exists the file /etc/mail/aliases. It specifies several aliases for the most system accounts. Postfix must translate these aliases to real addresses. So edit the file and set a real mail address for the root and the operator account.
# Well-known aliases -- these should be filled in! root:Этот адрес электронной почты защищён от спам-ботов. У вас должен быть включен JavaScript для просмотра. operator:Этот адрес электронной почты защищён от спам-ботов. У вас должен быть включен JavaScript для просмотра.
Run the newaliases command to recreate the alias database.
newaliases
in /etc/postfix/main.cf
mailbox_command = /usr/libexec/dovecot/dovecot-lda myhostname = [mail.domain.com] mydomain = [domain.com] myorigin = $myhostname mydestination = $myhostname, localhost mynetworks = 127.0.0.0/8 mynetworks_style = host inet_interfaces = $myhostname, localhost relay_domains = $mydestination alias_maps = hash:/etc/mail/aliases alias_database = hash:/etc/mail/aliases smtpd_tls_security_level = may smtpd_tls_auth_only = yes smtpd_tls_key_file = /etc/ssl/postfix/[mail.domain.com.key.pem] smtpd_tls_cert_file = /etc/ssl/postfix/[mail.domain.com.cert.pem] smtpd_tls_loglevel = 1 smtpd_tls_received_header = yes smtpd_tls_session_cache_timeout = 3600s smtpd_error_sleep_time = 60 smtpd_soft_error_limit = 60 smtpd_hard_error_limit = 10 smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_non_fqdn_hostname reject_non_fqdn_sender, reject_non_fqdn_recipient, reject_unknown_sender_domain, reject_unknown_recipient_domain, reject_unauth_destination, reject_unauth_pipelining, reject_invalid_hostname, reject_rbl_client list.dsbl.org, reject_rbl_client sbl.spamhaus.org, reject_rbl_client bl.spamcop.net, permit tls_random_source = dev:/dev/urandom tls_random_prng_update_period = 3600s smtpd_sasl_type = dovecot smtpd_sasl_path = private/auth smtpd_sasl_auth_enable = yes smtpd_sasl_security_options = noanonymous smtpd_sasl_authenticated_header = yes mailbox_command = /usr/libexec/dovecot/deliver smtpd_helo_required = yes strict_rfc821_envelopes = yes disable_vrfy_command = yes virtual_transport = dovecot virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domain_maps.cf virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf virtual_uid_maps = static:[1001] virtual_gid_maps = static:[1001] dovecot_destination_recipient_limit = 1
mysql_virtual_alias_maps.cf
user = [mailauth] password = [secret] hosts = [localhost] dbname = [postfixadmin] query = SELECT goto FROM alias WHERE address='%s' AND active = '1'
mysql_virtual_domain_maps.cf
user = [mailauth] password = [secret] hosts = [localhost] dbname = [postfixadmin] query = SELECT domain FROM domain WHERE domain='%s' AND backupmx = '0' AND active = '1'
mysql_virtual_mailbox_maps.cf
user = [mailauth] password = [secret] hosts = [localhost] dbname = [postfixadmin] query = SELECT CONCAT(maildir, 'Maildir/') AS maildir FROM mailbox WHERE username='%s' AND active = '1'
master.cf
The master.cf defines which services are available, which daemons should be started for a requested service and how a client connects to a service. In this file we must only setup two additional services. So first of all you must uncomment the smtps service in order to use the secure variant of the smtp protocol.
smtps inet n - n - - smtpd -o smtpd_tls_wrappermode=yes -o smtpd_sasl_auth_enable=yes -o smtpd_client_restrictions=permit_sasl_authenticated,reject -o milter_macro_daemon_name=ORIGINATING
For using the Dovecot LDA to deliver emails for virtual domains, you must add the dovecot service to the end of the file.
dovecot unix - n n - - pipe flags=DRhu user=vmail:vmail argv=/usr/libexec/dovecot/deliver -f ${sender} -d ${recipient}
in /etc/dovecot/dovecot.conf :
protocols = imap listen = *, [::]
in /etc/dovecot/conf.d/10-ssl.conf :
ssl = yes ssl_cert = <[/etc/ssl/dovecot/mail.domain.com.cert.pem] ssl_key = <[/etc/ssl/dovecot/mail.domain.com.key.pem]
(http://wiki2.dovecot.org/SSL/DovecotConfiguration)
in /etc/dovecot/conf.d/10-mail.conf :
mail_location = maildir:/var/vmail/%d/%n/Maildir:INDEX=/var/vmail/%d/%n/indexes mail_uid = vmail mail_gid = vmail first_valid_uid = [1001] last_valid_uid = [1001] first_valid_gid = [1001] last_valid_gid = [1001]
in /etc/dovecot/conf.d/10-master.conf :
unix_listener auth-userdb { mode = 0660 user = vmail group = vmail } unix_listener /var/spool/postfix/private/auth { mode = 0660 user = postfix group = postfix }
in /etc/dovecot/conf.d/15-mailboxes.conf:
namespace inbox { mailbox Trash { auto = subscribe special_use = \Trash } mailbox Drafts { auto = subscribe special_use = \Drafts } mailbox Sent { auto = subscribe # autocreate and autosubscribe the Sent mailbox special_use = \Sent } mailbox Junk { auto = subscribe # autocreate and autosubscribe Spam special_use = \Junk }
(http://wiki2.dovecot.org/MailboxSettings)
in /etc/dovecot/conf.d/20-imap.conf:
protocol imap { mail_plugins = quota imap_quota } protocol lda { postmaster_address = [Этот адрес электронной почты защищён от спам-ботов. У вас должен быть включен JavaScript для просмотра. ] mail_plugins = quota }
in /etc/dovecot/conf.d/90-plugin.conf :
plugin { quota = maildir:User quota }
in /etc/dovecot/conf.d/10-auth.conf :
auth_mechanisms = plain login cram-md5 digest-md5
in /etc/dovecot/dovecot-sql.conf :
driver = mysql connect = host=/var/run/mysqld/mysqld.sock user=[mailauth] password=[secret] dbname=[postfixadmin] default_pass_scheme = cram-md5 user_query = SELECT CONCAT('/var/vmail/', maildir) AS home, CONCAT('*:bytes=', quota) AS quota_rule FROM mailbox WHERE username = '%u' AND active = 1 password_query = SELECT CONCAT('/var/vmail/', maildir) AS userdb_home, username as user, password, CONCAT('*:bytes=', quota) AS userdb_quota_rule FROM mailbox WHERE username = '%u' AND active = 1
webapp-config -I -h localhost -d roundcube roundcube 0.9.5
webapp-config -I -h localhost -d postfixadmin postfixadmin 2.3.6
postfixadmin/config.inc.php :
$CONF['configured'] = true; $CONF['database_type'] = 'mysqli'; $CONF['database_host'] = '[localhost]'; $CONF['database_user'] = '[postfixadmin]'; $CONF['database_password'] = '[secret]'; $CONF['database_name'] = '[postfixadmin]'; $CONF['database_prefix'] = ''; $CONF['setup_password'] = '[paste here your hashed password]'; $CONF['postfix_admin_url'] = '[https://postfixadmin.domain.com]'; $CONF['admin_email'] = '[Этот адрес электронной почты защищён от спам-ботов. У вас должен быть включен JavaScript для просмотра. ]'; $CONF['dovecotpw'] = "/usr/bin/doveadm pw"; $CONF['domain_path'] = 'YES'; $CONF['domain_in_mailbox'] = 'NO'; $CONF['quota'] = 'YES'; $CONF['used_quotas'] = 'YES'; $CONF['new_quota_table'] = 'YES';
/etc/init.d/postfix start
/etc/init.d/dovecot start
rc-update add postfix default
rc-update add dovecot default
UPD 270814 : roundcube и amvisd будут добавлены позже :-)