0

Ciao! How are you?

​​Problem:
I need 2 interfaces, because the fast ISP blocks 25 port, the slower is open.

​​I can telnet with the required interface:

telnet -b 192.168.81.20 alt2.gmail-smtp-in.l.google.com 25  

Trying 74.125.68.27...
Connected to alt2.gmail-smtp-in.l.google.com.
Escape character is '^]'.
220 mx.google.com ESMTP q14si1562820plk.485 - gsmtp

​The wrong is not working​

telnet -b 192.168.78.20 alt2.gmail-smtp-in.l.google.com 25 

Trying 74.125.68.27...
telnet: Unable to connect to remote host: Connection refused
root@server:/etc/postfix# 

​I got the right settings (smtp_bind_address, the one I need and works with telnet):

​smtp      inet  n       -       y       -       -       smtpd
  -o content_filter=spamassassin
​​  -o smtp_bind_address=192.168.81.1

submission inet n       -       y       -       -       smtpd
  -o syslog_name=postfix/submission
  -o smtpd_tls_security_level=encrypt
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
​​  -o smtp_bind_address=192.168.81.1
smtps     inet  n       -       y       -       -       smtpd
  -o syslog_name=postfix/smtps
  -o smtpd_tls_wrappermode=yes
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
​​  -o smtp_bind_address=192.168.81.1

​Still, I get this error:​

Jun 07 13:19:04 server postfix/smtp[10823]: connect to alt1.gmail-smtp-in.l.google.com[108.177.14.27]:25: Connection refused
Jun 07 13:19:04 server postfix/smtp[10823]: connect to alt1.gmail-smtp-in.l.google.com[2a00:1450:4010:c0f::1b]:25: Network is unreachable
Jun 07 13:19:05 server postfix/smtp[10823]: connect to alt2.gmail-smtp-in.l.google.com[74.125.68.27]:25: Connection refused
Jun 07 13:19:05 server postfix/smtp[10823]: C625334017A: to=<alabard@gmail.com>, relay=none, delay=12983, delays=12976/0.01/7.4/0, dsn=4.4.1, status=deferred (connect to alt2.gmail-smtp-in.l.google.com[74.125.68.27]:25: Connection refused)
​

​The settings are correct, why I get connection refused?
If you know, thanks so much!
Ciao!​

More:

Routing:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.78.1    0.0.0.0         UG    10     0        0 enp2s0
0.0.0.0         192.168.81.1    0.0.0.0         UG    30     0        0 enp1s0
192.168.78.0    0.0.0.0         255.255.255.0   U     0      0        0 enp2s0
192.168.81.0    0.0.0.0         255.255.255.0   U     0      0        0 enp1s0

Ifconfig:

enp1s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.81.20  netmask 255.255.255.0  broadcast 192.168.81.255
        inet6 fe80::9ade:d0ff:fe04:23c3  prefixlen 64  scopeid 0x20<link>
        ether 98:de:d0:04:23:c3  txqueuelen 1000  (Ethernet)
        RX packets 265  bytes 49826 (48.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 104  bytes 25251 (24.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.78.20  netmask 255.255.255.0  broadcast 192.168.78.255
        inet6 fe80::eeaa:a0ff:fe1b:4d84  prefixlen 64  scopeid 0x20<link>
        ether ec:aa:a0:1b:4d:84  txqueuelen 1000  (Ethernet)
        RX packets 4733  bytes 850839 (830.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4911  bytes 934827 (912.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 8049  bytes 3219724 (3.0 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 8049  bytes 3219724 (3.0 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

my.conf

# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = ESMTP mail.patrikx3.tk
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# See http://www.postfix.org/COMPATIBILITY_README.html -- default to 2 on
# fresh installs.
compatibility_level = 2

# TLS parameters
#smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
#smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
#smtpd_use_tls=yes
#smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
#smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

smtpd_tls_cert_file= /etc/ssl/acme/patrikx3.tk/fullchain.cer
smtpd_tls_key_file=/etc/ssl/acme/patrikx3.tk/patrikx3.tk.key
smtpd_use_tls=yes
smtpd_tls_auth_only = yes

smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes

smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination, check_policy_service unix:private/policyd-spf

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

#smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination

myhostname = mail.patrikx3.tk
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = localhost
relayhost = 
mynetworks = 127.0.0.0/8
# 5 gigabyt
mailbox_size_limit = 5368709120
# 50 megabyte
message_size_limit = 52428800
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
virtual_transport = lmtp:unix:private/dovecot-lmtp
virtual_mailbox_domains = mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf
virtual_alias_maps = mysql:/etc/postfix/mysql-virtual-alias-maps.cf

# spf
policyd-spf_time_limit = 3600

#opendkim
smtpd_milters = inet:127.0.0.1:8891
non_smtpd_milters = $smtpd_milters
milter_default_action = accept
milter_protocol = 2

The required interface has route as well:

iface enp1s0 inet dhcp 
        metric 30 
        post-up ip route add 192.168.81.0/24 dev enp1s0 src 192.168.81.20 table rt2 
        post-up ip route add default via 192.168.81.1 dev enp1s0 table rt2 
        post-up ip rule add from 192.168.81.20/32 table rt2 
        post-up ip rule add to 192.168.81.20/32 table rt2
  • Please add to the post the configs about routing email (to gmail?), and the output of netstat -nr – Rui F Ribeiro Jun 7 '17 at 11:48
  • thanks so much! what is the about routing email? – Patrik Laszlo Jun 7 '17 at 12:00
  • I would advise adding to the question your main.cf file. – Rui F Ribeiro Jun 7 '17 at 12:01
  • i added, thanks so much if you understand the problem – Patrik Laszlo Jun 7 '17 at 12:07
  • 2
    You cannot have two default gateways working at the same time magically...and by far the metrics of 192.168.78.1 say it is winning; you need an iptables rule for diverting the traffic of port 25. Also running SMTP servers from residential ISPs, wether their port 25 is open or not, is not a good idea for several reasons, one of them is that the reverse DNS name of the IP of the public address wont match your DNS name. Such setup has been prone to failure for at least one decade or more, due to measures to fight zombie machines spewing spam. I ran an ISP 10 years ago, and I also blocked SMTP – Rui F Ribeiro Jun 7 '17 at 12:27
1

Actually , the problem was that I was settings for the listening settings, so instead of ,master.cf, i just had to add it into master.cf like this:

smtp_bind_address=192.168.81.20

And that's it, perfect and works all the time!!!! :) So simple! Postfix email listing helped me!

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.