Welcome to the Linux Foundation Forum!

IPTables and Virtual Servers


I have both Dedicated Servers and Virtual Ubuntu servers (containers). IPTables are similar on all of them. However the syslogs on Virtual Servers do not indicate 'iptables denied' messages, but the Dedicated servers do.
Could this be, because IPTables cannot use net-filters in the kernel ?


  • afmorielo
    afmorielo Posts: 9
    edited October 2021

    My personal experience with containers - Docker, more precisely - has led me to configure package filtering using IPTables. However, rules for the containers are set on the host and not on the containers themselves.

    Check your IPTables rules on your host machine. You will probably see the following chains:

    • DOCKER

    You will see that Docker auto creates several IPTables rules that allow the containers, that exist in a virtual world inside the host machine, to access the network. The DOCKER-USER chain is initially empty, and is where you would define your extra user-specific filtering rules. DOCKER-USER rules precede the DOCKER chain rules.

    For instance, if you want to allow input on port 80 on the containers you would use a rule similar to this one:

    //enp0s3 is the host machine interface
    iptables -A DOCKER-USER -i enp0s3 -p tcp -m conntrack --ctorigdstport 80 --ctdir ORIGINAL -j ACCEPT

    You can read more here: https://docs.docker.com/network/iptables/


Upcoming Training