Results 1 to 10 of 10

Thread: Ubuntu hosts and hostname mystery

  1. #1
    Loves duck, Peking Duck! bsodmike's Avatar
    Join Date
    Jul 2003
    Location
    Colombo
    Posts
    2,909
    Thanks
    496
    Thanked
    92 times in 80 posts
    • bsodmike's system
      • Motherboard:
      • Misc.
      • CPU:
      • Mac Pro 2.8 GHz (8-cores) / iMac 2.8GHz C2D Extreme Edition / MacBook Pro 15" 2.33 & 13.3" 2.26 GHz
      • Memory:
      • 2GB DDR2 kits on all systems / FB ECC RAM in Mac Pro
      • Storage:
      • 320GB + 3x 1TB, Mac Pro / 500 GB, iMac / 2x 1TB & 2x 2TB WD My Book Studio II, via FW800 to Mac Pro
      • Graphics card(s):
      • ATI Radeon HD 2600 XT 256MB (two dual-link DVI ports / Mac Pro)
      • PSU:
      • Misc.
      • Case:
      • Misc.
      • Operating System:
      • Mac OS X 10.5 (Mac Pro) / Mac OS X 10.4.11 (others)
      • Monitor(s):
      • Apple 23" Cinema HD / Dell FPW2408 / iMac 24" display
      • Internet:
      • 2mbps ADSL (Mac Pro) / 512kbps WiMax (Wifi/MacBook Pro)

    Ubuntu hosts and hostname mystery

    Hi,

    I'm facing bit of a conundrum with my new server. It is essentially a distributed-virtual Plesk Virtuoso container with a rather simple LAMP setup (PHP5 etc) and virtual hosting.

    The issue is that on each reboot, the /etc/hosts and /etc/hostname files are reset with their original configs causing the virtual hosting to break, i.e. rather than hosting the vhosts correctly, it essentially routes all traffic to /var/www, or essentially 000-default ~ this beats the whole point of vhosting in the first place!

    Questions:
    1. Is there any way to set both files as no longer writable etc?
    2. How can I get around them being overwritten at boot?


    A very crude workaround would be to set a script to load at boot via init.d and have it rewrite both files to their correct configs - of course, I have no idea as to the point during boot at which they get replaced.

    I am running out of hair to pull at this point....

    Thanks in advance!
    Mike.
    Last edited by bsodmike; 13-07-2010 at 09:19 AM.

  2. #2
    PHP Geek Flash477's Avatar
    Join Date
    Dec 2008
    Location
    Devon
    Posts
    822
    Thanks
    51
    Thanked
    72 times in 65 posts

    Re: Ubuntu hosts and hostname mystery

    Look at /etc/sysconfig/network

  3. #3
    Loves duck, Peking Duck! bsodmike's Avatar
    Join Date
    Jul 2003
    Location
    Colombo
    Posts
    2,909
    Thanks
    496
    Thanked
    92 times in 80 posts
    • bsodmike's system
      • Motherboard:
      • Misc.
      • CPU:
      • Mac Pro 2.8 GHz (8-cores) / iMac 2.8GHz C2D Extreme Edition / MacBook Pro 15" 2.33 & 13.3" 2.26 GHz
      • Memory:
      • 2GB DDR2 kits on all systems / FB ECC RAM in Mac Pro
      • Storage:
      • 320GB + 3x 1TB, Mac Pro / 500 GB, iMac / 2x 1TB & 2x 2TB WD My Book Studio II, via FW800 to Mac Pro
      • Graphics card(s):
      • ATI Radeon HD 2600 XT 256MB (two dual-link DVI ports / Mac Pro)
      • PSU:
      • Misc.
      • Case:
      • Misc.
      • Operating System:
      • Mac OS X 10.5 (Mac Pro) / Mac OS X 10.4.11 (others)
      • Monitor(s):
      • Apple 23" Cinema HD / Dell FPW2408 / iMac 24" display
      • Internet:
      • 2mbps ADSL (Mac Pro) / 512kbps WiMax (Wifi/MacBook Pro)

    Re: Ubuntu hosts and hostname mystery

    Quote Originally Posted by Flash477 View Post
    Look at /etc/sysconfig/network
    There is no 'sysconfig'. That's only for redhat I think. I'm using Ubuntu 10.04 LTS.

    ODBCDataSources dpkg lsb-release rc2.d
    X11 environment lynx-cur rc3.d
    adduser.conf fonts magic rc4.d
    aliases fstab magic.mime rc5.d
    alternatives gai.conf mail rc6.d
    anacrontab groff mailcap rcS.d
    apache2 group mailcap.order resolv.conf
    apm group- manpath.config resolvconf
    apparmor gshadow mime.types rmt
    apparmor.d gshadow- mke2fs.conf rpc
    apt host.conf modprobe.conf sasldb2
    bash.bashrc hostname modprobe.d screenrc
    bash_completion.d hosts modules securetty
    bindresvport.blacklist hosts.allow motd security
    blkid.conf hosts.deny mtab services
    blkid.tab init mtools.conf shadow
    ca-certificates init.d mysql shadow-
    ca-certificates.conf init.removed nanorc shells
    calendar initramfs-tools network skel
    complete.tcsh inittab networks ssh
    console inputrc nsswitch.conf ssl
    console-tools insserv odbc.ini sudoers
    cracklib insserv.conf opt sudoers.d
    cron.d insserv.conf.d pam.conf sysctl.conf
    cron.daily iproute2 pam.d sysctl.d
    cron.hourly issue papersize syslog.conf
    cron.monthly issue.net passwd terminfo
    cron.weekly ld.so.cache passwd- timezone
    crontab ld.so.conf perl ucf.conf
    csh ld.so.conf.d php5 udev
    csh.cshrc ldap ppp ufw
    csh.login legal profile update-motd.d
    csh.logout libpaper.d profile.d updatedb.conf
    dbus-1 locale.alias protocols vim
    debconf.conf localtime python vz
    debian_version logcheck python2.6 warnquota.conf
    default login.defs quotagrpadmins wgetrc
    defoma logrotate.conf quotatab wide-dhcpv6
    deluser.conf logrotate.d rc.local
    depmod.d lsb-base rc0.d
    dhcp3 lsb-base-logging.sh rc1.d

  4. #4
    PHP Geek Flash477's Avatar
    Join Date
    Dec 2008
    Location
    Devon
    Posts
    822
    Thanks
    51
    Thanked
    72 times in 65 posts

    Re: Ubuntu hosts and hostname mystery

    Sorry, I'm running CentOS, although I thought that was pretty standard.

    Looking at the man page for Ubuntu hostname you might want to check if it is set in either of these files:

    /etc/rc.d/rc.inet1
    /etc/init.d/boot

  5. #5
    Senior Member watercooled's Avatar
    Join Date
    Jan 2009
    Posts
    11,478
    Thanks
    1,541
    Thanked
    1,029 times in 872 posts

    Re: Ubuntu hosts and hostname mystery

    After editing the hosts file, run:
    echo servername.domain.com > /etc/hostname
    /etc/init.d/hostname.sh start
    Replacing servername.domain.com with your server name obviously.

  6. #6
    Loves duck, Peking Duck! bsodmike's Avatar
    Join Date
    Jul 2003
    Location
    Colombo
    Posts
    2,909
    Thanks
    496
    Thanked
    92 times in 80 posts
    • bsodmike's system
      • Motherboard:
      • Misc.
      • CPU:
      • Mac Pro 2.8 GHz (8-cores) / iMac 2.8GHz C2D Extreme Edition / MacBook Pro 15" 2.33 & 13.3" 2.26 GHz
      • Memory:
      • 2GB DDR2 kits on all systems / FB ECC RAM in Mac Pro
      • Storage:
      • 320GB + 3x 1TB, Mac Pro / 500 GB, iMac / 2x 1TB & 2x 2TB WD My Book Studio II, via FW800 to Mac Pro
      • Graphics card(s):
      • ATI Radeon HD 2600 XT 256MB (two dual-link DVI ports / Mac Pro)
      • PSU:
      • Misc.
      • Case:
      • Misc.
      • Operating System:
      • Mac OS X 10.5 (Mac Pro) / Mac OS X 10.4.11 (others)
      • Monitor(s):
      • Apple 23" Cinema HD / Dell FPW2408 / iMac 24" display
      • Internet:
      • 2mbps ADSL (Mac Pro) / 512kbps WiMax (Wifi/MacBook Pro)

    Re: Ubuntu hosts and hostname mystery

    Quote Originally Posted by Flash477 View Post
    Sorry, I'm running CentOS, although I thought that was pretty standard.

    Looking at the man page for Ubuntu hostname you might want to check if it is set in either of these files:

    /etc/rc.d/rc.inet1
    /etc/init.d/boot
    Thanks but I couldn't locate those
    README network-interface sendmail
    anacron network-interface-security sendsigs
    apache2 networking single
    bootlogd ondemand skeleton
    console-screen.sh plymouth ssh
    cron plymouth-log stop-bootlogd
    fetchmail plymouth-splash stop-bootlogd-single
    halt plymouth-stop sysklogd
    hostname portmap udev
    hwclock procps udev-finish
    hwclock-save quota udevmonitor
    iptables quotarpc udevtrigger
    keymap.sh rc umountfs
    killprocs rc.local umountnfs.sh
    klogd rcS umountroot
    libpam-foreground reboot urandom
    module-init-tools rsync vzquota
    modules_dep.sh saslauthd wide-dhcpv6-client
    mysql screen-cleanup

  7. #7
    Senior Member watercooled's Avatar
    Join Date
    Jan 2009
    Posts
    11,478
    Thanks
    1,541
    Thanked
    1,029 times in 872 posts

    Re: Ubuntu hosts and hostname mystery

    What about using chmod to remove write permissions?

  8. #8
    Loves duck, Peking Duck! bsodmike's Avatar
    Join Date
    Jul 2003
    Location
    Colombo
    Posts
    2,909
    Thanks
    496
    Thanked
    92 times in 80 posts
    • bsodmike's system
      • Motherboard:
      • Misc.
      • CPU:
      • Mac Pro 2.8 GHz (8-cores) / iMac 2.8GHz C2D Extreme Edition / MacBook Pro 15" 2.33 & 13.3" 2.26 GHz
      • Memory:
      • 2GB DDR2 kits on all systems / FB ECC RAM in Mac Pro
      • Storage:
      • 320GB + 3x 1TB, Mac Pro / 500 GB, iMac / 2x 1TB & 2x 2TB WD My Book Studio II, via FW800 to Mac Pro
      • Graphics card(s):
      • ATI Radeon HD 2600 XT 256MB (two dual-link DVI ports / Mac Pro)
      • PSU:
      • Misc.
      • Case:
      • Misc.
      • Operating System:
      • Mac OS X 10.5 (Mac Pro) / Mac OS X 10.4.11 (others)
      • Monitor(s):
      • Apple 23" Cinema HD / Dell FPW2408 / iMac 24" display
      • Internet:
      • 2mbps ADSL (Mac Pro) / 512kbps WiMax (Wifi/MacBook Pro)

    Re: Ubuntu hosts and hostname mystery

    Quote Originally Posted by watercooled View Post
    What about using chmod to remove write permissions?
    That made no difference. I did a 'chmod a-w' on both files; rebooted and they were back to defaults.

    edit: I did a chattr +i on the files and got the external hostname set by our host.
    Last edited by bsodmike; 14-07-2010 at 08:09 AM.

  9. #9
    Agent of the System ikonia's Avatar
    Join Date
    May 2004
    Location
    South West UK (Bath)
    Posts
    3,736
    Thanks
    39
    Thanked
    75 times in 56 posts

    Re: Ubuntu hosts and hostname mystery

    ok - in my view stop trying to put little dirty fixes in to resolve this.

    Something is changing your hostname, that's a serious issue, you need to know what that is and fix it.

    This should not happen on a default ubuntu install so you've got to look at any packages you've installed

    a.) from the ubuntu repo's post install
    b.) any packages you've installed from external repos

    run through the init scripts (keep in mind 10.04 will use upstart scripts) and search out /etc/hostname and /etc/hosts

    Also consider dhcp, is dhcp setting this for you ?

    as anything else changing, eg: the ip addresses in /etc/hosts, your dns servers for example ?
    It is Inevitable.....


  10. #10
    Loves duck, Peking Duck! bsodmike's Avatar
    Join Date
    Jul 2003
    Location
    Colombo
    Posts
    2,909
    Thanks
    496
    Thanked
    92 times in 80 posts
    • bsodmike's system
      • Motherboard:
      • Misc.
      • CPU:
      • Mac Pro 2.8 GHz (8-cores) / iMac 2.8GHz C2D Extreme Edition / MacBook Pro 15" 2.33 & 13.3" 2.26 GHz
      • Memory:
      • 2GB DDR2 kits on all systems / FB ECC RAM in Mac Pro
      • Storage:
      • 320GB + 3x 1TB, Mac Pro / 500 GB, iMac / 2x 1TB & 2x 2TB WD My Book Studio II, via FW800 to Mac Pro
      • Graphics card(s):
      • ATI Radeon HD 2600 XT 256MB (two dual-link DVI ports / Mac Pro)
      • PSU:
      • Misc.
      • Case:
      • Misc.
      • Operating System:
      • Mac OS X 10.5 (Mac Pro) / Mac OS X 10.4.11 (others)
      • Monitor(s):
      • Apple 23" Cinema HD / Dell FPW2408 / iMac 24" display
      • Internet:
      • 2mbps ADSL (Mac Pro) / 512kbps WiMax (Wifi/MacBook Pro)

    Re: Ubuntu hosts and hostname mystery

    Thanks for your reply Ikonia; I shared your sentiments exactly and really couldn't rest until I did find the root of the problem. It's to do with the way Virtuozzo containers work; the hostname is stored externally!

    Most hosting companies probably present their clients with a very complex control panel - this is not the case with MediaTemple. When one purchases a 'slice', essentially, the Primary Domain is used as the external hostname.

    Therefore, on reboots, those two files will always change to the primary domain.

    This would typically work on any Ubuntu setup if the sites were being served either from /var/www or /etc/apache2/sites-available/000-default. In our case it wasn't the latter per say - we are using vhosting with 'a2ensite' etc. Of course, with a2ensite, we'd essentially enable something like "/etc/apache2/sites-available/ourdomain.com".

    If /etc/hosts and /etc/hostname = ourdomain.com, DUMP_VHOSTS shows that the vhosting breaks. That's why hosts and hostname needed to be something very different from the actual domain(s) used.

    Thankfully, this is sorted now and thanks to all for your help/support

    Cheers, Mike.
    Last edited by bsodmike; 17-07-2010 at 07:24 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •