понедельник, 2 декабря 2013 г.

Mikrotik wifi hotspot

В продолжение Mikrotik public wifi натгиваем hotspot

1) #  ip hotspot setup
hotspot interface: pub
local address of network: 192.168.22.1/24
masquerade network: yes
address pool of network: 192.168.22.2-192.168.22.254
select certificate: none
ip address of smtp server: 0.0.0.0
dns servers: 8.8.8.8
dns name:
name of local hotspot user: admin
password for the user: 

быстрая настройка на интерфейс pub. smtp можете указать как и dns name, а вот пароль на юзверя задавать не над.


2) # ip hotspot profile set hsprof1 hotspot-address=192.169.22.1 login-by=http-chap,trial trial-uptime=30m/3h trial-user-profile=default 
изменяем профиль на триал. время доступа 30 мин. после чего в бан на 3 часа.
 
3) # ip hotspot user profile set default keepalive-timeout=1h shared-users=unlimited add-mac-cookie=no rate-limit="512k/512k"
лимит на 1 юзера 512 Kb Rx/Tx


4) # file remove hotspot/login.html
    # file remove hotspot/alogin.html
    # file remove hotspot/status.html
удаляем лишнее.
вместо  login.html вставляем свою html с сылками.

ссылки выдераются из login.html
$(link-login-only)?dst=$(link-orig-esc)&username=T-$(mac-esc)
прямая в инет
$(link-login-only)?dst=http://kyyct.blogspot.ru/&username=T-$(mac-esc)
редирект на сайт


Mikrotik public wifi



1) # interface wireless security-profiles add name=pub mode=none
создаем публичный профиль

2) # interface wireless add name="pub" mtu=1500 arp=enabled master-interface=wlan1 ssid="free" bridge-mode=enabled security-profile=pub
поднимаем виртуальный wi-fi интерфей поверх реального wlan1

3) # ip address add address=192.168.22.1/24 interface=pub
 назначаем гейт в "левом" диапазоне

4) # ip dhcp-server setup
dhcp server interface: pub
dhcp address space: 192.168.22.0/24
gateway for dhcp network: 192.168.22.1
addresses to give out: 192.168.22.2-192.168.22.254
dns servers: 4.4.4.4,8.8.8.8
наскоро конфигурим dhcp
сегментированная сеть 192.168.22.0/24
днс можно оставить провайдера.

5) Будете выставлять в продакшн прикройте файром все что можно.
базовые правила:
# ip firewall filter add chain=forward action=jump jump-target=customer in-interface=ether1-gateway
# ip firewall filter add chain=customer action=accept connection-state=established 
# ip firewall filter add chain=customer action=accept connection-state=related 
# ip firewall filter add chain=customer action=drop

понедельник, 2 сентября 2013 г.

fail2ban + Asterisk + Debian

1) # apt-get install fail2ban iptables python
2) # cd /etc/fail2ban/filter.d/
тут фильтры. (ололо)
3) # vim asterisk.conf
[INCLUDES]
failregex = NOTICE.* .*: Registration from '.*' failed for '<HOST>:.*' - Wrong password
            NOTICE.* .*: Registration from '.*' failed for '<HOST>:.*' - No matching peer found
            NOTICE.* .*: Registration from '.*' failed for '<HOST>:.*' - No matching peer found
            NOTICE.* .*: Registration from '.*' failed for '<HOST>:.*' - Username/auth name mismatch
            NOTICE.* .*: Registration from '.*' failed for '<HOST>:.*' - Device does not match ACL
            NOTICE.* .*: Registration from '.*' failed for '<HOST>:.*' - Peer is not supposed to register
            NOTICE.* .*: Registration from '.*' failed for '<HOST>:.*' - ACL error (permit/deny)
            NOTICE.* .*: Registration from '.*' failed for '<HOST>:.*' - Device does not match ACL
            NOTICE.* .*: Registration from '\".*\".*' failed for '<HOST>:.*' - No matching peer found
            NOTICE.* .*: Registration from '\".*\".*' failed for '<HOST>:.*' - Wrong password
            NOTICE.* <HOST> failed to authenticate as '.*'$
            NOTICE.* .*: No registration for peer '.*' \(from <HOST>\)
            NOTICE.* .*: Host <HOST> failed MD5 authentication for '.*' (.*)
            NOTICE.* .*: Failed to authenticate user .*@<HOST>.*
            NOTICE.* .*: <HOST> failed to authenticate as '.*'
            NOTICE.* .*: <HOST> tried  to authenticate with nonexistent user '.*'
            VERBOSE.*SIP/<HOST>-.*Received incoming SIP connection from unknown peer

ignoreregex =
4) # vim /etc/fail2ban/jail.conf
дописать в конфиг параметры очевидны.

# from asterisk
[asterisk-iptables]
enabled  = true
filter   = asterisk
action   = iptables-allports[name=ASTERISK, protocol=all]
sendmail-whois[name=ASTERISK, dest=root, sender=root@kyct.ru]
logpath  = /home/asterisk/ap/log/messages
maxretry = 6
bantime = 259200
5) # vim /home/asterisk/ap/etc/logger.conf
 дописать в конфиг

[general]
dateformat=%F %T

6) Перезапускаем проверяем. 
# iptables -L -v
 

понедельник, 26 августа 2013 г.

proxmox usb port to kvm

root@proxmox:~# lsusb -t
1-1.4:1.0: No such file or directory
/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M
    |__ Port 1: Dev 2, If 0, Class=HID, Driver=usbhid, 12M
    |__ Port 1: Dev 2, If 1, Class=HID, Driver=usbhid, 12M
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci_hcd/2p, 480M
    |__ Port 1: Dev 2, If 0, Class=hub, Driver=hub/6p, 480M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci_hcd/2p, 480M
    |__ Port 1: Dev 2, If 0, Class=hub, Driver=hub/6p, 480M
        |__ Port 4: Dev 3, If 0, Class=vend., Driver=, 12M
        |__ Port 5: Dev 5, If 0, Class=vend., Driver=usbfs, 1.5M
        |__ Port 6: Dev 6, If 0, Class=vend., Driver=usbfs, 1.5M



vim /etc/pve/qemu-server/100.conf
add
usb0: host=1-1.6

openvz mount host directory

Example

 :~# cat > /etc/vz/conf/113.mount
  #!/bin/bash
. /etc/vz/vz.conf
. /etc/vz/conf/113.conf
SRC=/home/kyct/host
DST=/home/kyct/virt
VE_ROOT=/vz/root/113
if [ ! -e ${VE_ROOT}$DST} ]; then mkdir -p ${VE_ROOT}${DST}; fi
mount -n -t simfs ${SRC} ${VE_ROOT}${DST} -o ${SRC}
 
:~# chmod 755 /etc/vz/conf/113.mount

для рачков:

vz - 113
SRC - папка на хост машине
DST - папка в гостевой машине

воскресенье, 14 апреля 2013 г.

proxmox bridge interfaces


proxmox-main:~# cat /etc/network/interfaces

# network interface settings
auto lo
iface lo inet loopback

# dns-* options are implemented by the resolvconf package, if installed
iface eth1 inet manual
iface eth0 inet manual
# eth0 кабель с локалкой
# eth1 ненужен

auto vmbr0
iface vmbr0 inet static
        address 192.168.1.10
        netmask 255.255.255.0
        gateway 192.168.1.1
        dns-nameserver 192.168.1.1
        bridge_ports eth0
        bridge_stp off
        bridge_fd 0

ставим proxmox

1) apt-get install vim 
2) vim /etc/hosts 
#ставим ip компа (без этого ошибки при установки)
3) vim /etc/apt/sources.list

# 

# deb cdrom:[Debian GNU/Linux 6.0.6 _Squeeze_ - Official amd64 NETINST Binary-1 20120930-15:53]/ squeeze main

#deb cdrom:[Debian GNU/Linux 6.0.6 _Squeeze_ - Official amd64 NETINST Binary-1 20120930-15:53]/ squeeze main

deb http://ftp.at.debian.org/debian squeeze main contrib

# PVE packages provided by proxmox.com
deb http://download.proxmox.com/debian squeeze pve

# security updates
deb http://security.debian.org/ squeeze/updates main contrib

4)

wget -O- "http://download.proxmox.com/debian/key.asc" | apt-key add -

5) aptitude update
6) aptitude upgrade
7) aptitude install pve-kernel-2.6.32-19-pve
#актуальность версии http://download.proxmox.com/debian/dists/squeeze/pve/binary-amd64/
8) reboot
9) uname -a 
#проверяем ядро 2.6.32-19-pve 
10) aptitude install pve-headers-2.6.32-19-pve proxmox-ve-2.6.32 ntp ssh lvm2 postfix ksm-control-daemon vzprocps
11) a2ensite pve-redirect.conf
12) /etc/init.d/apache2 restart