Fedora Linux Support Community & Resources Center

Go Back   FedoraForum.org > Fedora 17/18 > Servers & Networking
FedoraForum Search

Forgot Password? Join Us!

Servers & Networking Discuss any Fedora server problems and Networking issues such as dhcp, IP numbers, wlan, modems, etc.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11th January 2006, 10:40 AM
diyfiesta's Avatar
diyfiesta Offline
Registered User
 
Join Date: Nov 2005
Posts: 49
Question send(ing)mail from root@localhost.localdomain

Hi Folks,

I've been playing with sendmail, wonderful stuff, but how do I make the sending address useful?

I've figured out that a change to the /etc/aliases file (then running newaliases) will forward all emails to root to a gmail account for example (which is cool because logwatch is sending me interesting things) but if I do this for two machines, I have emails from root@localhost.localdomain from both machines.

Also, to get httpd working, I edited the /etc/hosts file from something like

127.0.0.1 localhost machine1

to

127.0.0.1 localhost.localdomain localhost machine1

I suspect this is where sendmail gets it info from?

So, I'm wondering if this is the wider issue of setting the hostname on a machine and even... dun dun dun... setting up (local?) DNS? I figure I should be able to name the host with something useful and so get emails from root@machine1.mydomain and root@machine2.mydomain?

Any tips or pointers? I don't "own" any domain names and am running my servers on a home network accessing the internet via a router. Most configuration items are unchanged from isntall and its Fedora 4 (2.6.14-1.1653_FC4).

Thanks in advance,
Toby
Reply With Quote
  #2  
Old 12th January 2006, 06:54 PM
polc1410 Offline
Registered User
 
Join Date: Nov 2004
Posts: 90
Quote:
Originally Posted by diyfiesta
Also, to get httpd working, I edited the /etc/hosts file from something like

127.0.0.1 localhost machine1

to

127.0.0.1 localhost.localdomain localhost machine1
? that makes no sense to me! Are you running httpd on both machines? 127.0.0.1 is a loopback address - so that would make sense. What do you type in your browser to see the home page? Anyway all that is fairly irrelevant!

/etc/hosts is a bit lika a static local DNS (you dont say if you have static IP addresses or DHCP). Before your machine goes looking for a domain name it tries to resolve it using /etc/hosts (windows has an equivalent hosts file /windows/system/hosts or /windows/system32/drivers/etc/hosts ... one or two windows virus attack its hosts file and cause all sorts of exciting things to happen by redirecting localhost to external addresses!) anyway I digress again...

Reconfig your hostname by simply typing:

Code:
# hostname new.host.name
(you need to have superuser privalages (use su)

The new.host.name can be anything it doesn't need to be a valid domain name. My domain name is wittongilbert.free-online.co.uk, but my host names are linux-server.wittongilbert and linux-pc.wittongilbert - perhaps they should be linux-server.wittongilbert.free-online.co.uk but in reality that is not a valid domain!

You could set them to whatever you want - but they should be different... (in my opinion)


Quote:
I suspect this is where sendmail gets it info from?
Perhaps, but it may also be in the sendmail config file which is a beast of document. I edit mine using webmin... much easier and it contains references to linux-server.wittongilbert, localhost, localhost.localdomain and wittongilbert.free-online.co.uk. I know I edited some of them but I on't emember which ones!!quote]
So, I'm wondering if this is the wider issue of setting the hostname on a machine and even... dun dun dun... setting up (local?) DNS? I figure I should be able to name the host with something useful and so get emails from root@machine1.mydomain and root@machine2.mydomain?

Any tips or pointers? I don't "own" any domain names and am running my servers on a home network accessing the internet via a router. [/QUOTE]

Local DNS sounds like a big job for two PC's just add the following in the opposite machine's /etc/hosts files!:

192.168.1.100 (or whatever its IP address is) machine1.mydom
192.168.1.101 (or whatever...) machine2.mydom

Then if you are on machine 1 and ping machine2.mydom instead of ping 192.168.1.101 you should get the same result. (try it before you edit the hosts file... the router may do it for you anyway!)

If you plan on making the network big then local DNS is more realistic...

HTH

Calum
Reply With Quote
  #3  
Old 13th January 2006, 09:09 AM
diyfiesta's Avatar
diyfiesta Offline
Registered User
 
Join Date: Nov 2005
Posts: 49
Post

Thanks for the note Calum,

Quote:
? that makes no sense to me! Are you running httpd on both machines? 127.0.0.1 is a loopback address - so that would make sense. What do you type in your browser to see the home page? Anyway all that is fairly irrelevant!
Yikes! yes to running httpd on both machines (although I don't really need to), the problem I had was around httpd not having a server name or some such hilarity;

Code:
Quote:
Starting httpd: httpd: Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
I tried running # hostname new.name but it didn't seem to change the /etc/hosts file. It did return the new entry though when I ran 'hostname' with no parameters. I got scared so set it back oh, it couldn't ping it either but I may be doing something wrong.

So, in summary are you saying that if I change my /etc/hosts to something like;

127.0.0.1 localhost machine1
192.168.1.23 linux-machine.toby.com machine1

that sending mail out will result in mail addresses like

root@linux-machine.toby.com

? I think I need to keep the loopback in there(?) and arn't sure if having two aliases the same (machine1 above) is invalid.

Cheers,
Toby
Reply With Quote
  #4  
Old 14th January 2006, 11:42 AM
polc1410 Offline
Registered User
 
Join Date: Nov 2004
Posts: 90
[DELETED] Posted in Error - will post correct version soon. Sorry
Reply With Quote
  #5  
Old 14th January 2006, 12:52 PM
polc1410 Offline
Registered User
 
Join Date: Nov 2004
Posts: 90
Quote:
Originally Posted by diyfiesta
Yikes! yes to running httpd on both machines (although I don't really need to), the problem I had was around httpd not having a server name or some such hilarity;
That's OK, although in view of potential security holes - I'd personally only run httpd on a machine if its needed. Hence I have one machine which is the server and others which tap into that server. If you are using machine 1 and want to view the web server running on machine 1 you can type http://127.0.0.1/ on your machine to view it. That's the lopop back address and should display a web page on virtually any PC anywhere in the world that's running httpd! However if you type the same address into machine2 you'll see the httpd server on machine2 - if you want to see machine1's content you either need to type http://192.168.1.23 or a host name if one is configured. (There may be firewall rules, host.allow host.deny rules etc to open up as well.)

It may be possible with a well configured system running DHCP to type "machine1" in and it be translated to 192.168.1.23 -- I don't know?

However if you added
Code:
192.168.1.23 machine1
to the hosts file on machine2 and then type http://machine1/ in the browser it will display just like you typed the numbers. You could also use 192.168.1.23 linux-machine.toby.com (but that measn you have to type more in the browser!!)

HOWEVER none of that will affect the email! /etc/hosts is only read when your PC needs to know how to resolve a domain name before it tries the DNS server. It doesn't describe your local domain name!

Quote:
I tried running # hostname new.name but it didn't seem to change the /etc/hosts file. It did return the new entry though when I ran 'hostname' with no parameters. I got scared so set it back oh, it couldn't ping it either but I may be doing something wrong.
Don't be scared!! Penguins don't usually bite but they can sometimes give you a nasty slap with their flipper!! #hostname new.name is the only way you'll get the machine to believe its got a new name! That should translate into your email (but as email is already configured there may be a config file that pulled out of date info...)

Note -if you open a terminal window you see something like:
username@localhost directory$

That localhost should change to be machine1 or whatever. This sounds like a trivial thing but if you ever use SSH to connect into the other machine (you might not now, but give it a few years!) it measn you actually know which user you are logged in as on which machine... its all much clearer.

Quote:
So, in summary are you saying that if I change my /etc/hosts to something like;

127.0.0.1 localhost machine1
192.168.1.23 linux-machine.toby.com machine1

that sending mail out will result in mail addresses like

root@linux-machine.toby.com
NO!
/etc/hosts will only change how domain names are directed. It won't change your email. But you will probably also want to change the hosts file - otherwsie ping wont work from machine1 to machine2!
Quote:
? I think I need to keep the loopback in there(?) and arn't sure if having two aliases the same (machine1 above) is invalid.
Yes you need loopback.
Two aliases the same? not sure - probably not - but it only needs one.

Here's the suggestion:
Code:
Loginto machine 1
$ su
# hostname linux-machine1.toby.com
# vi /etc/hosts

edit it to:

127.0.0.1        localhost   machine1
192.168.1.23   linux-machine1.toby.com
192.168.1.24   linux-machine2.toby.com machine2

# ping machine1
# ping linux-machine1.toby.com
# ping machine2
# exit

---
Log into machine 2

$ su
# hostname linux-machine2.toby.com
# vi /etc/hosts

edit it to:

127.0.0.1        localhost   machine2
192.168.1.23   linux-machine1.toby.com machine1
192.168.1.24   linux-machine2.toby.com

# ping machine2
# ping linux-machine2.toby.com
# ping machine1
# exit
Then either use
Code:
$ mail root
(you leave the editor by putting a line with just a . on it)
or wait for logwatch to send the mail... and see what happens. It may STILL not know that the email domain has changes - but that's easy sorted with config files if we need to.. (it might be worth restarting sendmail etc first though incase it can pick them up when started.

ACTUALLY - I just looked at my LogWatch to see what it contains... the root@localhost.localdomain still appears (will need to check why!) BUT - the subject line contains the server domain...

Last edited by polc1410; 14th January 2006 at 12:54 PM.
Reply With Quote
  #6  
Old 15th January 2006, 07:13 AM
jdonz's Avatar
jdonz Offline
Registered User
 
Join Date: Nov 2004
Location: Phoenix, AZ
Age: 36
Posts: 56
Quote:
Originally Posted by polc1410
...
#hostname new.name is the only way you'll get the machine to believe its got a new name!
...
Actually, /etc/sysconfig/network is the file that specifies your hostname. You can edit /etc/sysconfig/network manually if you like. I believe the command line tool is just a shortcut to editing /etc/sysconfig/network.
Code:
[root@workstation ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=workstation.localdomain
[root@workstation ~]#
__________________
Registered Linux User No. 373003
Reply With Quote
Reply

Tags
root@localhostlocaldomain, sendingmail

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
localhost@localdomain inder Using Fedora 5 1st September 2006 04:43 PM
mail woes - root can't send emails mudarra Servers & Networking 1 7th August 2006 06:38 PM
Send a mail with root@hostname as sender (not root) friguyb Servers & Networking 0 10th December 2004 04:06 PM


Current GMT-time: 15:51 (Thursday, 23-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat