Asterisk and E1 Gateway

can i connect Asterisk server at location (A) to VOIP E1 gateway (like Cisco or others) in location (B) through the internet ? the gateway is connected to E1 line and to the internet with static ip address. can they both be connected and the gateway be defined as a trunk? also how can i use H.323 in this situation?
Thanks

Sure you can. Depending on the gateway, you might also be able to use a low-bitrate codec like GSM or G.729 to reduce the bandwidth usage. If not, you could put another * box in front of it to handle the encoding.

As for H.323, you could use it to connect the gateway to asterisk. However, I’d recommend using SIP or IAX instead if possible. If you put * machines on each end and use them with IAX trunk mode, you save a bunch of bandwidth on headers that aren’t duplicated for every single call.

Thank you for the information, so i guess it is better to just install 1 server in each location and have them connected through IAX instead of getting seprate gateway, may be install Digium T1 interface on the remote server instead . but i have another question. if i have 1 T1 line connected to the remote * that means having a total of 24 channels, how many g729 codec license do i need , and do i need to buy license for each server. what is the best codec then to be used with IAX to interconnect both servers. we are not going to use any voice mail or music on hold, just an IVR for calling card , it is just a basic termination for the lines

A digium T1 card would probably be a better idea, unless the gateway you get can compress to different codecs. Asterisk+digium card will be more flexible as you expand or grow in the future though.

for reference- PRI -> server1 -> internet (iax trunk -> server2 -> your phones

You will need either 24 or 48 licenses. You will absolutely need 24 for server1. If the other end (server2) has IP phones which support G.729, then server2 doesn’t need any licenses, it will just pass through the 729 data w/out messing with it.
Bottom line- if the server can pass through the data, you dont need one. If it has to generate data or listen to it, you need one.

Since you said you are running a calling card system, you will probably need 48 licenses (one on the PRI side to encode, the other on the office IVR side to decode).
This makes me ask- why bother with an IAX trunk at all? Why not just load the calling card application on the PRI-side Asterisk box, and have it access a remote SQL database? Setup a VPN connection between it and your central database server for security, then have the calling card application local on the PRI system. This will reduce your bandwidth usage exponentially.

I’m sorry i didn’t clearfy the expected setup, it sould look like this
PRI -> server1 -> internet (iax trunk -> server2 ->PRI ->customer.
so the calling card application on the server 2 side, when the customer dial to server 2 from a regular or cellular phone and get autenticated then the call travel through server1 and terminated at the called party on a regular PSTN line. there is no IP phones or extensions at all. do i still need to buy license or simply use pass through g729?

probably. If the calling card application is running on top of Asterisk, then yes you do. If the calling card application is its own system and that system supports G.729, then you don’t.

Also look into iLBC and GSM codecs, they are similar to G.729 but do not have license issues.