Архив рубрики: Публикации

MikroTik VLAN and Bridge Configuration

VLAN and Bridge are two useful features in MikroTik Router.  These two features are frequently used in any MikroTik network configuration. VLAN divides a physical interface into multiple logical interfaces. So, you can isolate your network into multiple logical networks on a physical interface. On other hand, MikroTik Bridge integrates multiple physical interfaces in a logical interface. So, you can extend your broadcast domain on multiple physical interfaces and can extend your popular services such as PPPoE or DHCP on multiple physical interfaces. As VLAN and Bridge are useful to any MikroTik network, this article is designed to show the necessary steps to configure VLAN and Bridge in MikroTik Router.




VLAN in MikroTik




VLAN (Virtual Local Area Network) is used to create multiple virtual LANs on a single physical interface. It is a layer 2 method that divides a single broadcast domain into multiple broadcast domains. So, proper VLAN planning can increase your network performance as well as network privacy.




There are various situations when you need to create VLAN in your MikroTik router. For example, if your ISP provides your WAN connection through a VLAN, you have to create a VLAN on your WAN interface or if you need to isolate your VIP users from other network users for any security purpose, VALN will be a better solution to isolate your physical network into multiple logical networks.




MikroTik VLAN Network
MikroTik VLAN Network




How to Create VLAN in MikroTik




VLAN can easily be created in MikroTik router like other network devices. Following steps will show you how to create VLAN in your MikroTik Router.






  • Login to your MikroTik Router by winbox with your login credentials.
  • Click on Interfaces menu from left menu bar and then click on VLAN tab.
  • Click on PLUS SIGN (+) to add new VLAN interface. A new window named New Interface will appear.
  • Put your VLAN name what you wish in Name input field.
  • Put your VLAN id in VLAN ID input field. If you want to create VLAN for WAN connection, your ISP will provide you the VLAN ID. If you want to create VLAN for your network, provide an integer number between 1 to 4095 what you wish.
  • Now choose your physical interface on which you want to create VLAN from Interface dropdown menu.
  • Click Apply and OK button.




A new VLAN interface has been created. Similarly, you can create as many VLANs as you want following the above steps.




Your newly created VLAN interface will behave like a physical interface. So, you can assign an IP on this VLAN interface as well as you can use this interface for routing. You will find your newly created VLAN interface all the places where there is an option to select interface such as assigning IP address on an interface, selecting your network gateway interface and so on.




If you wish to create VLAN for your local network, you have to configure a manageable switch. Follow my article about MikroTik VLAN routing configuration with manageable switch. It will show how to configure inter-VLAN routing with MikroTik Router and manageable switch.




MikroTik Bridge




Every port in MikroTik Router is a layer 3 port by default and its keep in different broadcast domain. So, if you create a PPPoE server or a DHCP server on any interface, the service cannot be accessible from any other interfaces and other interfaces keep unused sometimes. If you want to use these unused interfaces and want to access your DHCP or PPPoE server from all the interfaces, you have to turn your layer 3 ports to layer 2 ports and bind them to a layer 3 logical port. MikroTik bridge feature has come for this purpose.




MikroTik Bridge turns layer 3 ports to layer 2 ports and bind them with a logical layer 3 port. So, all the bridge ports as well as the logical layer 3 port keep in the same broadcast domain. Now it is possible to access any service like PPPoE or DHCP from any bridged MikroTik port.




How to Create Bridge in MikroTik Router




There are two major steps to create Bridge in MikroTik Router. First step is creating a logical bridge interface and second step is binding your desired physical interface to this logical interface. Following steps will show you the complete bridge configuration in MikroTik Router.




  • Login to your MikroTik Router by winbox with your login credentials.
  • Click on Bridge menu item from left menu bar. Bridge window will appear now.
  • Click on Bridge tab if not selected and then click on PLUS SIGN (+). New Interface window will appear.
  • Put your bridge interface name as you wish in the Name
  • Click Apply and OK
  • Now click on Ports tab and then click on PLUS SIGN (+). New Bridge Port window will appear.
  • Choose your physical interface that you want to bind to the bridge interface from Interface dropdown menu.
  • Choose your Bridge interface that you created before from Bridge dropdown menu.
  • Click Apply and OK
  • Do step 6 to step 9 if you want to add more physical interfaces to your bridge interface.




Creating logical bridge interface and binding physical interfaces to this bridge interface have been completed. Now any service that is created on bridge interface will be accessible from your bound physical interfaces easily.




If you face any problem to do above steps properly, watch below video carefully about MikroTik VLAN and Bridge Configuration. I hope it will help you to do the above steps successfully.


Honeypot. Инструменты, тактика и мотивы хакеров. Знай своего врага.

Олдовая книжка, но пусть будет!

Описание

Вы когда-нибудь задумывались над тем, какие мотивы движут компьютерными взломщиками, когда они атакуют, взламывают и используют в своих целях системы?

Задача этой книги состоит в том, чтобы рассказать о сообществе взломщиков, их мотивах и о том, как они взламывают системы и что делают в атакованной системе после успешного взлома. Читать

Asterisk. Соединение абонента с тем же оператором, при обрыве связи

Задача

Имеется небольшой call-центр. Все входящие звонки с разных линий и номеров сначала поступают на сервер Asterisk (FreeBSD+Asterisk 11.14.1), а он в свою очередь распределяет эти звонки между всеми операторами по определенному сценарию (queues).

При звонке, клиент сначала прослушивает голосовое приветствие, потом его сервер соединяет со свободным оператором, и начинается общение. Но часто бывает, что при плохой связи – звонок обрывает. Клиенту приходится заново перезванивать, слушать опять голосовое приветствие (которое порой может длиться до полуминуты), и попадает на оператора… на другого оператора. Приходится заново  рассказывать о своей проблеме другому оператору и решать все по новой. Порой “качество” связи (мобильной) может упасть на столько, что приходится перезванивать по 5-10 раз !!!

Поэтому было решено сделать так, что бы при обрыве, при повторном звонке, от одного и того же клиента – звонок шел без очереди на того же оператора, без голосовых приветсвий и т.д.

Решение

Решение оказалось довольно простым.

Будем использовать существующую базу Asterisk’а – CDRВ этой базе хранятся все записи и входящих и исходящих звонках нашего телефонного сервера.

Открываем файл /etc/asterisk/extensions.conf и правим нужный нам входящий канал. Добавляем такой блок:

 exten => 100,1,MYSQL(Connect connid IP_MYSQL ЛОГИН_MYSQL ПАРОЛЬ_MYSQL БАЗА_MYSQL)

 exten => 100,n,MYSQL(Query resultid ${connid} select dstchannel from cdr where clid like '%${CDR(src)}' and calldate like '${STRF TIME(${EPOCH},,%Y-%m-%d %H)}%')

 exten => 100,n,MYSQL(Fetch fetchid ${resultid} operator)

 exten => 100,n,GotoIf($["${operator}" = ""]?8:5)

 exten => 100,n,MYSQL(Clear ${resultid})

 exten => 100,n,MYSQL(Disconnect ${connid})

 exten => 100,n,Dial(SIP/${operator:-12:3},20,tT)

 exten => 100,n,Background(hello)

 exten => 100,n,Queue(support)

Что мы делаем

При входящем звонке, соединяемся с базой, делаем запрос, на поиск в таблице cdr в поле clid  по номеру водящего звонка (переменная %${CDR(src)} ) и время укажем последний текущий час (переменная ${STRF TIME(${EPOCH},,%Y-%m-%d %H)}%) в поле calldate.  Если звонок “новый” и еще не звонил в течении часа, то запрос вернет пустое значение в переменную operator, и звонок перекинется на проигрывание приветствия, и звонок поступит в очередь операторов, где на него ответит свободный оператор.

Пример cmd asterisk:

 -- Executing [100@local-phones:1] MYSQL("SIP/INPUT_MTS-0000006c", "Connect connid localhost aster password asterisk") in new stack

 -- Executing [100@local-phones:2] MYSQL("SIP/INPUT_MTS-0000006c", "Query resultid 3 select dstchannel from cdr where clid like '%099xxxxxxx' and calldate like '2017-09-06 09%'") in new stack

 -- Executing [100@local-phones:3] MYSQL("SIP/INPUT_MTS-0000006c", "Fetch fetchid 4 operator") in new stack

 -- Executing [100@local-phones:4] GotoIf("SIP/INPUT_MTS-0000006c", "1?8:5") in new stack

 -- Goto (local-phones,100,8)

 -- Executing [100@local-phones:8] BackGround("SIP/INPUT_MTS-0000006c", "hello") in new stack

 -- <INPUT_MTS-0000006c> Playing 'hello.slin' (language 'ru')

 -- Executing [100@local-phones:9] Queue("SIP/INPUT_MTS-0000006c", "support") in new stack

 -- Started music on hold, class 'default', on SIP/INPUT_MTS-0000006c

 == Using SIP RTP CoS mark 5

 -- SIP/971-0000006d is ringing

 -- SIP/971-0000006d answered SIP/INPUT_MTS-0000006c

 -- Stopped music on hold on SIP/INPUT_MTS-0000006c


Если же, клиент уже звонил и в базе cdr уже существует запись о том, что он звонил. Тогда в переменную operator вернется значение – SIP- номер оператора, с кем он разговаривал, и звонок уже вне очереди поступит напрямую к тому же оператору.

 -- Executing [100@local-phones:1] MYSQL("SIP/INPUT_MTS-0000006a", "Connect connid localhost aster password asterisk") in new stack

 -- Executing [100@local-phones:2] MYSQL("SIP/INPUT_MTS-0000006a", "Query resultid 1 select dstchannel from cdr where clid like '%099xxxxxxx' and calldate like '2017-09-06 09%'") in new stack 

 -- Executing [100@local-phones:3] MYSQL("SIP/INPUT_MTS-0000006a", "Fetch fetchid 2 operator") in new stack

 -- Executing [100@local-phones:4] GotoIf("SIP/INPUT_MTS-0000006a", "0?8:5") in new stack

 -- Goto (local-phones,100,5)

 -- Executing [100@local-phones:5] MYSQL("SIP/INPUT_MTS-0000006a", "Clear 2") in new stack

 -- Executing [100@local-phones:6] MYSQL("SIP/INPUT_MTS-0000006a", "Disconnect 1") in new stack

 -- Executing [100@local-phones:7] Dial("SIP/INPUT_MTS-0000006a", "SIP/971,20,tT") in new stack



2017-09-06T10:41:35
Asterisk