## get a target ##
dig gmail.com M
dig alt1.gmail-smtp-in.l.google.com.
=> for a smtp server:
74.125.130.26
74.125.136.26
Test without UFW enabled:
telnet 74.125.130.26 25
Trying 74.125.130.26...
Connected to 74.125.130.26.
Escape character is '^]'.
220 mx.google.com ESMTP 21si38598486ioe.191 - gsmtp
helo
250 mx.google.com at your service
quit
221 2.0.0 closing connection 21si38598486ioe.191 - gsmtp
Connection closed by foreign host.
## Enable UFW Deny all out and all but ssh in ##
sudo ufw allow ss
sudo ufw default deny incoming
sudo ufw default deny outgoing
sudo ufw status verbose
Status: active
Logging: on (low)
Default: deny (incoming), deny (outgoing), deny (routed)
New profiles: skip
To Action From
-- ------ ----
22 ALLOW IN Anywhere
22 (v6) ALLOW IN Anywhere (v6)
## Retest (should be blocked now) ##
telnet 74.125.130.26 25
Trying 74.125.130.26...
yes blocked
## now open up just to this address port 25 ##
sudo ufw allow out proto tcp to 74.125.130.26 port 25
Rule added
sudo ufw status verbose
Status: active
Logging: on (low)
Default: deny (incoming), deny (outgoing), deny (routed)
New profiles: skip
To Action From
-- ------ ----
22 ALLOW IN Anywhere
22 (v6) ALLOW IN Anywhere (v6)
74.125.130.26 25/tcp ALLOW OUT Anywhere
telnet 74.125.130.26 25
Trying 74.125.130.26...
Connected to 74.125.130.26.
Escape character is '^]'.
220 mx.google.com ESMTP qi3si11408425pac.30 - gsmtp
helo
250 mx.google.com at your service
quit
221 2.0.0 closing connection qi3si11408425pac.30 - gsmtp
Connection closed by foreign host.
Still blocked 2nd IP as it should be
telnet 74.125.136.26 25
Trying 74.125.136.26...