LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Hostname Issues : Linux Gateway (https://www.linuxquestions.org/questions/linux-networking-3/hostname-issues-linux-gateway-248425/)

Cagao 10-28-2004 12:43 PM

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

Cagao 10-29-2004 02:51 AM

ttt
 
ttt

blish_blash 10-29-2004 11:26 AM

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?

Cagao 10-29-2004 12:05 PM

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.

blish_blash 10-29-2004 12:29 PM

could /etc/hosts do the trick?

blish_blash 10-29-2004 12:32 PM

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

Cagao 10-29-2004 03:22 PM

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.

blish_blash 10-29-2004 06:56 PM

I would give it a try... change the your host name to a one without the subdomain, restart sendmail and try... it might work.

scowles 10-29-2004 11:53 PM

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


All times are GMT -5. The time now is 10:04 AM.