Configuring hostname, domainname, and IP address

Discussion in 'Linux Networking' started by linuxquestion, Jan 2, 2004.

  1. HI,

    Sorry to ask another dumb question.

    I want to configure my Redhat Advanced server 2.1 to
    into a local network. I plan to have only two nodes.

    hostname: red
    ip address: 10.0.0.1
    domainname: testrac.com

    hostname: white
    ip address: 10.0.0.2
    domainname: testrac.com

    So far, I am only working with the first machine, red.
    I'm trying to get the machine to recognize itself as
    red.testrac.com, at IP 10.0.0.1. On domain: testrac.com


    I have modified these files:

    cat /etc/hosts
    # Do not remove the following line, or various programs
    # that require network functionality will fail.
    127.0.0.1 red red.testrac.com localhost.localdomain localhost
    10.0.0.1 red red.testrac.com


    cat /etc/sysconfig/network
    NETWORKING=yes
    HOSTNAME=red.testrac.com



    hostname
    red.testrac.com

    hostname --short
    red

    hostname --long
    red
    (odd. Why not the whole name?)


    domainname
    (none)

    dnsdomainname
    - nothing


    ping red.testrac.com

    PING red (127.0.0.1) from 127.0.0.1 : 56(84) bytes of data.
    64 bytes from red (127.0.0.1): icmp_seq=0 ttl=255 time=281 usec

    - looks at 127.0.0.1, not 10.0.0.1


    ping 10.0.0.1
    connect: Network is unreachable

    ------------

    I would like the command domainname to return:
    testrac.com, and ping 10.0.0.1 to find itself.

    What am I missing here? It is something with the dns?


    Thanks
     
    linuxquestion, Jan 2, 2004
    #1
    1. Advertisements

  2. Switch the red and the red.testrac.com in your host file.
    Look to your /etc/hosts file. You have red.testrac.com as 127.0.0.1 as
    well as 10.0.0.1 and it is finding the 127.0.0.1 first. Remove the red
    and red.testrac.com from the 127.0.0.1 line.
    Off the top of my head I am not sure about the domainname commands
    result but I will see what I can find.
     
    Charles LaCour, Jan 2, 2004
    #2
    1. Advertisements

  3. linuxquestion

    Brad Olin Guest

    Umm try it this way...

    127.0.0.1 localhost.localdomain localhost
    10.0.0.1 red.testrac.com red

    The lo and eth0 nics must have unique names (1st name after the IP
    address) and unique aliases (subsequent names on same line).
    I think you should also have a gateway statement in the
    /etc/sysconfig/network file, something like...

    GATEWAY=10.0.0.254


    FYI: The new convention is that .1 is the gateway device and the old
    convention is that .254 is the gateway device. Truth be know, it can be
    any valid IP within your network. Just be aware that most network
    devices (like routers) will have a factory default of one or the other.


    Brad
     
    Brad Olin, Jan 2, 2004
    #3
  4. linuxquestion

    Baho Utot Guest

    The format is FQDN followed by aliases

    This is what it should read instead
    127.0.0.1 red.testrac.com red localhost.localdomain localhost
    --------------- +++ +++++++++++++++++++++ +++++++++
    where ---- is the fully qualified domainname
    and ++++ are aliases
    Because the hosts file is barfed
    Should read
    dnsdomainname
    testrac.com red


    Later Dude
     
    Baho Utot, Jan 2, 2004
    #4
  5. linuxquestion

    Bill Unruh Guest

    ] wrote:

    ]> HI,
    ]>
    ]> Sorry to ask another dumb question.
    ]>
    ]> I want to configure my Redhat Advanced server 2.1 to
    ]> into a local network. I plan to have only two nodes.
    ]>
    ]> hostname: red
    ]> ip address: 10.0.0.1
    ]> domainname: testrac.com
    ]>
    ]> hostname: white
    ]> ip address: 10.0.0.2
    ]> domainname: testrac.com
    ]>
    ]> So far, I am only working with the first machine, red.
    ]> I'm trying to get the machine to recognize itself as
    ]> red.testrac.com, at IP 10.0.0.1. On domain: testrac.com
    ]>
    ]>
    ]> I have modified these files:
    ]>
    ]> cat /etc/hosts
    ]> # Do not remove the following line, or various programs
    ]> # that require network functionality will fail.
    ]> 127.0.0.1 red red.testrac.com localhost.localdomain localhost
    Call this localhost and do not use the words red or red.testrac.com for
    it. On reading the hosts file it is the FIRST instance which is taken.
    This means that red would always come out as 127.0.0.1 which is not
    always what you want.


    ]> 10.0.0.1 red red.testrac.com
    ]>

    ]The format is FQDN followed by aliases

    ]This is what it should read instead
    ] 127.0.0.1 red.testrac.com red localhost.localdomain localhost
    ] --------------- +++ +++++++++++++++++++++ +++++++++
    ]where ---- is the fully qualified domainname
    ]and ++++ are aliases

    It does not really matter. It is just that the first name is what is
    returned on a reverse lookup. If you are ok with it just returning red
    your original is fine. I ahve loads of machines that do that and
    everything works fine. In a hosts file there is no need for a fully
    qualified domain name for local stuff.


    ]>
    ]> cat /etc/sysconfig/network
    ]> NETWORKING=yes
    ]> HOSTNAME=red.testrac.com

    ]Ok

    ]> hostname --long
    ]> red

    Why do you care?
    ]> domainname
    ]> (none)

    Why do you care?


    ]> dnsdomainname
    ]> - nothing

    Why do you care?
     
    Bill Unruh, Jan 2, 2004
    #5
  6. linuxquestion

    Bill Unruh Guest

    ]> hostname: red
    ]> ip address: 10.0.0.1

    ]Don't do that - it is not officially allowed in IP networking.

    ]Use 10.1.1.1 if you must, but in any case you will have to set the
    ]netmask by hand to 255.255.255.0, as it is not a standard class C subnet.

    Why? a zero in the non-last position is fine. Yes, you may have to set
    the netmask by hand, but so what. And so what if it is 255.0.0.0? It is
    a private address space anyway.


    ]>
    ]> PING red (127.0.0.1) from 127.0.0.1 : 56(84) bytes of data.
    ]> 64 bytes from red (127.0.0.1): icmp_seq=0 ttl=255 time=281 usec
    ]>
    ]> - looks at 127.0.0.1, not 10.0.0.1

    ]Of course it does - you told it to!

    Because teh first occurance of red in /etc/hosts is the 127.0.0.1 IP
    address. It takes the first occurance.


    ]> ping 10.0.0.1
    ]> connect: Network is unreachable

    This is a routing problem. What is the output of route?
     
    Bill Unruh, Jan 2, 2004
    #6
  7. Thanks for the responses. Ok, I tried this:

    change /etc/hosts to:

    # Do not remove the following line, or various programs
    # that require network functionality will fail.
    127.0.0.1 red.testrac.com red localhost.localdomain localhost
    10.0.0.1 red.testrac.com red

    reboot

    ping -c 1 red
    PING red.testrac.com (127.0.0.1) from 127.0.0.1 : 56(84) bytes of data.
    64 bytes from red.testrac.com (127.0.0.1): icmp_seq=0 ttl=255 time=302 usec

    # ping -c 1 red.testrac.com
    PING red.testrac.com (127.0.0.1) from 127.0.0.1 : 56(84) bytes of data.
    64 bytes from red.testrac.com (127.0.0.1): icmp_seq=0 ttl=255 time=17 usec

    - it's still looking at 127.0.0.1

    hostname --long
    red.testrac.com

    hostname --short
    red


    But, it still can't see the IP address that I want to assign
    to this machine:

    ping -c 1 10.0.0.1
    connect: Network is unreachable

    dnsdomainname
    testrac.com

    How do I assign the IP address to the machine?

    Thanks


    ---------------

    BTW, I notice that your domain is: philippines-island.org Two of
    my girlfriends were Phillipina (not at the same time). They
    picked me. They had long hair past their waist.
     
    linuxquestion, Jan 2, 2004
    #7
  8. linuxquestion

    Bit Twister Guest


    Well, make up your mind.
    If you want 10,0,0,1
    127.0.0.1 localhost.localdomain localhost
    10.0.0.1 red.testrac.com red
    or
    127.0.0.1 red.testrac.com red localhost.localdomain localhost
     
    Bit Twister, Jan 2, 2004
    #8
  9. linuxquestion

    Baho Utot Guest

    I was just giving them the proper format. If you want it set properly then
    that is the way its supposed to be. I set things as they should be to
    avoid problems later. Just because it works don't make it right.
    I don't have any problem with my networking.

    I don't
    I don't
    I don't
     
    Baho Utot, Jan 2, 2004
    #9
  10. linuxquestion

    Baho Utot Guest

    Thats because the 127.0.0.1 line is before the 10.0.0.1 try to swap them.
    If I understand the problem then it is assigned by ifconfig on boot, either
    by DHCP or a static setting.

    Yes I don't think two at the same time works ;)
     
    Baho Utot, Jan 2, 2004
    #10
  11. Did you read my earlier reply to your post?

    By having the short name, red, first in your /etc/hosts file that is
    considered your host name long or short. In your /etc/hosts file you
    should have each name and IP only once. By having red and
    red.testrac.com on two different lines with different IPs is ambiguous
    and likely not to produce the results you want. If you want to display
    the domain try hostname -d. If you take a look at the man pages the
    domainname command is used to show or set the system’s NIS/YP domain name.

    Your /etc/hosts file should look like this:
    127.0.0.1 localhost.localdomain localhost
    10.0.0.1 red.testrac.com red


    To dig further into your issue then please provide the output of the
    following commands:

    ifconfig -a
    netstat -nr
    cat /etc/sysconfig/network-scripts/eth0
    cat /etc/resolv.conf
    cat /nsswitch.conf
     
    Charles LaCour, Jan 2, 2004
    #11
  12. linuxquestion

    Brad Olin Guest

    fyi: a reboot is not required here

    Yup. That is what you told it to do. BT said it well, make up your
    mind...
    Obviously not, nor mine.

    btw: I wouldn't have repeated almost exactly your post except that your
    news server is better connected than mine. Sorry about that, I'll try
    harder to not stutter your words. :)


    Brad
     
    Brad Olin, Jan 3, 2004
    #12
  13. No problem, I don't mind if you repeat what I say. I have done the same
    thing, now I try to remember to check for new posts just before I submit
    my reply especially if it has taken me a while to put together my response.
     
    Charles LaCour, Jan 3, 2004
    #13
  14. linuxquestion

    David Tangye Guest

    On 03/01/04 09:21, after an epic battle with a keyboard, Charles LaCour
    wrote ...
    Agreed. Repeating FQDN and aliases is wrong, as is switching them. RTFM.

    The ip address for ethernet, on Redhat systems at least , is in
    somewhere like /etc/sysconfig/networking/devices/ifcfg-eth0. This is mine:

    DEVICE=eth0
    BOOTPROTO=none
    BROADCAST=192.168.0.255
    IPADDR=192.168.0.1
    NETMASK=255.255.255.0
    NETWORK=192.168.0.0
    ONBOOT=yes
    USERCTL=no
    PEERDNS=no
    TYPE=Ethernet
    GATEWAY=192.168.0.254

    Note my IP address at IPADDR=192.168.0.1
     
    David Tangye, Jan 3, 2004
    #14
  15. linuxquestion

    Ed Murphy Guest

    Actually, /etc/hosts on *each* machine should look like this:

    127.0.0.1 localhost # and only localhost
    127.0.0.2 localhost.localdomain # may be unnecessary
    10.0.0.1 red.testrac.com red
    10.0.0.2 white.testrac.com white
     
    Ed Murphy, Jan 3, 2004
    #15
  16. linuxquestion

    Baho Utot Guest

    Ok lets take this example shall we:
    127.0.0.1 red.testrac.com red localhost.localdomain localhost

    What is wrong with this....nothing if we RTFM we find that the only FQDN is
    red.testrac.com, red localhost.localdomain localhost are aliases.
    There is nothing that states you cannot have white.testrac.com as an alias.
    If we are dealing with a single machine then it is quite proper.
    Lookup the definition of an alias.
    This can be 127.0.0.1 red.testrac.com red localhost.localdomain localhost
    and 10.0.0.1 set in /etc/sysconfig/networking/devices/ifcfg-eth0 and the
    problem is solved.

    Now this may be a problem on a network w/o DNS as each host file would be
    unique to that machine as in white.testrac.com host file being:
    127.0.0.1 white.testrac.com white localhost.localdomain localhost
    10.0.0.1 red.testrac.com red

    and red.testrac.com being:
    127.0.0.1 red.testrac.com red localhost.localdomain localhost
    10.0.0.2 white.testrac.com white

    The easist way:

    127.0.0.1 localhost.localdomain localhost
    10.0.0.1 red.testrac.com red
    10.0.0.2 white.testrac.com white

    With DNS the first way works every time.

    Agreed?
     
    Baho Utot, Jan 3, 2004
    #16
  17. Yes, I did try what you suggested. But it didn't work.

    -----------------

    change /etc/hosts to:

    127.0.0.1 localhost.localdomain localhost
    10.0.0.1 red.testrac.com red

    reboot:

    ping red
    connect: Network is unreachable

    ping red.testrac.com
    connect: Network is unreachable

    dnsdomainname
    testrac.com

    -----------------

    Maybe I am phrasing the question wrong, but the original question is
    to get the machine to recognize itself as ALL of:

    127.0.0.1, 10.0.0.1, red.testrac.com, red

    So, if I ping 10.0.0.1, it should immediately find itself.
    Later, I will connect a second node (10.0.0.2), and it should
    immediately find it also. I believe that I am correct when I
    assume that, if a machine can't find itself, it will not find
    the second machine.

    Perhaps another way to phrase the question would be:
    how do I set the IP address, domainname, and hostname
    for an individual machine?
     
    linuxquestion, Jan 3, 2004
    #17
  18. To dig further into your issue then please provide the output of the
    -----------------

    Ok, nothing like surprises! It looks like the ethernet is not
    setup. Even though I have Ethernet, I believe on the motherboard.


    While not connected to the internet:

    -------------------
    cat /etc/sysconfig/network-scripts/eth0
    cat: /etc/sysconfig/network-scripts/eth0: No such file or directory

    - odd, since my motherboard comes with a built in ethernet.


    -------------------

    hostname -d
    testrac.com

    -------------------

    ifconfig -a
    lo Link encap:Local Loopback
    inet addr:127.0.0.1 Mask:255.0.0.0
    UP LOOPBACK RUNNING MTU:16436 Metric:1
    RX packets:210 errors:0 dropped:0 overruns:0 frame:0
    TX packets:210 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0
    RX bytes:14562 (14.2 Kb) TX bytes:14562 (14.2 Kb)

    -------------------
    netstat -nr

    Kernel IP routing table
    Destination Gateway Genmask Flags MSS Window
    irtt Iface
    127.0.0.0 0.0.0.0 255.0.0.0 U 40 0
    0 lo



    -------------------
    cat /etc/resolv.conf
    domain testrac.com


    -------------------

    In the Redhat hardware browser GUI, I can find nothing looking like
    an ethernet card. There is:
    CDROM, Floppy disks, hard disks, system devices, and USB devices
    Under system devices, there is four: USB UHCI Root hub

    I went into the Windows boot, and exported information from
    System info, network.


    [Adapter]

    Item Value
    Name [00000001] Intel(R) PRO/100 VE Network Connection
    Adapter Type Ethernet 802.3
    Product Type Intel(R) PRO/100 VE Network Connection
    Installed Yes
    PNP Device ID PCI\VEN_8086&DEV_1050&SUBSYS_01551028&REV_02\4&1C660DD6&0&40F0
    Last Reset 1/3/2004 11:48 AM
    Index 1
    Service Name E100B
    IP Address 0.0.0.0
    IP Subnet
    Default IP Gateway Not Available
    DHCP Enabled Yes
    DHCP Server
    DHCP Lease Expires Not Available
    DHCP Lease Obtained Not Available
    MAC Address 00:07:E9:3C:E3:24
    Memory Address 0xFCFFB000-0xFCFFBFFF
    I/O Port 0x0000DF40-0x0000DF7F
    IRQ Channel IRQ 20
    Driver c:\windows\system32\drivers\e100b325.sys (7.0.26.0 built by:
    WinDDK, 142.00 KB (145,408 bytes), 1/1/1980 12:00 AM)


    So, what docs do I need to be reading to configure the ethernet,
    and network?


    If this wasn't a big enough surprise, get this. I exported the
    text file from windows. But, cat network.txt | grep -i ethernet
    finds nothing. But, cat network.txt | wc gives me 492 lines.
    Even grep doesn't want to work today!


    Thanks
     
    linuxquestion, Jan 3, 2004
    #18
  19. linuxquestion

    Brad Olin Guest

    Your /etc/hosts finally looks reasonable. The error message that you
    now report indicates the network is not working...

    I'll quote Charles' earlier post

    To dig further into your issue then please provide the output of the
    following commands:

    ifconfig -a
    netstat -nr
    cat /etc/sysconfig/network-scripts/eth0
    cat /etc/resolv.conf
    cat /etc/nsswitch.conf


    Brad
    --
    "Until you make peace with who you are, you'll never be content with
    what you have." Doris Mortman

    Bradley W. Olin
    http://www.bwo1.com
     
    Brad Olin, Jan 3, 2004
    #19
  20. linuxquestion

    P.T. Breuer Guest

    Yes it did.
    This is now presumably a correct /etc/hosts. What is your hostname?
    What machine is "red"? And which interface have you assigned the IP
    10.0.0.1 too, if it is this machine?
    Don't! What on earth do you think that will do?
    So? All that means is that you haven't set an interface to talk to
    10./8 on.
    Quite right. But it should have told you the IP number too!
    There is no semantics to "recognize".
    It knows all that it needs to know.
    What do you mean? It does no finding. It simply sends the packets to
    the interface through which 10./8 is routed. If you have an interface
    configured as 10.0.0.1, then the kernel itself will intercept the
    packets and answer for it.

    So we deduce that you forgot to configure an interface as 10.0.0.1.
    I don't understand what you mean. Please use normal terminology!
    It doesn't do any "finding".
    There is no such thing as "the IP address". Machines normally have
    many. At least one per interface. Machines do have a unique hostname
    (with a unique domainname too), however, and you set it with
    "hostname", unsurprisingly.

    You may choose to set a FQDN with hostname, in which case the
    domainname is defined immediately as the trailing portion. If
    you only set an alias with hostname (e.g. "red"), then that alias
    will be looked up in /etc/hosts to find a canonical name
    ("red.testrac.com") which must be the first entry on the line on which
    the alias occurs. And the canonical name must be a FQDN, in order that
    the domainname be derived from it.

    Unsurprisingly too, you set the IP address of an interface with
    "ifconfig".

    Even more unsurprisingly, you set the routing out through your various
    interfaces with "route".

    So cease making a mess of this perfectly straightforward stuff.

    Peter
     
    P.T. Breuer, Jan 3, 2004
    #20
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.