Ubuntu Pastebin

Paste from UFW Help at Wed, 20 Jan 2016 07:53:22 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
## 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...
Download as text