0

In my /etc/hostname (Ubuntu 14.04) file I have:

pavel@subdomain:~$ cat /etc/hostname
example.ru

But when I run:

hostname -f

it shows:

pavel@subdomain:~$ hostname -f
subdomain.example.ru

It possibly (100%) affects my postfix configuration, when I'm trying to configure it as send-only SMTP-server and it sends messages with "pavel@subdomain.domain.ru" sender address.

How and where to avoid subdomain in my case? Thank you!

1
  • To solve your Postfix issue, you might want to take a look at Postfix Address Rewriting - Masquerade. I can't tell you this is the solution to use, but it worked perfectly when I had the same issue as yours.
    – Yuriko
    Nov 30, 2015 at 9:34

2 Answers 2

1

The hostname should contain the name of the server, for example athena.zertux.net is my subdomain, in the hostname i would put athena.

The /etc/hosts file can contain a mapping of IP address to a domain/subdomain.

In your case:

127.0.0.1       localhost
127.0.0.1       example.ru

If you need a specific IP for your domain name, you can change 127.0.0.1

2
  • But what if my domain name (e.g. hostname.ru) should be aliased to the virtual machine itself? Nov 30, 2015 at 9:26
  • You can add that in the /etc/hosts file
    – zertux
    Nov 30, 2015 at 9:29
1

hostname -f resolves the name given by hostname into an IP, and then does a reverse lookup on that address to get the name to return to you.

In your specific case, your DNS (or /etc/hosts) is turning example.ru into an IP address, which then reverses back into subdomain.example.ru, so that's where the name is coming from.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.