LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 10-28-2004, 12:43 PM   #1
Cagao
LQ Newbie
 
Registered: Oct 2004
Posts: 11

Rep: Reputation: 0
Hostname Issues : Linux Gateway


I have a main server(192.168.1.1 + external IP) (running Mandrake 10), this has a static IP, with a registered domain name, running DNS, Apache, etc.

Everything is working fine, mainly, but when I send email from the server they appear as me@whatever.mydomain.com

I've recently changed servers (old one running Mandrake 9), the old server worked fine, but i've changed settings on both and can't remember exactly what I've changed on the old server, stupid I know for not keeping backups.

I have another Linux box (192.168.1.2), and a Windows machine (192.168.1.3), these 2 machines don't have public IP's.

For the sake of this question, let's say I have the following names for my machines...

Main Server : myserver.mydomain.com
Other Linux Box : oldserver
Windows Machine : windowsmachine

I need to know what I should have in files such as...

/etc/hosts
/etc/sysconfig/network

and also my sendmail.cf.

I've read many HowTo's but can't find anything that answers what I need.

Thanks in advance for anyone that can help.

Cheers,

Rob

Last edited by Cagao; 10-29-2004 at 02:50 AM.
 
Old 10-29-2004, 02:51 AM   #2
Cagao
LQ Newbie
 
Registered: Oct 2004
Posts: 11

Original Poster
Rep: Reputation: 0
ttt

ttt
 
Old 10-29-2004, 11:26 AM   #3
blish_blash
Member
 
Registered: Dec 2003
Posts: 68

Rep: Reputation: 15
Quote:
Everything is working fine, mainly, but when I send email from the server they appear as me@whatever.mydomain.com
What is wrong with that? what would you want it to be?
 
Old 10-29-2004, 12:05 PM   #4
Cagao
LQ Newbie
 
Registered: Oct 2004
Posts: 11

Original Poster
Rep: Reputation: 0
I want emails to come from me@mydomain.com, not me@mysubdomain.mydomain.com.

I don't receive mails sent to that address, or to me@mydomain.com, whereas on my old server I did.

I'm just after some examples from of what my network config files should look like for my setup.
 
Old 10-29-2004, 12:29 PM   #5
blish_blash
Member
 
Registered: Dec 2003
Posts: 68

Rep: Reputation: 15
could /etc/hosts do the trick?
 
Old 10-29-2004, 12:32 PM   #6
blish_blash
Member
 
Registered: Dec 2003
Posts: 68

Rep: Reputation: 15
in my /etc/hosts there is a line:
192.168.0.60 scenic.ronsdomain scenic

I would guess it should look like this in your case:

<external-ip> mydomain.com

Hope that helps...
Cheers,
Ron
 
Old 10-29-2004, 03:22 PM   #7
Cagao
LQ Newbie
 
Registered: Oct 2004
Posts: 11

Original Poster
Rep: Reputation: 0
Currently i have...

<my ip> mysub.mydomain.com mysub

i'm not sure if that's the problem (wouldn't have thought so), so prob looking into problem with /etc/sysconfig/network

Or maybe other config files I've forgotten about.
 
Old 10-29-2004, 06:56 PM   #8
blish_blash
Member
 
Registered: Dec 2003
Posts: 68

Rep: Reputation: 15
I would give it a try... change the your host name to a one without the subdomain, restart sendmail and try... it might work.
 
Old 10-29-2004, 11:53 PM   #9
scowles
Member
 
Registered: Sep 2004
Location: Texas, USA
Distribution: Fedora
Posts: 620

Rep: Reputation: 31
Quote:
Originally posted by Cagao
Currently i have...

<my ip> mysub.mydomain.com mysub

i'm not sure if that's the problem (wouldn't have thought so), so prob looking into problem with /etc/sysconfig/network

Or maybe other config files I've forgotten about.
The format you have in your hosts file is correct. A copy/paste from the man pages on the format of /etc/hosts
Code:
IP_address canonical_hostname aliases
Now, from the man pages (README) on sendmail...
Code:
+-----------+
| WHO AM I? |
+-----------+
 
Normally, the $j macro is automatically defined to be your fully 
qualified domain name (FQDN).  Sendmail does this by getting your
host name using gethostname and then calling gethostbyname on the 
result.  For example, in some environments gethostname returns 
only the root of the host name (such as "foo"); gethostbyname is
supposed to return the FQDN ("foo.bar.com").  In some (fairly rare)
cases, gethostbyname may fail to return the FQDN.  In this case 
you MUST define confDOMAIN_NAME to be your fully qualified domain 
name.  This is usually done using: 
 
        Dmbar.com 
        define(`confDOMAIN_NAME', `$w.$m')dnl
Based on your problem description in your first post, sendmail "properly" derived its FQDN. So changing the above sendmail settings or your /etc/hosts file are not necessary. I included the above for reference.

To verify your systems hostname and domain name are properly configured, type:
Code:
[scowles@voyager mail]$ hostname --fqdn                                         
voyager.mydomain.com
[scowles@voyager mail]$ hostname --domain                                       
mydomain.com
[scowles@voyager mail]$ hostname --short                                       
voyager

[scowles@voyager mail]$ sendmail -bt -d0.1 </dev/null                           
Version 8.12.10
 Compiled with: DNSMAP HESIOD HES_GETMAILHOST LDAPMAP LOG MAP_REGEX
                MATCHGECOS MILTER MIME7TO8 MIME8TO7 NAMED_BIND NETINET NETINET6
                NETUNIX NEWDB NIS PIPELINING SASLv2 SCANF STARTTLS TCPWRAPPERS
                USERDB USE_LDAP_INIT
 
============ SYSTEM IDENTITY (after readcf) ============
      (short domain name) $w = voyager
  (canonical domain name) $j = voyager.mydomain.com
         (subdomain name) $m = mydomain.com
              (node name) $k = voyager.mydomain.com
========================================================

[root@voyager mail]# cd /etc
[root@voyager etc]# cat /etc/hosts
127.0.0.1       localhost.localdomain   localhost
192.168.9.3     voyager.mydomain.com  voyager
Obvioulsy your hostname and domain name will be different, but the output format from the above commands should be identical. If its not... DO NOT PASS GO, DO NOT COLLECT $200! Fix your systems hostname/resover lib configuration prior to configuring sendmail to add the domain name instead of the fdqn. See: man hostname

Finally, the problem you describe in your post has to do with how sendmail handles a "from" address that is not fully qualified. i.e. From: scowles instead of From: scowles@mydomain.com Sendmail is always going to add the derived FQDN it obtained at startup to any NON-FQDN "from" e-mail address. A NON-FQDN e-mail address usually happens with cronjobs or when using the "mail command.

With the above in mind, there are a couple of ways to configure sendmail to NOT add the FQDN to NON-FQDN e-mail addresses. Implement one or the other, not both.

1) Global solution - Enable the sendmail feature "MASQUERADE AS" by...

* add the following two lines to your sendmail.mc file.
Code:
MASQUERADE_AS(`mydomain.com')dnl
FEATURE(masquerade_envelope)dnl
* Create the new sendmail.cf file
Code:
# cd /etc/mail
# m4 sendmail.mc >sendmail.cf
* restart sendmail and test

Note: The root account is never masqueraded becuase it should be listed as an "exposed" user (as it should be). So root cronjobs will still have the from address set to root@hostname.mydomain.com, not root@mydomain.com, but all other accounts should now appear as user@mydomain.com when submitted locally.

2) Per user - Enable the sendmail genericstable feature.

* add the following two lines to /etc/mail/sendmail.mc. I added them after the "virtusertable" lines.
Code:
FEATURE(`genericstable',`hash /etc/mail/genericstable.db')dnl
GENERICS_DOMAIN_FILE(`/etc/mail/generics-domains')dnl
* create the following two files:
Code:
# cd /etc/mail
# touch genericstable generics-domains
* in the genericstable file, add the users you want to rewite with the domain name.
Code:
# cat /etc/mail/genericstable
scowles      scowles@mydomain.com
* In /etc/mail/generics-domains, add your systems fqdn. Basically, only e-mails that are submitted from the entries (FQDN) listed in this file will be re-written.
Code:
# cat /etc/mail/generocs-domains
hostname.mydomain.com
* Now create the genericstable database.
Code:
# cd /etc/mail
makemap hash genericstable.db <genericstable
* Restart sendmail and test
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Hostname change issues sfwalter Linux - Networking 1 10-29-2004 03:50 PM
Mail - Hostname issues ?? init Linux - Networking 1 08-23-2004 05:05 AM
hostname issues diwakergupta Linux - Networking 3 02-01-2004 12:44 AM
Hostname issues drxsmurf Mandriva 1 01-24-2004 01:23 PM
OpenBSD Hostname and Mail Issues R4z0r *BSD 1 11-30-2002 07:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 08:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration