You have already heard that making calls between two different geographical places in VoIP network might encounter different problems. So there would be no connection between UAs. There are some solutions like VPN, Tunnel and so on. Here another solution is explained which is more secure and convinient.
Most VoIP protocols like SIP and IAX2 are among Application layer protocols and UDP or TCP is used to tranfer data. IAX2 uses only UDP so with some modifications we will get a good result.
IAX2 protocol and PortScrambling Techniqe is used to ease the process.
Consider this topology:
As you can see Asterisk servers are not connected directly but they are connected through a PS service.
Now we need to code the PS service. The codes are simple and consider that if you need other configurations you have to modify it. The code is Python.
Creat a new file and name it “ps.py”, then add these codes:
host = ‘Local-IP’;
port = 65432;
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
print ‘Failed to create socket’
receive data from client (data, addr)
data, addr = sock.recvfrom(1024)
if (addr == “Local-IP”):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
elif(addr == “Remote-IP”):
print str(addr) + “:” + str(addr)
except socket.error, msg:
print 'Error Code : ’ + str(msg) + ’ Message ’ + msg
Instead of “Remote-IP” and “Local-IP” add your server IPs. You need to creat this file on both servers and run it.
Now we need to have an IAX-Trunk on each server on PS service with any possible port, in our example 654321:
port = 65432
Now run the PS service: python ps.py &
Then restart IAX madoul. If you command “iax show peers” yo’ll see that IAX-Trunk in registered on PS service. This way you can make calls easily without any call lost.
Bear in mind that in this method both servers must have static IP.