LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 06-10-2021, 07:36 PM   #1
MilkTea
LQ Newbie
 
Registered: Nov 2013
Location: PA, USA
Distribution: Debian Squeeze
Posts: 28

Rep: Reputation: Disabled
[UFW BLOCK] in dmesg


I have a rather strange problem that I couldn't figure out. On my server, I only enabled port 22 for SSH and port 6000 for an application. The default policies were deny incoming, allow outgoing, and deny routed. I noticed a bunch of [UFW BLOCK] from some external peers and the STP is 6000.

I couldn't figure out why ufw blocked those traffic, I changed the default for incoming to allow. Well, it didn't help. I then changed the default for routed to also allow. So now all incoming, outgoing, and routed are allowed. Still, I am seeing [UFW BLOCK] growing whenever I check dmesg.

I thought by allowing all is essentially not blocking anything. Why does ufw still block the incoming traffic?
 
Old 06-11-2021, 01:44 AM   #2
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 17,264
Blog Entries: 10

Rep: Reputation: 5172Reputation: 5172Reputation: 5172Reputation: 5172Reputation: 5172Reputation: 5172Reputation: 5172Reputation: 5172Reputation: 5172Reputation: 5172Reputation: 5172
Quote:
Originally Posted by MilkTea View Post
I have a rather strange problem that I couldn't figure out. On my server, I only enabled port 22 for SSH and port 6000 for an application. The default policies were deny incoming, allow outgoing, and deny routed. I noticed a bunch of [UFW BLOCK] from some external peers and the STP is 6000.

I couldn't figure out why ufw blocked those traffic, I changed the default for incoming to allow. Well, it didn't help. I then changed the default for routed to also allow. So now all incoming, outgoing, and routed are allowed. Still, I am seeing [UFW BLOCK] growing whenever I check dmesg.

I thought by allowing all is essentially not blocking anything. Why does ufw still block the incoming traffic?
Did you 'ufw reload' after making those changes?

Show us the (relevant part of the) logs, show us ufw configuration, e.g. 'ufw status verbose'.
Use code tags for code & command output (see my signature).
 
Old 06-11-2021, 08:02 AM   #3
MilkTea
LQ Newbie
 
Registered: Nov 2013
Location: PA, USA
Distribution: Debian Squeeze
Posts: 28

Original Poster
Rep: Reputation: Disabled
Yes, I did reload the rules. I, at one point, even restarted ufw service.
Here is a portion of dmesg -T
Code:
[Fri Jun 11 08:55:44 2021] [UFW BLOCK] IN=enp3s0 OUT= MAC=3c:7c:3f:21:e5:f0:00:f4:59:68:50:54:08:00 SRC=77.xx.yy.62 DST=192.168.2.2 LEN=40 TOS=0x00 PREC=0x00 TTL=51 ID=0 DF PROTO=TCP SPT=6000 DPT=48942 WINDOW=0 RES=0x00 RST URGP=0
[Fri Jun 11 08:55:44 2021] [UFW BLOCK] IN=enp3s0 OUT= MAC=3c:7c:3f:21:e5:f0:00:f4:59:68:50:54:08:00 SRC=77.xx.yy.62 DST=192.168.2.2 LEN=40 TOS=0x00 PREC=0x00 TTL=51 ID=0 DF PROTO=TCP SPT=6000 DPT=48942 WINDOW=0 RES=0x00 RST URGP=0
[Fri Jun 11 08:55:44 2021] [UFW BLOCK] IN=enp3s0 OUT= MAC=3c:7c:3f:21:e5:f0:00:f4:59:68:50:54:08:00 SRC=77.xx.yy.62 DST=192.168.2.2 LEN=40 TOS=0x00 PREC=0x00 TTL=51 ID=0 DF PROTO=TCP SPT=6000 DPT=48942 WINDOW=0 RES=0x00 RST URGP=0
[Fri Jun 11 08:55:44 2021] [UFW BLOCK] IN=enp3s0 OUT= MAC=3c:7c:3f:21:e5:f0:00:f4:59:68:50:54:08:00 SRC=77.xx.yy.62 DST=192.168.2.2 LEN=40 TOS=0x00 PREC=0x00 TTL=51 ID=0 DF PROTO=TCP SPT=6000 DPT=48942 WINDOW=0 RES=0x00 RST URGP=0
From ufw status verbose
Code:
Status: active
Logging: on (low)
Default: allow (incoming), allow (outgoing), allow (routed)
New profiles: skip

To                         Action      From
--                         ------      ----
443/tcp                    ALLOW IN    Anywhere
6000/tcp                  ALLOW IN    Anywhere
22/tcp (OpenSSH)           ALLOW IN    Anywhere
443                        ALLOW IN    Anywhere
443/tcp (v6)               ALLOW IN    Anywhere (v6)
6000/tcp (v6)             ALLOW IN    Anywhere (v6)
22/tcp (OpenSSH (v6))      ALLOW IN    Anywhere (v6)
443 (v6)                   ALLOW IN    Anywhere (v6)
 
Old 06-12-2021, 03:28 AM   #4
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 17,264
Blog Entries: 10

Rep: Reputation: 5172Reputation: 5172Reputation: 5172Reputation: 5172Reputation: 5172Reputation: 5172Reputation: 5172Reputation: 5172Reputation: 5172Reputation: 5172Reputation: 5172
Hmmm. My Default reads "deny (incoming), allow (outgoing), disabled (routed)" - yours reads like no firewall at all, tbh.
But I'm no expert.
I also get confused by SPT= and DPT= ...
Anyhow, it looks like it should be working (comparing to my own ufw setup where I succesfully punched some holes).

Only thing more stricter is that you specified the tcp protocol, so check out if your application uses only tcp.

Could it be that it's not UFW or your system's firewall at all, but your router instead?
I always have to open a port both on the server's firewall and the router.
 
Old 06-12-2021, 09:11 AM   #5
MilkTea
LQ Newbie
 
Registered: Nov 2013
Location: PA, USA
Distribution: Debian Squeeze
Posts: 28

Original Poster
Rep: Reputation: Disabled
As mentioned, it was "deny (incoming), allow (outgoing), disabled (routed)". I was trying to test why ufw blocked the incoming traffic so I changed it to "allow". The strange things is, like you pointed out, this is essentially no firewall. However, ufw still blocks some incoming traffic.

I believe SPT stands for "source port" and DPT stands for "destination port". So basically the incoming packets were from source:6000. From the message, I also think that opening only tcp should be sufficient. The block packages were using tcp (PROTO=TCP).

I have a physical firewall. However, since the dmesg says "[UFW BLOCK]", I think it is from ufw.

At this point, I have turned off ufw on my server because I have a physical firewall and this server is inside a private network. I don't think it is a huge concern from being attached from outside. The only ports that are opened, as you can see, are 443, 6000, and 22.

I simply want to learn and understand why ufw is blocking those packages.
 
Old 06-13-2021, 02:50 AM   #6
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 17,264
Blog Entries: 10

Rep: Reputation: 5172Reputation: 5172Reputation: 5172Reputation: 5172Reputation: 5172Reputation: 5172Reputation: 5172Reputation: 5172Reputation: 5172Reputation: 5172Reputation: 5172
Maybe start with a fresh ufw profile.
Should default to deny incoming.
Then read the docs, and try punching a hole again.
Keep in mind that ufw has different commands to add opening rules: "allow,insert,prepend" and obviously they do different things.

Last edited by ondoho; 06-13-2021 at 02:55 AM.
 
  


Reply

Tags
firewall, ufw


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between ouput of dmesg and content of /var/log/dmesg Sayan Acharjee Linux - General 1 09-21-2011 10:42 AM
dmesg vs /var/log/dmesg drManhattan Linux - Newbie 2 08-07-2011 05:28 AM
UFW block on legitimate ports peridot121 Linux - Security 5 07-06-2010 07:21 PM
dmesg (command) and /var/log/dmesg are different? Oxagast Linux - Software 2 07-10-2006 05:50 AM
/bin/dmesg > /dmesg-boot not Working in Knoppix 3.4 suguru Debian 2 07-04-2004 05:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 11:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration