how to properly edit hosts, hostname and resolf.conf?

Posted on

Problem :

I have been searching the Internet for a real nop tutorial on the subject but could not found any direct info. on how to edit these files the proper way.

I have a Debian Internet server that I use to host some personal domains and runs Squid and rTorrent. The server is up and running with no problems. However, I am confused about a few things.

Lets say that I named my server (foo), my domain is (example.com) and my public IP is 95.211.133.200 now:

  1. should /etc/hostname contains:

    tango.example.com
    

    or

    tango <----- just the server name
    
  2. should /etc/hosts contain:

    127.0.0.1       localhost.localdomain   localhost
    95.211.133.200  foo.example.com         foo
    
  3. should /etc/resolf.conf contain (along with the name servers) both:

    domain example.com
    search example.com
    

    or just the first one.

    Are there any other files that I should edit in order to make things right?

  4. last thing, the command:

    domainname
    
    returns: (none)
    

    I believe it should return (example.com). What should I do to correct that?

Solution :

/etc/hostname should have just foo

/etc/hosts looks fine

/etc/resolv.conf should probably be example.com for both, depending on your use case. Note that you named it /etc/resolf.conf and it should be v and not f

I don’t know about domainname

Leave a Reply

Your email address will not be published. Required fields are marked *