Howto setup Asterisk/FreePBX behind NAT

Asterisk, Weekly Tips March 10th, 2010

This HOWTO assumes that your FreePBX system is sitting behind a NATed firewall with no direct connection to the outside world and it is NOT in the DMZ zone. If you have your system facing outside, or have used Mapped IP addresses or other techniques, then it is assumed that you have adequate knowledge to interpret these instructions and also assure that you have properly secured your installation.

The three key considerations in setting up remote extensions are:

  • Asterisk Knows what network is external vs. internal
  • All Signaling and Media ports are forwarded to Asterisk
  • The Extension/Device is setup to be NATed

In order to accomplish the above we need to apply some configuration information into FreePBX, some Asterisk configuration files and on your firewall/router.

Internal/External Network Information

You must edit or create the file sip_nat.conf typically found in your /etc/asterisk directory and make sure it is owned by asterisk. We will assume that you have an internal network of 192.168.1.0/255.255.255.0 and that you have a static IP address of 24.72.182.16. If you have a dynamic IP, see the notes that follow. In this situation, you need to create or edit the following entries in your sip_nat.conf file:

externip=24.72.182.16
localnet=192.168.1.0/255.255.255.0

This tells Asterisk what IP address range is internal vs. external so that it can rewrite the SIP headers appropriately. If you have a dynamic address instead of a static address then you need to modify the above. You will need to have a domain name for the host, let’s assume you are using dyndns.com’s free service and have chosen the name mydomain.dyndns.org. Then your sip_nat.conf file would look like the following:

externhost=mydomain.dyndns.org
externrefresh=120
localnet=192.168.1.0/255.255.255.0

Where externrefresh tells Asterisk to recheck the IP address every 120 seconds in this case. You should adjust this higher or lower based on the frequency that this changes.

Firewall/Router Configuration

The default installation of FreePBX is configured to use UDP port 5060 as the SIP signaling port and UDP ports 10001-20000 as the RTP Media ports. All these ports must be forwarded to your FreePBX System. How to do this varies widely depending on the firewall or equipment that you are using. It is commonly referred to as Port Forwarding or maybe Destination NAT (DNAT). However it is referred, if we assume in this example that your FreePBX system has an internal IP address of 192.168.1.100 then you will want:

  • UDP/5060 -> Forward to 192.168.1.100
  • UDP/10001-20000 -> Forward to 192.168.1.100

Extension Information

We will assume you are using FreePBX in Extension mode but if you are using Devices/Users the same applies on the Devices page. You need to configure the extension with NAT enabled so that Asterisk knows this device is NATed and can apply the SIP rewriting rules that you previously configured in the sip_nat.conf file. Navigate to the desired extension and scroll down to the Device Options Section.

The configuration option nat must be set to yes, and you may want to set qualify to yes as well although not necessary.

With these steps, when properly configured, your external device should be able to communicate with your FreePBX server unless you have issues on the remote end where the device is located because of badly behaved Firewalls. The remote device should be configured to use your external IP address or domain name as configured above in the sip_nat.conf file.

The Top 7 Best Linux Distributions for You

Linux, Weekly Tips February 4th, 2010

There are various approaches to answering this question. The broad answer is: “any of them,” but that’s not very helpful if you’re just looking for a place to start.

The problem is, there never can be one best Linux distribution for everyone, because the needs of each user tend to be unique. Telling someone who’s looking for a good introductory distribution to try Gentoo, for instance, would be a mistake because for all its positive qualities, Gentoo is decidedly not a beginner’s distro.

All too often, Linux aficionados will tend to list the distributions they like as the best, which is fair, but if they are not aware of their audience, they could suggest something that does not meet that person’s needs. Finding a good Linux distribution is like finding a good match in an online dating service: good looks aren’t the only quality upon which to judge a Linux distro.

To help users discover the Linux distribution that’s best for them, this resource will definitively list the best candidates for the various types of Linux users to try. The use-case categories will be:

  • Best Desktop Distribution
  • Best Laptop Distribution
  • Best Enterprise Desktop
  • Best Enterprise Server
  • Best LiveCD
  • Best Security-Enhanced Distribution
  • Best Multimedia Distribution

Once you find the best Linux distribution for your needs, you can visit our Linux Migration Guides to assist you in installing and using the one you’d like to try.

Best Linux Desktop Distribution

There are a lot of Linux distributions that have the primary focus of becoming the next best desktop replacement for Windows or OS X. Of all the categories in this list, this is the most sought-after, and contentious, group of distros.

While it would be ideal to include many distributions on this list, the reality is that there really needs to be just one “best” Linux distribution. For early 2010, that distro has to be Canonical’s Ubuntu.

Ubuntu edges out its closest contenders, Fedora and openSUSE, because its development team is constantly focused on the end-user experience. Canonical and the Ubuntu community have spent a lot of time and resources on bringing ease-of-use tools to this distribution, particularly in the area of installing Ubuntu and installing applications within Ubuntu.

In addition, Ubuntu’s level of support for its desktop products is highly superior, which is important in this class of distributions since it is the most likely to contain users new to Linux. Both the official and unofficial Ubuntu documentation is robust and searchable, a big plus.

Best Linux Laptop Distribution

Laptop distributions almost fall into the same category as desktop users, but there are a number of key differences that make the criteria for evaluating a good laptop distribution important. Power management, docking tools, and wireless ease-of-use are critical to users on the go, as is having a distro that meets those needs.

Right now, the best laptop distribution is openSUSE, one of the lead contenders for the desktop honors. On the laptop, openSUSE shines with great connectivity tools, such as an easy-to-use networking toolset that not only handles WiFi connectivity, but also CDMA/cellular modem connections.

openSUSE also deals with docking stations for laptops very well, including dual-monitor management on the fly. Power management is very granular, which is great for detailing various power needs you might find yourself needing.

Best Linux Enterprise Desktop

This category is replete with great contenders as well, and it’s difficult to highlight just one. At the end of the day, though, the nod must be given to SUSE Linux Enterprise Desktop (SLED).

The reason is simple: while SLED and its primary competitor Red Hat Enterprise Linux Desktop are nearly identical in features and support performance, SLED has the advantage of the openSUSE Build Service, a free and open service that lets applications be built and delivered to SUSE Linux and openSUSE products (as well as Red Hat and CentOS).

This is a very important differentiator in enterprise desktop development, as it means that SLED has the current advantage of application building and deployment in the enterprise arena.

Best Linux Enterprise Server

Again, in this category it really comes down to two main contenders: Red Hat Enterprise Linux (RHEL) and SUSE Linux Enterprise Server (SLES). Given the pick for the Enterprise Desktop category, you might expect SLES to get the “best of” label here.

But, when all factors for the enterprise server are weighed, RHEL is still the king of this particular hill.

Red Hat edges out Novell with its server product, because RHEL users get a deeply mature distribution, and Red Hat’s support structure is second to none in the enterprise channels.

Best Linux LiveCD

As Linux technology improves, users can easily choose the LiveCD version of practically any of the Linux distros listed here to get the best LiveCD experience for their needs.

There is a specialized class of LiveCDs, however, that offers users utilities and tools for the specific purpose of repairing existing Linux and Windows installations. These distros are very useful to have regardless of what primary Linux distribution you like to use, because in a crisis they are invaluable to own.

In this class of distribution, KNOPPIX is hands-down the most complete and useful distro. Loaded on a CD or USB storage device, KNOPPIX will let you recover from nearly any rare Linux system crash as well as the much-less-rare Windows breakdowns.

Best Linux Security-Enhanced Distribution

Linux is inherently very secure compared to other operating systems, but there’s always room for improvement.

One of the challenges for locking down Linux is if you are not careful, you can take away too much functionality. Another challenge is that the best security-oriented Linux distro, SELinux, is historically known to be difficult to configure correctly. Still, if security out of the box is your priority, this is the best place to begin.

Another approach is the white hat method: using security and forensic tools to examine your existing installation, determine the holes, then lock your system down based on what gaps you find. If you have the time and inclination, this is a great way to do it, because this will get any existing system more secure right away.

For the white hat approach, the best distribution is BackTrack Linux, a dedicated penetration testing distro that will enable you to safely try to crack any system you are caretaking. Its toolset and strong community give it the advantage in this category.

Best Linux Multimedia Distribution

General Linux distributions have come a long way in terms of multimedia performance. Rare is the audio or video file that can’t be played on Linux. Music services such as Rhapsody and video sites like YouTube and Hulu are also standards-compliant and accessible to Linux users.

Still, for those users who are multimedia creators as well as consumers, there are Linux distributions that contain powerful tools for audio and video editing.

The best in this class is currently Ubuntu Studio. For audio, video, and graphic production, it contains a very complete set of tools, as well as format and codec support for a huge range of multimedia formats.

The applications contained in Ubuntu Studio are the same or similar to those used by major studios to create cutting edge work, so users are getting the best apps, coupled with the strong support ethos already found in the Ubuntu community.

In Linux there are as many opinions as there are lines of code. This represents one view of the best in Linux. What’s yours?

About Author:

Brian Proffitt is a Linux and Open Source expert, having worked as a member of the Linux media as well as the Linux Foundation. My off-hour activities include Habitat for Humanity, taekwondo, and being the lucky dad of three fantastic daughters. Follow me on Twitter @LinuxScribe.

Flashblock throughs away Flash annoyance when surfing the Web

Weekly Tips December 19th, 2009

Never be annoyed by a Flash animation again! Blocks Flash so it won’t get in your way, but if you want to see it, just click on…

Flashblock is an extension for the Mozilla, Firefox, and Netscape browsers that takes a pessimistic approach to dealing with Macromedia Flash content on a webpage and blocks ALL Flash content from loading. It then leaves placeholders on the webpage that allow you to click to download and then view the Flash content.

Flashblock currently blocks the following content types:

  • Macromedia Flash
  • Macromedia Shockwave
  • Macromedia Authorware

Our public support forums can be accessed via:
our mailing list: http://www.mozdev.org/mailman/listinfo/flashblock
or newsgroup: news://news.mozdev.org/public.mozdev.flashblock

Lời người viết: Một trải nghiệm vô cùng lý thú. Chúng ta làm sao có thể có được những điều hết sức hữu ích thế này nếu không phải là với Mozilla Firefox và phần mềm tự do nguồn mở.

Hãy cài đặt ngay tại đây.

Fedora 12 installation/upgrade process

Linux, Weekly Tips November 20th, 2009

The installation/upgrade process for Fedora 12 is similar to Fedora 11: http://blog.iwayvietnam.com/tuanta/2009/08/13/fedora-11-installation-process/.

Fedora 12 local repositories in iWay LAN has been also ready. See /etc/yum.repos.d/local.repo below:

# Base packages inside iWay LAN
[base-local]
name=Fedora $releasever – $basearch – Base local
baseurl=http://dev.iwayvietnam.com/mirror/f12/
enabled=1
gpgcheck=0

# Update packages inside iWay LAN
[updates-local]
name=Fedora $releasever – $basearch – Updates local
baseurl=http://mirror.iwayvietnam.com:9090/yum/updates/$releasever/$basearch/
enabled=1
gpgcheck=0

# Additional packages at ATRPMS.net
[atrpms]
name=Fedora Core $releasever – $basearch – ATrpms
baseurl=http://dl.atrpms.net/f$releasever-$basearch/atrpms/stable
gpgkey=http://ATrpms.net/RPM-GPG-KEY.atrpms
gpgcheck=1
enabled=1

Have fun!

Install Chrome on Fedora Linux

Linux, Weekly Tips October 13th, 2009

You can install Chrome using the YUM package manager.

You have to first add a new repository file to the /etc/yum.repos.d directory, following steps:

  1. Open your favorite editor and enter the su command to gain root access.
  2. Create the /etc/yum.repos.d/chromium.repo file.
  3. Add the following contents to the file:
    [chromium]
    name=Chromium Test Packages
    baseurl=http://spot.fedorapeople.org/chromium/F$releasever/
    enabled=1
    gpgcheck=0
  4. Save the file.

Once yum has updated you are ready to install Chromium. Issue the following command:
yum install chromium
and answer ‘Y’ to install.

After the installation is complete you are ready to run Chromium. You will find Chromium listed in the Internet sub-menu of the Applications menu.