Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

ufw default deny incoming

Linux Kernel, Network, and Services configuration.
Post Reply
Message
Author
User avatar
bjorntj
Posts: 11
Joined: 2021-01-25 12:31

ufw default deny incoming

#1 Post by bjorntj »

Hi.

Not sure what I am missing here but I have a Debian 10 server where I am trying to use ufw for my firewall settings.
But the default rule of deny incoming is removed after I reboot my server. If I run "ufw default deny incoming" after I have rebooted, then all ports are denied except for those I have opened. But after a reboot, it seems that the default is set to accept all incoming.

What am I missing here?


Regards,

BTJ
Someone wrote:
"I understand that if you play a Windows CD backwards you hear strange Satanic messages"
To which someone replied:
"It's even worse than that; play it forwards and it installs Windows"

User avatar
Hallvor
Global Moderator
Global Moderator
Posts: 2042
Joined: 2009-04-16 18:35
Location: Kristiansand, Norway
Has thanked: 151 times
Been thanked: 212 times

Re: ufw default deny incoming

#2 Post by Hallvor »

Did you enable it?

Code: Select all

    # ufw enable
    # ufw default deny incoming
    # ufw default allow outgoing
[HowTo] Install and configure Debian bookworm
Debian 12 | KDE Plasma | ThinkPad T440s | 4 × Intel® Core™ i7-4600U CPU @ 2.10GHz | 12 GiB RAM | Mesa Intel® HD Graphics 4400 | 1 TB SSD

User avatar
bjorntj
Posts: 11
Joined: 2021-01-25 12:31

Re: ufw default deny incoming

#3 Post by bjorntj »

Yes, after boot the status says:

Code: Select all

# ufw status verbose

Status: active
Logging: off
Default: deny (incoming), allow (outgoing), disabled (routed)
New profiles: skip

To                         Action      From
--                         ------      ----
more rules
But the deny incoming is not working...
Someone wrote:
"I understand that if you play a Windows CD backwards you hear strange Satanic messages"
To which someone replied:
"It's even worse than that; play it forwards and it installs Windows"

User avatar
dilberts_left_nut
Administrator
Administrator
Posts: 5347
Joined: 2009-10-05 07:54
Location: enzed
Has thanked: 13 times
Been thanked: 66 times

Re: ufw default deny incoming

#4 Post by dilberts_left_nut »

bjorntj wrote:But the deny incoming is not working...
How do you know?
AdrianTM wrote:There's no hacker in my grandma...

User avatar
bjorntj
Posts: 11
Joined: 2021-01-25 12:31

Re: ufw default deny incoming

#5 Post by bjorntj »

Because a port I have specifically opened from just one ip, is open for all ip's...
Running "ufw default deny incoming" after boot, fixes the firewall...
I am not a newbie in this game.. 8)

But I have never used UFW before, maybe it's just better to use iptables....

BTJ
Someone wrote:
"I understand that if you play a Windows CD backwards you hear strange Satanic messages"
To which someone replied:
"It's even worse than that; play it forwards and it installs Windows"

User avatar
bjorntj
Posts: 11
Joined: 2021-01-25 12:31

Re: ufw default deny incoming

#6 Post by bjorntj »

btw, if I compare the iptables rules after boot and after running "ufw default deny incoming", I see the following:

right after boot:

Code: Select all

hain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
after running the deny command:

Code: Select all

Chain INPUT (policy DROP)
target     prot opt source               destination
ufw-before-logging-input  all  --  0.0.0.0/0            0.0.0.0/0
ufw-before-input  all  --  0.0.0.0/0            0.0.0.0/0
ufw-after-input  all  --  0.0.0.0/0            0.0.0.0/0
ufw-after-logging-input  all  --  0.0.0.0/0            0.0.0.0/0
ufw-reject-input  all  --  0.0.0.0/0            0.0.0.0/0
ufw-track-input  all  --  0.0.0.0/0            0.0.0.0/0

Chain FORWARD (policy DROP)
target     prot opt source               destination
ufw-before-logging-forward  all  --  0.0.0.0/0            0.0.0.0/0
ufw-before-forward  all  --  0.0.0.0/0            0.0.0.0/0
ufw-after-forward  all  --  0.0.0.0/0            0.0.0.0/0
ufw-after-logging-forward  all  --  0.0.0.0/0            0.0.0.0/0
ufw-reject-forward  all  --  0.0.0.0/0            0.0.0.0/0
ufw-track-forward  all  --  0.0.0.0/0            0.0.0.0/0

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
ufw-before-logging-output  all  --  0.0.0.0/0            0.0.0.0/0
ufw-before-output  all  --  0.0.0.0/0            0.0.0.0/0
ufw-after-output  all  --  0.0.0.0/0            0.0.0.0/0
ufw-after-logging-output  all  --  0.0.0.0/0            0.0.0.0/0
ufw-reject-output  all  --  0.0.0.0/0            0.0.0.0/0
ufw-track-output  all  --  0.0.0.0/0            0.0.0.0/0
So it seems like the default rules are not applied on boot...
Someone wrote:
"I understand that if you play a Windows CD backwards you hear strange Satanic messages"
To which someone replied:
"It's even worse than that; play it forwards and it installs Windows"

reinob
Posts: 1198
Joined: 2014-06-30 11:42
Has thanked: 99 times
Been thanked: 47 times

Re: ufw default deny incoming

#7 Post by reinob »

I don't have experience with ufw (why don't you use nftables?), but maybe doing a "systemctl status ufw" after boot will tell you if it is enabled and whether it started OK or not.

If not enabled, do "systemctl enable ufw" (assuming there's a ufw.service).

User avatar
bjorntj
Posts: 11
Joined: 2021-01-25 12:31

Re: ufw default deny incoming

#8 Post by bjorntj »

Thx, but as I said, ufw is enabled and running after boot, it's just that the default rules are not applied....
Someone wrote:
"I understand that if you play a Windows CD backwards you hear strange Satanic messages"
To which someone replied:
"It's even worse than that; play it forwards and it installs Windows"

reinob
Posts: 1198
Joined: 2014-06-30 11:42
Has thanked: 99 times
Been thanked: 47 times

Re: ufw default deny incoming

#9 Post by reinob »

OK, can you check if you have /etc/ufw/user.rules and/or /etc/ufw/user6.rules, and if they have the content you'd expect (that's where your rules are supposed to be saved).

I imagine there's no need to ask if you have *another* firewall starting/configuring at boot (nftables, iptables-persistent, etc.) which might be cleaning up what ufw has done while initializing?

User avatar
bjorntj
Posts: 11
Joined: 2021-01-25 12:31

Re: ufw default deny incoming

#10 Post by bjorntj »

No, I don't... And yes, those files exists and looks fine..

But I have been looking at nftables now and I think I will be swithing to nftables instead... Thx.. :)


BTJ
Someone wrote:
"I understand that if you play a Windows CD backwards you hear strange Satanic messages"
To which someone replied:
"It's even worse than that; play it forwards and it installs Windows"

User avatar
Ardouos
Posts: 1077
Joined: 2013-11-03 00:30
Location: Elicoor II
Has thanked: 1 time
Been thanked: 4 times

Re: ufw default deny incoming

#11 Post by Ardouos »

+1 for nftables.

I switched to it after I installed Buster and I was surprised with how simple it was. You can manage it by using commands or directly editing the text file (just be careful with the correct formatting). The main disadvantage as of today is that there is less documentation on it. But that may change due to time.

The wiki if you need to refer to it. Otherwise there are guides online which people have made.
https://wiki.nftables.org/wiki-nftables ... /Main_Page


The link below will drop all incoming whilst allowing connections that your computer has made, as well as loopback.

Simple rules for a desktop:
https://wiki.nftables.org/wiki-nftables ... orkstation
There is only one Debian | Do not break Debian | Stability and Debian | Backports

⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀

User avatar
bjorntj
Posts: 11
Joined: 2021-01-25 12:31

Re: ufw default deny incoming

#12 Post by bjorntj »

Yes, got my rules set up and seems to be working as it should now...
Thx.. :)
Someone wrote:
"I understand that if you play a Windows CD backwards you hear strange Satanic messages"
To which someone replied:
"It's even worse than that; play it forwards and it installs Windows"

reinob
Posts: 1198
Joined: 2014-06-30 11:42
Has thanked: 99 times
Been thanked: 47 times

Re: ufw default deny incoming

#13 Post by reinob »

bjorntj wrote:Yes, got my rules set up and seems to be working as it should now...
Thx.. :)
Good to hear!

The only problem I have with nftables, which I use everywhere (desktop and server) is with docker, as it still depends (in the debian sense) on iptables. You can avoid it by setting "iptables: false" in the daemon.json config, but then you have to set your forwarding rules, etc. by yourself..

User avatar
bjorntj
Posts: 11
Joined: 2021-01-25 12:31

Re: ufw default deny incoming

#14 Post by bjorntj »

ok, good to know... :)
Someone wrote:
"I understand that if you play a Windows CD backwards you hear strange Satanic messages"
To which someone replied:
"It's even worse than that; play it forwards and it installs Windows"

Post Reply