header

Apache with dynamic IP



I was setting up a FreeBSD system to use Apache, and I was running into some problems getting it to start normally. I had the following in my /etc/rc.conf file:

hostname="grtest.domain.name.com"
ifconfig_em0="DHCP"
...

and in my /etc/hosts file:

::1 localhost
127.0.0.1 localhost

I was getting assigned a good IP, but when I would attempt to start Apache, I would get an error message similar to

[Thu Aug 18 11:05:11] [alert] httpd: Could not determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName

What I had to do to fix the issue was to add a private IP for my NIC. I did this via the FreeBSD Diary’s instructions, which involved:

  1. Adding the following line to /etc/hosts:
    192.168.0.1 grtest grtest.domain.name.com
  2. Adding line to /etc/rc.conf to add IP automatically to NIC on boot:
    ifconfig_em0_alias="inet 192.168.0.1 netmask 0xffffffff"
  3. Add IP to NIC via the command:
    ifconfig em0 alias 192.168.0.1 netmask 0xffffffff
  4. Restart apache, noting no longer an error:
    /usr/local/etc/rc.d/apache2.sh restart

Now it will still give me a public IP from the DHCP, but now works so that Apache will start correctly.

I was having a similar problem on a Gentoo Linux system before I scrapped it, so a similar solution would probably have fixed that issue as well.



2 Comments »

  1. gravatar

    Rafael Said,

    January 3, 2006 @ 9:33 am

    Very good! It worked!

  2. gravatar

    Teh Blarg » Red Hat Enterprise Linux (RHEL) 4 ifconfig adding an alias Said,

    June 12, 2007 @ 8:27 am

    [...] Ubuntu is not for me.Apache with dynamic IPGentoo LinuxSpyware Removal ApplicationsMaxtor Hard Drive, [...]

RSS feed for comments on this post · TrackBack URI

Leave a Comment

blogtimes