This comment has made me very intrigued, but at the same time quite confused.
On this link you provided, it states the following:
By default, managed LXD bridges add firewall rules to ensure full functionality. If you do not run another firewall on your system, you can let LXD manage its firewall rules.
Since I never touched this, I’m assuming lxd
added firewall rules somewhere. But where are they?
They don’t seem to be on iptables
.
$ sudo iptables -vL
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
19671 1180K ACCEPT tcp -- any any 10.0.0.0/16 anywhere tcp dpt:8443 state NEW /* Victor: allow lxd cluster */
14M 3167M ACCEPT all -- any any anywhere anywhere state RELATED,ESTABLISHED
3 252 ACCEPT icmp -- any any anywhere anywhere
7456 696K ACCEPT all -- lo any anywhere anywhere
0 0 ACCEPT udp -- any any anywhere anywhere udp spt:ntp
1599 88360 ACCEPT tcp -- any any anywhere anywhere state NEW tcp dpt:ssh
2327 745K REJECT all -- any any anywhere anywhere reject-with icmp-host-prohibited
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 REJECT all -- any any anywhere anywhere reject-with icmp-host-prohibited
Chain OUTPUT (policy ACCEPT 14M packets, 2945M bytes)
pkts bytes target prot opt in out source destination
28208 2161K InstanceServices all -- any any anywhere link-local/16
Chain InstanceServices (1 references)
pkts bytes target prot opt in out source destination
0 0 ACCEPT tcp -- any any anywhere 169.254.0.2 owner UID match root tcp dpt:iscsi-target /* See the Oracle-Provided Images section in the Oracle Cloud Infrastructure documentation for security impact of modifying or removing this rule */
0 0 ACCEPT tcp -- any any anywhere 169.254.2.0/24 owner UID match root tcp dpt:iscsi-target /* See the Oracle-Provided Images section in the Oracle Cloud Infrastructure documentation for security impact of modifying or removing this rule */
0 0 ACCEPT tcp -- any any anywhere 169.254.4.0/24 owner UID match root tcp dpt:iscsi-target /* See the Oracle-Provided Images section in the Oracle Cloud Infrastructure documentation for security impact of modifying or removing this rule */
0 0 ACCEPT tcp -- any any anywhere 169.254.5.0/24 owner UID match root tcp dpt:iscsi-target /* See the Oracle-Provided Images section in the Oracle Cloud Infrastructure documentation for security impact of modifying or removing this rule */
0 0 ACCEPT tcp -- any any anywhere 169.254.0.2 tcp dpt:http /* See the Oracle-Provided Images section in the Oracle Cloud Infrastructure documentation for security impact of modifying or removing this rule */
4731 505K ACCEPT udp -- any any anywhere 169.254.169.254 udp dpt:domain /* See the Oracle-Provided Images section in the Oracle Cloud Infrastructure documentation for security impact of modifying or removing this rule */
0 0 ACCEPT tcp -- any any anywhere 169.254.169.254 tcp dpt:domain /* See the Oracle-Provided Images section in the Oracle Cloud Infrastructure documentation for security impact of modifying or removing this rule */
0 0 ACCEPT tcp -- any any anywhere 169.254.0.3 owner UID match root tcp dpt:http /* See the Oracle-Provided Images section in the Oracle Cloud Infrastructure documentation for security impact of modifying or removing this rule */
0 0 ACCEPT tcp -- any any anywhere 169.254.0.4 tcp dpt:http /* See the Oracle-Provided Images section in the Oracle Cloud Infrastructure documentation for security impact of modifying or removing this rule */
23376 1648K ACCEPT tcp -- any any anywhere 169.254.169.254 tcp dpt:http /* See the Oracle-Provided Images section in the Oracle Cloud Infrastructure documentation for security impact of modifying or removing this rule */
4 1216 ACCEPT udp -- any any anywhere 169.254.169.254 udp dpt:bootps /* See the Oracle-Provided Images section in the Oracle Cloud Infrastructure documentation for security impact of modifying or removing this rule */
0 0 ACCEPT udp -- any any anywhere 169.254.169.254 udp dpt:tftp /* See the Oracle-Provided Images section in the Oracle Cloud Infrastructure documentation for security impact of modifying or removing this rule */
97 7372 ACCEPT udp -- any any anywhere 169.254.169.254 udp dpt:ntp /* See the Oracle-Provided Images section in the Oracle Cloud Infrastructure documentation for security impact of modifying or removing this rule */
0 0 REJECT tcp -- any any anywhere link-local/16 tcp /* See the Oracle-Provided Images section in the Oracle Cloud Infrastructure documentation for security impact of modifying or removing this rule */ reject-with tcp-reset
0 0 REJECT udp -- any any anywhere link-local/16 udp /* See the Oracle-Provided Images section in the Oracle Cloud Infrastructure documentation for security impact of modifying or removing this rule */ reject-with icmp-port-unreachable
And then I checked if ufw
was running, as you mentioned. I get contradicting results when I run systemctl status
and when I run ufw status
.
$ systemctl status ufw.service
● ufw.service - Uncomplicated firewall
Loaded: loaded (/lib/systemd/system/ufw.service; enabled; vendor preset: enabled)
Active: active (exited) since Sun 2022-07-10 11:53:03 UTC; 2 days ago
Docs: man:ufw(8)
Main PID: 735 (code=exited, status=0/SUCCESS)
CPU: 2ms
Jul 10 11:53:03 arm1 systemd[1]: Starting Uncomplicated firewall...
Jul 10 11:53:03 arm1 systemd[1]: Finished Uncomplicated firewall.
$ sudo ufw status
Status: inactive
It seems to me like the service is running but it’s disabled. So I think it should be equivalent to it not running. At this point I thought lxd
added those rules on ufw
to allow traffic between the container and the host, but since ufw
is disabled, they will not work.
Now since this is running on Oracle Cloud, it’s important to read their recommendation on best practices which is here.
But now there’s an issue. The provided link mentions on how to add the proper rules to fix this problem using firewalld
or ufw
, but Oracle recommends the usage of iptables
. The same link also provides an iptables
command, but only to fix an issue with docker
which is also not installed.
Does anyone know the iptables
rule to fix this problem?
Just a side note, I thought I could figure it out if I found the rules lxd
added automatically to fix this problem and I thought they would be on ufw
.
$ sudo ufw show added
Added user rules (see 'ufw status' for running firewall):
(None)
Since this returned nothing, I found this post which mentions an alternative way. It told me to check one of 3 files and they all have the exact same content as the following.
$ sudo cat /etc/ufw/user.rules
*filter
:ufw-user-input - [0:0]
:ufw-user-output - [0:0]
:ufw-user-forward - [0:0]
:ufw-user-limit - [0:0]
:ufw-user-limit-accept - [0:0]
### RULES ###
-A ufw-user-limit -m limit --limit 3/minute -j LOG --log-prefix "[UFW LIMIT BLOCK] "
-A ufw-user-limit -j REJECT
-A ufw-user-limit-accept -j ACCEPT
COMMIT
So did lxd
add firewall rules to ensure full functionality?