immauss / openvas

Containers for running the Greenbone Vulnerability Manager. Run as a single container with all services or separate single applications containers via docker-compose.
GNU Affero General Public License v3.0
360 stars 102 forks source link

SMTP issue? #121

Closed killmasta93 closed 2 years ago

killmasta93 commented 2 years ago

Hi I was wondering if someone could shed some light on the email alerts

Currently on my host i have postfix installed and this is my main.cf

# See /usr/share/postfix/main.cf.dist for a commented, more complete version

# 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 = $myhostname ESMTP $mail_name (Ubuntu)
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

alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = $myhostname, proxy.casa.local, localhost.casa.local, , localhost
relayhost = 192.168.3.140:27
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
recipient_delimiter = +
inet_interfaces = loopback-only
inet_protocols = all
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/password
smtp_sasl_security_options =

and i test the config and i get the email

echo "My message" | mail -s subject alerts@domain.com

now on the container this is my docker compose

version: "3"
services:
  openvas:
    ports:
      - "8080:9392"
    environment:
      - "PASSWORD=mypass"
      - "USERNAME=admin"
      - "RELAYHOST=172.17.0.1"
      - "SMTPPORT=27"
      - "REDISDBS=512" # number of Redis DBs to use
      - "QUIET=false"  # dump feed sync noise to /dev/null
      - "NEWDB=false"  # only use this for creating a blank DB 
      - "SKIPSYNC=true" # Skips the feed sync on startup.
      - "RESTORE=false"  # This probably not be used from compose... see docs.
      - "DEBUG=false"  # This will cause the container to stop and not actually start gvmd
      - "HTTPS=false"  # wether to use HTTPS or not
      - "GMP=9390"    # to enable see docs
    volumes:
      - "/openvas:/data"
    container_name: openvas
    image: immauss/openvas:latest
  scannable:
    image: immauss/scannable
    container_name: scannable
volumes:
  openvas:

i run the test alert alert on openvas it says it works but i get no email

Thank you

killmasta93 commented 2 years ago

Hi @immauss so i changed the port to 25 because on the host it seems that port is 25


master       1203            root   13u  IPv4   25720      0t0  TCP 127.0.0.1:25 (LISTEN)
master       1203            root   14u  IPv6   25721      0t0  TCP [::1]:25 (LISTEN)

but still cant seemed to get it working

Thank you

farzadha2 commented 2 years ago

Hi any updates on this im also having the same issue? @immauss

Thank you

immauss commented 2 years ago

Start by checking the mailq in the container.

docker exec -it mailq

If the container mailq is empty, (It should be.) then check the mailq on the host.

Also, look in the mail logs on the host and see if there are any clues there.

If the emails are getting stuck in the queue on the host, you'll need to fix that first.

If they are getting stuck on the container, let me know and I "might" be able to help you out.

-Scott

killmasta93 commented 2 years ago

Thank you so much for the reply, currently in my container im getting this the emails are getting stuck in the container

image

immauss commented 2 years ago

From this, it looks like the problem is on the host. Make sure you have firewall rules in place to allow the connection and that the host postfix is listening on the docker0 interface ip.

-Scott

killmasta93 commented 2 years ago

thank you for the reply, so this is what i did on the docker container i used nmap to check if the port i opened which it is

ssh on the docker container

root@5d48b03b445d:/# nmap -p 25 172.17.0.1
Starting Nmap 7.80 ( https://nmap.org ) at 2022-06-19 22:01 UTC
Nmap scan report for proxy (172.17.0.1)
Host is up (0.00020s latency).

PORT   STATE SERVICE
25/tcp open  smtp

Nmap done: 1 IP address (1 host up) scanned in 0.35 seconds
root@5d48b03b445d:/# 

on my host i changed the postfix main.cf to this

inet_interfaces = localhost, 172.17.0.1
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 172.18.0.0/16

but still cant seem to get it working not sure what else i need

killmasta93 commented 2 years ago

it seemed i needed to also add this which solved the issue

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated reject_unauth_destination

immauss commented 2 years ago

Awesome! My "postfix foo" is not that great. Glad you worked it out! Thanks for the follow up too.

-Scott