Loading ...
Sorry, an error occurred while loading the content.

Using postfix in CentOS 6 to relay mails to First.Last@gmail.com

Expand Messages
  • Alexander Farber
    Hello, I m using: # cat /etc/*release CentOS release 6.3 (Final) # rpm -qa | grep post postfix-2.6.6-2.2.el6_1.x86_64 on 2 servers: preferans.de and (yes,
    Message 1 of 12 , Jan 15, 2013
    • 0 Attachment
      Hello, I'm using:

      # cat /etc/*release
      CentOS release 6.3 (Final)

      # rpm -qa | grep post
      postfix-2.6.6-2.2.el6_1.x86_64

      on 2 servers: preferans.de and (yes, funny name)
      static.103.78.9.176.clients.your-server.de

      I own several domains and would like all
      incoming mails addressing those domains
      to be forwarded to my Gmail address.

      So I have setup the MX-records for my domains:

      # host videoskat.de
      videoskat.de has address 176.9.40.169
      videoskat.de mail is handled by 100 static.103.78.9.176.clients.your-server.de.
      videoskat.de mail is handled by 10 preferans.de.

      # host balkan-preferans.de
      balkan-preferans.de has address 176.9.40.169
      balkan-preferans.de mail is handled by 100
      static.103.78.9.176.clients.your-server.de.
      balkan-preferans.de mail is handled by 10 preferans.de.

      And at the both servers I have added:

      # head /etc/postfix/virtual
      @... First.Last@...
      @... First.Last@...

      # postmap /etc/postfix/virtual

      # postmap -q "@..." /etc/postfix/virtual
      First.Last@...

      And have opened port 25 in the firewall:

      # grep -w 25 /etc/sysconfig/iptables
      -A INPUT -p tcp -m state --state NEW -m tcp -m multiport --dports
      25,22 -j ACCEPT

      But now when I send a mail to spam@...
      there is nothing to see in postfix logs:

      # sudo tail /var/log/maillog
      Jan 15 10:50:42 postfix/postfix-script[1401]: starting the Postfix mail system
      Jan 15 10:50:42 postfix/master[1402]: daemon started -- version 2.6.6,
      configuration /etc/postfix

      So I'm probably missing something?

      BTW the daily logwatch mails arrive
      from both servers just fine at my
      Gmail-mailbox First.Last@...

      Thank you for any hints
      Alex
    • Wietse Venema
      ... Nothing happens unless a connection is made. Does tcpdump show any connections coming to your system at TCP port 25? Wietse
      Message 2 of 12 , Jan 15, 2013
      • 0 Attachment
        Alexander Farber:
        > And have opened port 25 in the firewall:
        >
        > # grep -w 25 /etc/sysconfig/iptables
        > -A INPUT -p tcp -m state --state NEW -m tcp -m multiport --dports
        > 25,22 -j ACCEPT
        >
        > But now when I send a mail to spam@...
        > there is nothing to see in postfix logs:

        Nothing happens unless a connection is made. Does tcpdump
        show any connections coming to your system at TCP port 25?

        Wietse
      • Alexander Farber
        Thanks for replying - ... sorry for the stupid question, but how to use tcpdump to check for incoming connections? I ve come up only with these commands sofar:
        Message 3 of 12 , Jan 15, 2013
        • 0 Attachment
          Thanks for replying -

          On Tue, Jan 15, 2013 at 1:55 PM, Wietse Venema <wietse@...> wrote:
          > Alexander Farber:
          >> And have opened port 25 in the firewall:
          >>
          >> But now when I send a mail to spam@...
          >> there is nothing to see in postfix logs:
          >
          > Nothing happens unless a connection is made. Does tcpdump
          > show any connections coming to your system at TCP port 25?

          sorry for the stupid question, but how to use
          tcpdump to check for incoming connections?

          I've come up only with these commands sofar:

          # netstat -an |grep -w 25
          tcp 0 0 127.0.0.1:25 0.0.0.0:*
          LISTEN

          # iptables -L|grep -w smtp
          ACCEPT tcp -- anywhere anywhere state NEW
          tcp multiport dports smtp,ssh

          Thanks
          Alex
        • Reindl Harald
          ... tcpdump shows you the complete network-traffic why not simply start it and lokk what it does? ... how do you imagine connections from outside if you
          Message 4 of 12 , Jan 15, 2013
          • 0 Attachment
            Am 15.01.2013 14:10, schrieb Alexander Farber:
            > Thanks for replying -
            >
            > On Tue, Jan 15, 2013 at 1:55 PM, Wietse Venema <wietse@...> wrote:
            >> Alexander Farber:
            >>> And have opened port 25 in the firewall:
            >>>
            >>> But now when I send a mail to spam@...
            >>> there is nothing to see in postfix logs:
            >>
            >> Nothing happens unless a connection is made. Does tcpdump
            >> show any connections coming to your system at TCP port 25?
            >
            > sorry for the stupid question, but how to use
            > tcpdump to check for incoming connections?

            tcpdump shows you the complete network-traffic
            why not simply start it and lokk what it does?

            > I've come up only with these commands sofar:
            >
            > # netstat -an |grep -w 25
            > tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN

            how do you imagine connections from outside if you configure
            a daemon only listen on loopback device?

            P.S.: why cross posting on CentOS-list?
          • Eliezer Croitoru
            ... The first problem is that you are not listening on the right IP address. use: inet_interfaces = all instead of what you have. And I recommend you to learn
            Message 5 of 12 , Jan 15, 2013
            • 0 Attachment
              On 1/15/2013 3:10 PM, Alexander Farber wrote:
              > sorry for the stupid question, but how to use
              > tcpdump to check for incoming connections?
              >
              > I've come up only with these commands sofar:
              >
              > # netstat -an |grep -w 25
              > tcp 0 0 127.0.0.1:25 0.0.0.0:*
              > LISTEN
              >
              > # iptables -L|grep -w smtp
              > ACCEPT tcp -- anywhere anywhere state NEW
              > tcp multiport dports smtp,ssh
              >
              > Thanks
              > Alex

              The first problem is that you are not listening on the right IP address.
              use:
              inet_interfaces = all

              instead of what you have.

              And I recommend you to learn a bit more about linux basics.

              Best regards,
              Eliezer
            • Alexander Farber
              Thank you, I ve come a bit further - ... I ve added this line to /etc/postfix/main.cf inet_interfaces = all and now I see in the /var/log/maillog: Jan 15
              Message 6 of 12 , Jan 15, 2013
              • 0 Attachment
                Thank you, I've come a bit further -

                On Tue, Jan 15, 2013 at 2:15 PM, Eliezer Croitoru <eliezer@...> wrote:
                > The first problem is that you are not listening on the right IP address.
                > use:
                > inet_interfaces = all

                I've added this line to /etc/postfix/main.cf

                inet_interfaces = all

                and now I see in the /var/log/maillog:

                Jan 15 14:25:36 postfix/smtpd[2965]: connect from
                static.114.69.9.176.clients.your-server.de[176.9.69.114]
                Jan 15 14:25:36 postfix/smtpd[2965]: NOQUEUE: reject: RCPT from
                static.114.69.9.176.clients.your-server.de[176.9.69.114]: 554 5.7.1
                <test6@...>: Relay access denied; from=<afarber@...>
                to=<test6@...> proto=ESMTP helo=<www>
                Jan 15 14:25:39 postfix/smtpd[2965]: disconnect from
                static.114.69.9.176.clients.your-server.de[176.9.69.114]

                Regards
                Alex
              • Reindl Harald
                ... so the domain videoskat.de is not listed in your postfix config mydestination local_recipient_maps did you read any documentation or are you starting
                Message 7 of 12 , Jan 15, 2013
                • 0 Attachment
                  Am 15.01.2013 14:31, schrieb Alexander Farber:
                  > Thank you, I've come a bit further -
                  >
                  > On Tue, Jan 15, 2013 at 2:15 PM, Eliezer Croitoru <eliezer@...> wrote:
                  >> The first problem is that you are not listening on the right IP address.
                  >> use:
                  >> inet_interfaces = all
                  >
                  > I've added this line to /etc/postfix/main.cf
                  >
                  > inet_interfaces = all
                  >
                  > and now I see in the /var/log/maillog:
                  >
                  > Jan 15 14:25:36 postfix/smtpd[2965]: connect from
                  > static.114.69.9.176.clients.your-server.de[176.9.69.114]
                  > Jan 15 14:25:36 postfix/smtpd[2965]: NOQUEUE: reject: RCPT from
                  > static.114.69.9.176.clients.your-server.de[176.9.69.114]: 554 5.7.1
                  > <test6@...>: Relay access denied; from=<afarber@...>
                  > to=<test6@...> proto=ESMTP helo=<www>
                  > Jan 15 14:25:39 postfix/smtpd[2965]: disconnect from
                  > static.114.69.9.176.clients.your-server.de[176.9.69.114]

                  so the domain "videoskat.de" is not listed in your postfix config

                  mydestination
                  local_recipient_maps

                  did you read any documentation or are you starting blindly
                  from the centos-defaults and try to figure all knowledge
                  out auf mailing-lists? this will not work in most cases!
                • Alexander Farber
                  Hello - ... Actually yes I do start blindly from centos 6 default config. Because docs are huge and I don t even know for what *keywords* to look there. I.e.
                  Message 8 of 12 , Jan 15, 2013
                  • 0 Attachment
                    Hello -

                    On Tue, Jan 15, 2013 at 2:36 PM, Reindl Harald <h.reindl@...> wrote:
                    > so the domain "videoskat.de" is not listed in your postfix config
                    >
                    > mydestination
                    > local_recipient_maps
                    >
                    > did you read any documentation or are you starting blindly
                    > from the centos-defaults and try to figure all knowledge
                    > out auf mailing-lists? this will not work in most cases!

                    Actually yes I do start blindly from centos 6 default config.

                    Because docs are huge and I don't even know
                    for what *keywords* to look there.

                    I.e. what is the name for my setup (trying to forward
                    mails addressed to other domains) - is it "virtual smth."?

                    And also since Gmail is involved I believe it is always
                    a good idea to ask at the mailing lists first -
                    because they do special things sometimes.

                    Regards
                    Alex
                  • Wietse Venema
                    ... Start here: http://www.postfix.org/BASIC_CONFIGURATION_README.html Wietse
                    Message 9 of 12 , Jan 15, 2013
                    • 0 Attachment
                      Alexander Farber:
                      > Hello -
                      >
                      > On Tue, Jan 15, 2013 at 2:36 PM, Reindl Harald <h.reindl@...> wrote:
                      > > so the domain "videoskat.de" is not listed in your postfix config
                      > >
                      > > mydestination
                      > > local_recipient_maps
                      > >
                      > > did you read any documentation or are you starting blindly
                      > > from the centos-defaults and try to figure all knowledge
                      > > out auf mailing-lists? this will not work in most cases!
                      >
                      > Actually yes I do start blindly from centos 6 default config.
                      >
                      > Because docs are huge and I don't even know
                      > for what *keywords* to look there.

                      Start here:

                      http://www.postfix.org/BASIC_CONFIGURATION_README.html

                      Wietse
                    • Alexander Farber
                      Hello - ... with CentOS 6 I ve ended up adding inet_interfaces = all virtual_alias_domains = videoskat.de balkan-preferans.de to /etc/postfix/main.cf and
                      Message 10 of 12 , Jan 16, 2013
                      • 0 Attachment
                        Hello -

                        On Tue, Jan 15, 2013 at 3:05 PM, Wietse Venema <wietse@...> wrote:
                        > http://www.postfix.org/BASIC_CONFIGURATION_README.html

                        with CentOS 6 I've ended up adding

                        inet_interfaces = all
                        virtual_alias_domains = videoskat.de balkan-preferans.de

                        to /etc/postfix/main.cf and

                        @... First.Last@...
                        @... First.Last@...

                        to /etc/postfix/virtual and then

                        # postmap /etc/postfix/virtual
                        # service reload postfix

                        I've found that in
                        http://www.postfix.org/VIRTUAL_README.html#virtual_alias

                        Thanks
                        Alex
                      • Wietse Venema
                        ... You don t need virtual_alias_domains for this, but it does not hurt. ... The above wild-cards are sufficient to forward entire domains to gmail. HOWEVER,
                        Message 11 of 12 , Jan 16, 2013
                        • 0 Attachment
                          Alexander Farber:
                          > Hello -
                          >
                          > On Tue, Jan 15, 2013 at 3:05 PM, Wietse Venema <wietse@...> wrote:
                          > > http://www.postfix.org/BASIC_CONFIGURATION_README.html
                          >
                          > with CentOS 6 I've ended up adding
                          >
                          > inet_interfaces = all
                          > virtual_alias_domains = videoskat.de balkan-preferans.de

                          You don't need virtual_alias_domains for this, but it does not hurt.

                          > to /etc/postfix/main.cf and
                          >
                          > @... First.Last@...
                          > @... First.Last@...
                          >
                          > to /etc/postfix/virtual and then

                          The above wild-cards are sufficient to forward entire domains to gmail.

                          HOWEVER, there is one problem that you need to be aware of. If your
                          machine forwards SPAM to gmail, then gmail will decide that your
                          server is a spammer. Gmail may then file "good" mail from your
                          machine to the spam folder. That happened when my wife forwarded
                          all her mail from work to gmail.

                          > # postmap /etc/postfix/virtual
                          > # service reload postfix
                          >
                          > I've found that in
                          > http://www.postfix.org/VIRTUAL_README.html#virtual_alias

                          You did a good job of reading.

                          Wietse
                        • Alexander Farber
                          Hello Wietse - ... thank you for your software and the advice! I ll read up more on spam filtering and I ve changed the /etc/postfix/virtual to hold certain
                          Message 12 of 12 , Jan 18, 2013
                          • 0 Attachment
                            Hello Wietse -

                            On Wed, Jan 16, 2013 at 2:43 PM, Wietse Venema <wietse@...> wrote:
                            > Alexander Farber:
                            > HOWEVER, there is one problem that you need to be aware of. If your
                            > machine forwards SPAM to gmail, then gmail will decide that your
                            > server is a spammer. Gmail may then file "good" mail from your
                            > machine to the spam folder. That happened when my wife forwarded
                            > all her mail from work to gmail.
                            >
                            >> # postmap /etc/postfix/virtual
                            >> # service reload postfix
                            >>
                            >> I've found that in
                            >> http://www.postfix.org/VIRTUAL_README.html#virtual_alias
                            >
                            > You did a good job of reading.

                            thank you for your software and the advice!

                            I'll read up more on spam filtering and
                            I've changed the /etc/postfix/virtual to
                            hold certain addresses instead of wildcards

                            wXXXbmaster@... First.Last@...
                            wXXXbmaster@... First.Last@...

                            Also I've registered the above addresses
                            as my "Send mail as:" in Gmail-settings -
                            maybe it will like them better then ;-)

                            Regards
                            Alex
                          Your message has been successfully submitted and would be delivered to recipients shortly.