Hostname problem

Discussion in 'Mac Basics and Help' started by tag, Jun 17, 2005.

  1. tag macrumors 6502a

    tag

    Joined:
    Apr 29, 2005
    Location:
    PA, US
    #1
    Ok, Im trying to find a way to fix this, or get around it, depending how you look at it.
    When I connect to the internet, my host name of my iMac changes.

    Prior to connection to internet it is 'Robs iMac'...
    rob@Robs iMac:~ $ uname -a
    Darwin Robs iMac 8.1.0 Darwin Kernel Version 8.1.0: Tue May 10 18:16:08 PDT 2005; root:xnu-792.1.5.obj~4/RELEASE_PPC Power Macintosh powerpc

    Now after I connect it changes to my IP host address...
    rob@user216-178-86-223:~ $ uname -a
    Darwin user216-178-86-223.netcarrier.net 8.1.0 Darwin Kernel Version 8.1.0: Tue May 10 18:16:08 PDT 2005; root:xnu-792.1.5.obj~4/RELEASE_PPC Power Macintosh powerpc

    Now this isn't a huge problem, but if I connect to this computer via ssh or the like, I would like to have the computers name in the command line prompt, so I can tell which system I am on, but I can't seem to find a way to do that since whenever I connect to the internet, its host name automatically changes to its IP address.

    Currently I am using this prompt... PS1='\u@\h:\w \$ '

    I suppose if it comes down to it I could just manually put in the hostname and keep it static, but I would like to see if I can make it so the hostname isnt changing everytime I log on.
     
  2. peterparker macrumors regular

    peterparker

    Joined:
    Mar 12, 2005
    Location:
    Houston
    #2
    Strange, it was controlled in /etc/hostconfig in Panther but not in Tiger. I'll look around somemore or maybe someone else will have the answer first.
     
  3. daveL macrumors 68020

    daveL

    Joined:
    Jun 18, 2003
    Location:
    Montana
    #3
    When you connect to the internet your ISP is assigning you a host name and IP address via DHCP, which overrides your local settings. At least that's how it looks from here.
     
  4. yellow Moderator emeritus

    yellow

    Joined:
    Oct 21, 2003
    Location:
    Portland, OR
    #4
    daveL is correct. And that's how it should be. Don't mess with your hostname. Just change the prompt!
     
  5. tag thread starter macrumors 6502a

    tag

    Joined:
    Apr 29, 2005
    Location:
    PA, US
    #5
    Alright then thanks everyone, guess I'll just be changing the prompt manually then.
     
  6. superbovine macrumors 68030

    superbovine

    Joined:
    Nov 7, 2003
    #6
  7. tag thread starter macrumors 6502a

    tag

    Joined:
    Apr 29, 2005
    Location:
    PA, US
    #7

    Ok thats just cool, color coding your prompt via what type of connection you are using. I modified it so that it checks for a file on each system, and color codes the prompt based upon which file it finds, though after using it for a bit, I found the color coding actually works more efficiently to tell me which way Im connected (ie. ssh, telnet, via root/user color combinations). So thanks for that snippit.
     

Share This Page