21

I'm running Ubuntu 18.04 from Windows Bash:

uname -a
Linux DESKTOP-M87DGAS 4.4.0-17134-Microsoft #112-Microsoft Thu Jun 07 22:57:00 PST 2018 x86_64 x86_64 x86_64 GNU/Linux

I need to open some port with:

sudo ufw allow 22/tcp

But I get the following error:

ERROR: initcaps
[Errno 2] iptables v1.6.1: can't initialize iptables table `filter': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.

I get the same error by typing:

iptables -L

I've already upgrade my kernel with:

sudo apt-get update
sudo apt-get full-upgrade

I've tried to reboot the system but it didn't work.

How can I initiate the iptable filter?

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
JohnJohnsonJoe
  • 215
  • 1
  • 2
  • 6

2 Answers2

20

According to the Microsoft WSL page on github.com, iptables isn't supported.

https://github.com/Microsoft/WSL/issues/767

There is a uservoice page for requesting support at

https://wpdev.uservoice.com/forums/266908-command-prompt-console-bash-on-ubuntu-on-windo/suggestions/32025199-support-iptables

Jon
  • 3,573
  • 2
  • 17
  • 24
  • 4
    I'd note that the WSL page on github.com says that WSL now supports iptables in very recent versions, though it is evident some people are still having problems. – Jon Apr 24 '20 at 09:21
  • 6
    Yep, I am trying to run docker on my Windows Bash, and I am having the same error. – Jesus Soto May 08 '20 at 15:47
3

Windows restrict that command in WSL without authorization from administrator.

You just have to run WSL on CMD/Powershell/Ubuntu.exe as administator, then try this command again:

sudo iptables -L -v

I tested on WSL v1, but it should also work on WSL v2.

James Risner
  • 5,451
  • 11
  • 25
  • 47
akez
  • 55
  • 7