Find the answer to your Linux question:
Results 1 to 8 of 8
Hi folks, Ubuntu 10.10 64 bit I need to set /etc/hostname and /etc/hosts so that on running; $ hostname Code: ub1004 $ hostname -a Code: ub1004 I set them as; ...
  1. #1
    Linux Guru
    Join Date
    Sep 2004
    Posts
    1,546

    Settings of /etc/hosts and /etc/hostname

    Hi folks,

    Ubuntu 10.10 64 bit


    I need to set /etc/hostname and /etc/hosts so that on running;

    $ hostname
    Code:
    ub1004
    $ hostname -a
    Code:
    ub1004

    I set them as;

    cat /etc/hostname
    Code:
    ub1004
    cat /etc/hosts
    Code:
    127.0.0.1	localhost.localdomain
    123.123.123.123	ub1004.domain.com	ub1004
    
    # The following lines are desirable for IPv6 capable hosts
    ::1     localhost ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    ff02::3 ip6-allhosts
    After reboot:

    cat /etc/hostname
    Code:
    ub1004
    $ cat /etc/hosts
    Code:
    127.0.0.1	ub1004	localhost.localdomain	localhost
    ::1	ub1004	localhost6.localdomain6	localhost6
    #127.0.1.1	ub1004
    123.123.123.123	ub1004.domain.com	ub1004
    
    # The following lines are desirable for IPv6 capable hosts
    ::1     localhost ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    ff02::3 ip6-allhosts

    On running

    $ hostname
    Code:
    ub1004
    $ hostname -a
    Code:
    localhost.localdomain localhost localhost6.localdomain6 localhost6 ub1004 ub1004.domain.com
    Please advice.

    TIA


    B.R.
    satimis

  2. #2
    Linux User ptkobe's Avatar
    Join Date
    Feb 2008
    Location
    Torres Vedras, PT
    Posts
    274
    I'm guessing your question is why is the hosts file changing after reboot.

    I'll bet on some administrative routine that runs during the boot ip request or network authentication.
    Are you in charge of those processes? If they exist, that is.

    Of course, if you are not your machine's administrator, it may be a local routine. But as you are editing hosts...

    Is any of that possible?

    Regards
    Luis
    Last edited by ptkobe; 12-05-2010 at 02:29 AM.

  3. #3
    Linux Guru
    Join Date
    Sep 2004
    Posts
    1,546
    Quote Originally Posted by ptkobe View Post
    I'm guessing your question is why is the hosts file changing after reboot.

    I'll bet on some administrative routine that runs during the boot ip request or network authentication.
    Are you in charge of those processes? If they exist, that is.

    Of course, if you are not your machine's administrator, it may be a local routine. But as you are editing hosts...

    Is any of that possible?

    Regards
    Luis
    Hi Luis,

    I'm the admin. This is a virtual machine running Oracle VBox as virtualizer. I just discovered this strange happening /etc/hosts changed after reboot.

    host - Ubuntu 1010 64 bit
    VMs - Ubuntu 1004/1010 Debian 6.0, all 64 bits, Windows 32/64 bits etc.

    Only Ubuntu has this problem.

    On Debian:-
    > hostname
    > hostname -a
    display the same output, same hostname "deb600dk01"

    > cat /etc/hosts
    Code:
    127.0.0.1		localhost
    123.123.123.123. 	deb600dk01.domain.com	deb600dk01
    
    # The following lines are desirable for IPv6 capable hosts
    ::1     localhost ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    /etc/hosts won't change after reboot.

    I edited /etc/hosts of Ubuntu similar to that of Debian. But it doesn't work. Problem still remains.

    B.R.
    satimis

  4. #4
    Trusted Penguin elija's Avatar
    Join Date
    Jul 2004
    Location
    Either at home or at work or down the pub
    Posts
    2,303
    It could be DHCP rewriting it
    If we hit that bullseye, the rest of the dominoes will fall like a house of cards. Checkmate! (Zapp Brannigan)


    My new blog. It's probably not as good as I think it is.

  5. #5
    Linux Guru
    Join Date
    Sep 2004
    Posts
    1,546
    Quote Originally Posted by elija View Post
    It could be DHCP rewriting it
    Hi,

    All Ubuntu and Debian VMs and host are running fixed IP NOT DHCP

    $ cat /etc/network/interfaces
    Code:
    auto lo
    iface lo inet loopback
    
    # The primary network interface
    auto eth0
    iface eth0 inet manual
    
    auto br0
    iface br0 inet static
            address xxx.xxx.xxx.xxx
            network xxx.xxx.xxx.xxx
            netmask 255.255.255.0
            broadcast xxx.xxx.xxx.xxx
            gateway xxx.xxx.xxx.xxx
            bridge_ports eth0
            bridge_fd 9
            bridge_hello 2
            bridge_maxage 12
            bridge_stp off
    B.R.
    satimis

  6. #6
    Linux User ptkobe's Avatar
    Join Date
    Feb 2008
    Location
    Torres Vedras, PT
    Posts
    274
    Hi, satimis. Ok.
    First, what are the changes? They redirect your local machine name ip4 lookup searches to the loopback, and adds a line doing the same for the IP6 searches (missing the already existent line below).
    That's not bad. Can you live with it?

    Second, if not, or if you really want to try to get to the bottom of it, I'll check the boot scripts (/etc/rc2.d/S*) and the /etc/init/* boot scripts, and also the /etc/rc.local file to try to find some code that may be responsible for it.

    I never used VBox, I use kvm/libvirt, but I'm pretty sure that boot changes of /etc/hosts is not a "normal" thing. Maybe someone else may know more.

    Please don't mind me telling the following, we both probably been around on computers for a while.
    Check the dates on the above mentioned scripts with ls -lt. You may have made some change on them you have forgotten

    Regards
    Luis

    PS: From $ man hostname
    -a, --alias
    Display the alias name of the host (if used). This option is deprecated and should not be used anymore.
    ??

  7. #7
    Linux User ptkobe's Avatar
    Join Date
    Feb 2008
    Location
    Torres Vedras, PT
    Posts
    274
    Also, if you are using
    # The primary network interface
    auto eth0
    iface eth0 inet manual

    you may also check the /etc/network/if-*.d scipts

    $ man interfaces
    The manual Method
    This method may be used to define interfaces for which no configuration is done by default. Such interfaces can be configured
    manually by means of up and down commands or /etc/network/if-*.d scripts.

    I have a similar conf (with libvirt) and I don't have to use that. The
    bridge_ports eth0
    line is enough for me.

    You may try to comment those lines as an easy way to discard /etc/network/if-*.d scripts from being messing with your /etc/hosts file.

  8. #8
    Linux Guru
    Join Date
    Sep 2004
    Posts
    1,546
    Quote Originally Posted by ptkobe View Post
    Also, if you are using
    # The primary network interface
    auto eth0
    iface eth0 inet manual

    you may also check the /etc/network/if-*.d scipts

    $ man interfaces
    The manual Method
    This method may be used to define interfaces for which no configuration is done by default. Such interfaces can be configured
    manually by means of up and down commands or /etc/network/if-*.d scripts.

    I have a similar conf (with libvirt) and I don't have to use that. The
    bridge_ports eth0
    line is enough for me.

    You may try to comment those lines as an easy way to discard /etc/network/if-*.d scripts from being messing with your /etc/hosts file.
    Hi Luis,

    Up to now I haven't discovered this change causing problem in operation. I just wonder why all Ubuntu OS here both host and VMs have this problem. Debian VMs don't suffer this problem.

    Following is host data (Ubuntu 10.10 desktop 64bit):-

    $ cat /etc/hosts
    Code:
    127.0.0.1	ub1004	localhost.localdomain	localhost
    ::1	ub1004	localhost6.localdomain6	localhost6
    #127.0.1.1	ub1004
    192.xxx.xxx.xxx	ub1004.domain.com	ub1004
    
    # The following lines are desirable for IPv6 capable hosts
    ::1     localhost ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    ff02::3 ip6-allhosts
    $ cat /etc/hosts
    Code:
    127.0.0.1	ub1004	localhost.localdomain	localhost
    ::1	ub1004	localhost6.localdomain6	localhost6
    #127.0.1.1	ub1004
    192.xxx.xxx.xxx	ub1004.domain.com	ub1004
    
    # The following lines are desirable for IPv6 capable hosts
    ::1     localhost ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    ff02::3 ip6-allhosts
    $ cat /etc/network/interfaces
    Code:
    # The loopback network interface
    auto lo
    iface lo inet loopback
    
    # The primary network interface
    auto eth0
    iface eth0 inet manual
    
    auto br0
    iface br0 inet static
    	address	192.xxx.xxx.xxx
    	network 192.xxx.xxx.xxx
    	netmask	255.255.255.0
    	broadcast 192.xxx.xxx.xxx
    	gateway	192.xxx.xxx.xxx
    	bridge_ports eth0
    	bridge_fd 9
    	bridge_hello 2
    	bridge_maxage 12
    	bridge_stp off
    $ cat /etc/udev/rules.d/70-persistent-net.rules
    Code:
    # This file maintains persistent names for network interfaces.
    # See udev(7) for syntax.
    #
    # Entries are automatically added by the 75-persistent-net-generator.rules
    # file; however you are also free to add your own entries.
    
    # PCI device 0x1969:0x1026 (ATL1E)
    SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:26:18:44:b6:1a", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

    B.R.
    satimis

Posting Permissions

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