[Beginner] Having trouble setting up my firewall - "conntrack" related errors with iptables and ufw
Hello.
I'd appreciate some help with this. I'm a beginner trying to configure Arch after installing it, but I'm having trouble setting up my firewall. I've already read through the networking/firewall-related Arch wiki pages, but I don't see anything about my problem there.
The first time I encountered this issue was when I was trying to follow the Simple stateful firewall page. In their example setup for a single machine firewall, one of their commands is:
iptables -A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
When I try to run this, it gives me the response iptables: No chain/target/match by that name.. It says on the same page something about "conntrack" being a module that's automatically loaded by the kernel when it's needed, though.
After reading through all the pages, I ultimately decided that I'd like to use ufw to manage it, as it's simpler and easier for me at this stage, and I'm already used to using it through gufw on Ubuntu. I then tried to set up ufw, but then encountered a (seemingly related) issue a second time. When running ufw enable to activate ufw, it gives me the response:
ERROR: problem running ufw-init
modprobe: FATAL: Module nf_conntrack_ftp not found in directory /lib/modules/4.8.8-2-ARCH
modprobe: FATAL: Module nf_nat_ftp not found in directory /lib/modules/4.8.8-2-ARCH
modprobe: FATAL: Module nf_conntrack_netbios_ns not found in directory /lib/modules/4.8.8-2-ARCH
iptables-restore: line 4 failed
iptables-restore: line 77 failed
iptables-restore: line 30 failed
iptables-restore: line 11 failed
Problem running '/etc/ufw/before.rules'
Problem running '/etc/ufw/after.rules'
Problem running '/etc/ufw/user.rules'
This response has the same mention of conntrack again, as well as another module.
Edit: If I run ufw show raw, it prints out the following:
ERROR: IPV4 (raw):
... (info about various default chains / rules) ...
iptables v1.6.0: can't initialize iptables table 'nat': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.
I'm not sure if the above is relevant. I've already updated everything with pacman -Syu though.
Can someone help me with this please? I've already searched around but I can't find anything other than really old posts that don't seem to be relevant anymore. I'm not sure what I need to do to resolve this. This is pretty much a fresh Arch install, by the way.
Thanks.
Edited 24 Nov 2016. We only hold this version.
About this post
- Posted
- Archived
- Edited
- Score
- 2 · 100% up
- Kind
- Text
- ID
- 5elaec
7 comments
Try restarting your computer.
The main issue seems to be that the modules can't be found in the given directory.
Perhaps your kernel has been recently updated from 4.8.8-2 to 4.8.10-1. If that is the case, your modules would no longer be present if you were still running 4.8.8-2.
Thanks! It looks like this was the issue. It's working perfectly fine from a fresh boot. Sorry - I probably should've tried that in the first place. And you're exactly right - I had done an update beforehand, and looking at /var/log/pacman.log now, I did upgrade the kernel from 4.8.8.2 to 4.8.10-1.
I'm still a little bit confused about why this happened though. I thought that it was safe enough to update the kernel, in that it wouldn't interfere with the currently running system and would only be used starting from the next boot. Is this something specific to that particular kernel version, or is this a common issue that I might encounter every time when the kernel updates? Is it a good practice to restart right away after updating the kernel?
When the kernel updates from a version to any new version, it removes the /usr/lib/modules/OLD_VERSION contents. This means that any modules which are already loaded into memory should be fine, but NO new modules (like nf_conntrack for setting up a firewall) will work.
This has always been how arch does it. There may be pacman hooks floating around this subreddit which provide a work around for the modules issue, but really, just always update the kernel when you are ready to reboot, and always reboot when you update the kernel.
I'm not overly practiced with UFW, we prefer to just use IPTables directly (ufw has iptables as a dependency so why bother with an extra package).
I've not seen that error come up with relation to the INPUT chain before, in fact it "shouldn't" be possible, given that the INPUT, FORWARD and OUTPUT chains are meant to be present by default.
So I have a bit of insight as to what might be happening. Can you run the following and reply with the output. You should redact any specific IP addresses or names if the output has it:
Do you have your rules saved somewhere? You might want to try flushing and reapplying the rules:
When you're applying these rules, how do you do so? My guess is saved to a file then
systemctl restart ufw?I find that firewalls are pretty easy once you get them figured out. Lets see if we can't prove that true for you too :)
Thank you very much for taking the time to reply. Sorry for wasting your time - it looks like it was caused by a kernel update I'd installed earlier, and a reboot was all I needed!
Ah, have had my fair share of those. Glad to hear it's working for you now :)