0

When I set up a VPS, I set the name to "main" so both my /etc/hosts and /etc/hostnames files had one entry (that being "main"). So I set up root ssh access and type "hostname" and it gives me "main". Same deal when I type "hostname -f".

Well, I'm trying to set up Exim4 to send mail from my Django app (I only need to send, not receive) and I added the following to /etc/hosts.

127.0.1.1 main.mydomain.com main
<myip> main.mydomain.com main

I then executed service hostname restart and hostname -f only returned main. I even rebooted (something I try to avoid doing) and it still comes back main. Not sure why this is... The actual files themselves show my new entries but I can't get the actual hostname or hostname -f command to change for the life of me.

I'm guessing, but I'm not 100% sure, that's why when I use the command echo test message | mail -s test email@email.com I'm not getting an email at email@email.com (too many emails?). If it isn't absolutely necessary to have hostnames set up to use exim, I'd like to avoid it because its caused me such a headache.

Any help will render me eternally grateful to your awesomeness.

1

To set the domainname, you can use the equally named program domainname:

sudo domainname example.com

To query the actually set value, call it without parameters.

Also add need run the hostname.sh script (depends on the OS) to make the changes effective:

/etc/init.d/hostname.sh

On Debian and derivatives, there is also /etc/mailname which should contain the default sender's domain for outgoing emails.

I can't make a statement on Exim, but I think the default values in exim for host- and domainame should point to the OS's settings.

To cite the manpage of hostname:

THE FQDN

You can't change the FQDN (as returned by hostname --fqdn) or the DNS domain name (as returned by dnsdomainname) with this command. The FQDN of the system is the name that the resolver(3) returns for the host name.

Technically: The FQDN is the name getaddrinfo(3) returns for the host name returned by gethostname(2). The DNS domain name is the part after the first dot.

Therefore it depends on the configuration (usually in /etc/host.conf) how you can change it. Usually (if the hosts file is parsed before DNS or NIS) you can change it in /etc/hosts.

  • This seems more difficult than it should be. So I have to set the /etc/hosts and /etc/hostnames file plus do the sudo domainname thing? Will, at that point, Exim work as intended (assuming all my configuration settings are correct)? – Brian Burgess Mar 4 '15 at 20:16
  • @BrianBurgess I updated my answer – sebix Mar 4 '15 at 20:38
  • Thanks. I'll see how it works. As long as I can change that, I can at least move in to figuring out the configuration. – Brian Burgess Mar 4 '15 at 20:42
  • I praise your awesome for it is great. Thanks for the help! – Brian Burgess Mar 4 '15 at 22:24
0

If mail is being sent via postfix then you should also edit /etc/postfix/main.cf to have the correct value for myhostname = xyz

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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