Monday, June 8, 2020

Asterisk "Re-transmission timeout" errors

To avoid Re-transmission timeout errors on public sip trunks:
  1. on the firewall forward udp ports 5060, 10001-20000 to the internal ip address of your pbx
  2. on the firewall turn off any sip alg or sip transformations in the firewall
  3. either disable or set firewall udp timers to 3 minutes or more
  4. make sure your pbx has a static ip address and in the freepbx sip settings set NAT to yes
  5. turn on NAT on in your firewall
  6. if you have a static public ip address use it with your sip provider instead of registration

Asterisk AMI & AstDB (initial steps + Python connect)

First time AMI setup

vi /etc/asterisk/manager.conf minimal configuration required:
[general]
enabled = yes ;AMI
webenabled = no ;AJAM
httptimeout=120
port = 5038
bindaddr = 0.0.0.0
tlsenable=no
[admin]
secret=My$ecr3t
read=all
write=all

Test over telnet:

Wait till connected:
telnet 127.0.0.1 5038

Send below commands:
Action: Login
Username: admin
Secret: My$ecr3t
Events: off

"Enter" twice to get:
Response: Success
Message: Authentication accepted

To logoff:
Action: logoff

AstDB

To view needed permissions:
CLI> manager show commands

To write into astdb:
Action: DBPut
Family: TEST
Key: WhatEverYouWant

DBDel and DBGet are working in the same manner as DBPut above.

Python to AstDB connect

import sqlite3 # it's standard library

Learn name of the table and its structure:
connector = sqlite3.connect("/var/lib/asterisk/astdb.sqlite3")
cursor = connector.cursor()
cursor.execute("select sql from sqlite_master where type = 'table'")
print(cursor.fetchall())

cursor.close()
con.close()

VMware vCD (vCloud Director) first steps


vCloud Director — platform for managing virtual infrastructure in IaaS. 
Main notions are:
  1. Virtual datacenter (VDC) — pool of resources (CPU, RAM, HDD). This is environment where you will create virtual machines (VM), containers (vApp), networks
  2. vApp – is a container and VM placed inside vApp. vApp gives ability to group VMs. This grouping can be based on VMs purpose (mail servers, accounting etc.). vApp helps to manage this groups. Also you can use vApp templates. It's helpful when you have many VMs of the same functionalities
  3. Virtual machines (VM) — in vCloud Director you can create VM from the template or install from needed OS ISO
  4. Catalogs – thees are directories where you can store templates (vApp, VM, ISO) 
  5. Org VDC Networks – this is networks of your virtual Data Center. This networks are  accessible for all vApp and VM. Network can be isolated (without Internet access) and routed (with Internet access)
  6. vApp network - this network works only inside selected vApp and by default this network will not be accessible by VMs from other vApp.
There are two types of vCD GUI - with Adobe Flash and without of using Flash. We'll use GUI without Flash and vCD version 9.7

Adding organizational VDC network

Click on the name of needed data center. In "Networking" section select "Networks", then "ADD":
  1. Select isolated or routed network:
    1. To add routed network you must have "Edge connection" - VMware Edge gateway used to connect your VDC to the external world. Besides that all settings are identical for both isolated and routed networks
  2. Specify descriptive name for that network
  3. Specify IP address of a gateway for that network in CIDR (ex.:10.10.10.1/24)
  4. Share - if want to share this network with other VDC in your organisation
  5. Add static pools if needed (this addresses will be automatically assigned to the VMs connected to that network)
  6. Add DNS to be assigned for VM's in that network (ex.: 8.8.8.8 and 8.8.4.4)
  7. Click "FINISH"
  8. If you get : "VDC does not have any network pool associated with it." error, then your couldn't add a network
If you have Edge gateway, then you can setup DNAT / SNAT / DHCP / Firewall / VPN / Load Balancer of that gateway. Some cloud providers use dedicated VM as gateway and doesn't add any Edge gateway to the VDC. 

Adding vApp and VM

In vCD addition of VM begins from vApp addition:
  1. Add vApp from template (with installed OS)
  2. Add vApp with empty VM
  3. Add empty vApp and add VM later
Click on the name of needed data center. In "Compute" section select "vApps", then "NEW VAPP":
  1. Specify name of the vApp
  2. Click "CREATE" (to add empty vApp) or "ADD VIRTUAL MACHINE"
  3. Select needed template or create custom image
  4. Go through all suggested steps
To customize VM hardware or any other allowed parameters (VM must be powered off in order to change parameters):
  1. Compute > Virtual Machines
  2. Select VM added in vApp (or setup new VM if empty vApp addedd)
  3. Click on VM name
  4. Change all needed parameters
  5. Most used VM network types:
    1. e1000 - emulated Intel 82545EM Gigabit Ethernet, supported by most OS
    2. VMXNET family - VMware Tools must be installed in order to use this type:
      1. VMXNET first version
      2. VMXNET2 - adds Jumbo Frames and other enhancements
      3. VMXNET3 - virtualized NIC 10Gb, more stable than e1000 and uses less CPU resources
  6. Click "SAVE"
To add previously added VM to needed vApp:
  1. Compute > Virtual Machines
  2. Left click on 3 dots on the left of needed VM name
  3. Move to...
  4. Select needed vApp
  5. Select storage-policy and network
  6. "Done"
To change template's default password:
  1. Compute > Virtual Machines
  2. Click on VM name
  3. Guest OS Customization
  4. Check-box below:
    1. Enable guest customization
    2. Allow local administrator password 
    3. Require Administrator to change password on first login
  5. Uncheck-box:
    1. Auto generate password
    2. Change SID
  6. Specify password at the "Specify password"
  7. "SAVE"
Connecting to VM:
  1. Compute > Virtual Machines
  2. Left click on 3 dots on the left of needed VM name
  3. If connecting after "guest customization":
    1. Power On and Force Recustomization
  4. Select "Launch VM Remote Console":
    1. In order to connect to VM, register on https://my.vmware.com/ and download VMRC (VMware Remote Console)
    2. Ctrl + Alt to escape console screen