Static IP for Asterisk computer

I am newbie, and I do not have any other “Servers” running on my system, and not versed in Linux, so if someone can help me out with a step by step, that would be great.

I know my Asterisk/FreePBX is getting an IP address from my router. I can see it in the router DHCP server list. I connect to it fine, it is at

This is great since I programmed my Cisco SPA942 phones and use that IP. All is great.

However, I do know that if I lose power or the router is retarted, it may dish out a different IP to Asterisk/FreePBX. I know for sure because I restarted the router, and had to change all the phones (extensions) once (restarted Asterisk afterwards also).

Can someone point me to how to make my IP address static on the Asterisk/Linux computer? I do not see any interface on FreePBX that will allow me to change the IP from dynamic (DHCP) to static.

I do not know Linux so a step by step would be mist helpful. I have looked and searched and cannot find this int he user group or in the help.

Thank you. I am sure I cannot be the only one that is stumped by this.

You need to modify the file /etc/sysconfig/network-scripts/ifcfg-ethN and restart the network service. To do so, perform following steps at the local console (you will loose connection to the server if you do it remotely via SSH):

  1. login as a root
  2. cd /etc/sysconfig/network-scripts
  3. Open the file ifcgf-eth0 (or ifcgf-eth1 if you use the second card etc) using your favorite editor. For example vi, or nano.
  4. Modify the file , replacing BOOTPROTO=dhcp with BOOTPROTO=none, and adding :
    obviously, replace the ip numbers with yours.
  5. save the changes
  6. restart network service: service network restart

Thank you.

You did have one mistake and that is the file name

It should be: ifcfg-eth0

For those that are not well versed in Linux, a step by step is as follows:

go to the local machine (computer running FreePBX/Asterisk)
login as: root
Password: (your password you used when you setup the software)
Type the next lines
cd /etc/sysconfig/network-scripts
sudo nano ifcfg-eth0
hit return
(use your arrow key to get where you need. Make sure NUMLOCK is on)
navigate to the line with BOOTPRONTO and go to the end of the line
Using backspace delete "dhcp"
Type in "none"
hit return
type the following lines;
IPADDR= (replace this with the IP address you want)
GATEWAY= (replace this with your router gateway address)
leave the rest as it is.
Hit the ctcl+ O keys (the letter not the number zero)
Hit enter again to save the file
hit ctcl+Z to exit the text editor
at the command prompt type the next line
service network restart

you should see the network card shut down and then restart, and all should be fine from here.

Thank you to Igordiv for his posting.

Its PSTN link from Tata… No router in the middle… The link directly lands on Xorcom PBX and from there i connect to a switch (nothing configured in the switch). From the switch i connected all the snom phones through path pannel… Presently the PBX and phones are working fine… but whenever i change the IP then its not working. Please help me.



I want to change the IP of my PBX to defferent subnet. So i logged in through elastix and changed the IP. After that i changed the IP of my phones and configured the extension to it and tried to make call… i am able to call… the call is connecting…but the other person is not able to hear my voice… at the same time i can hear the other person voice.

I observed that incoming calls are also not coming to extension and i am not able to call the other extensions(internal) also… plz help me out changing the IP of PBX… plz let me know if u need any details…

Thanks in advance.


I’m not an expert on this, but I am pretty sure that your router and connection to the internet must be on the same subnet as the Asterisk server. Mostly, I think, it is best to leave it at and use the IP address range 192.168.1.x.

If your router is not on the same subnet, the ports will not forward to your Asterisk server.

For what possible reason would you want to have two subnets? From what I read, this causes issues in your entire data stream. If it has to do with bandwidth, buy a decent router…! Even a $50 router you should be able to get a gigabit 8 port for that with the ability to assign priority to the VoIP

Oops… type on the gateway :slight_smile: Thanks

you setup the ip address and/or gateway incorrectly. They now belong to different subnet. By definition gateway must be in the same subnet as the host.

I also suggest making the router assign the server a static IP.

Hi did this but then my IP Trunk registrations did not come up.

My file looks like

Accton Technology Corporation SMC2-1211TX




sorry to bring up an old thread. But I am researching how to assign static IP because I now have a backup standby machine. I was hoping to easily unplug ethernet cord on 1st machine (if it fails), plug in backup machine, reboot router and machine and have everyone talking to each other.

What would be wrong with leaving the freepbx machine on DCHP? and ONLY using router to assign the static IP?

only thing that is a little sloppy is the name that pops up “new-host-3”, etc.

Hi Drrehak, there is nothing wrong with using DHCP. Just keep in mind that your DHCP server (your router) may assign a different IP to the backup machine. In this case you would have to adjust all your SIP peers (phones etc) with the new IP of your new SIP server.

Using DHCP for any mission critical linux server is very bad advice, please don’t take it.

If you want to add an unused address to a working machine

ip addr add 192.168.1.nn/24 dev ethn

for example, will so do so. It is the rudimentary method of how all real HA (high availability) systems work (and I think that is what you are looking for), but there are many other recipes out there, from the banal to the exquisite, many free but Schmooze will sell you one for a few bucks.