Cannot use iptables on Ubuntu

Hello Guys,

As the title does

I am using Ubuntu 20.04 and I would like to use iptables instead of using ufw

So I disable ufw firewall

root@Ubunserver:~# systemctl stop ufw
root@Ubunserver:~# systemctl disable ufw
root@Ubunserver:~# systemctl mask ufw
root@Ubunserver:~# systemctl is-active ufw
inactive
root@Ubunserver:~#

Then I start and enable iptables

root@Ubunserver:~# systemctl start iptables
Failed to start iptables.service: Unit iptables.service not found.
root@Ubunserver:~#

The outcome told me that I need to install iptables.service. So I tried to run

root@Ubunserver:~# apt install iptables.service
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package iptables.service
E: Couldn't find any package by glob 'iptables.service'
root@Ubunserver:~# apt install iptables.services
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package iptables.services
E: Couldn't find any package by glob 'iptables.services'
root@Ubunserver:~# apt install iptables-services
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package iptables-services
root@Ubunserver:~# apt install iptables-service
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package iptables-service
root@Ubunserver:~#

I could not find the iptables.service to install
So how to fix this?

Thanks!

Maybe try:

apt install iptables

Hi friend,
This is not a solution
iptables is a built-in in both CentOS and Ubuntu
apt install iptables is only install iptable without iptables.services

1 Like

Hello,

What you're seeing here seems to be correct - in Ubuntu 20.04, there is no iptables service as such. The only additional package you probably want to make sure you have installed is iptables-persistent, which should add support for saving iptables rules and loading them at boot time.

Hope this helps !

2 Likes

Hi Savior.

Thank you so much. That what I need :smiley:

2 Likes