# Centos 7 - Docker and FirewallD

**URL:** https://meta.discourse.org/t/centos-7-docker-and-firewalld/32045
**Category:** Self-hosting
**Tags:** docker, email
**Created:** [August 13, 2015, 12:29am UTC](https://meta.discourse.org/t/centos-7-docker-and-firewalld/32045 "2015-08-13T00:29:10Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![nawarei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nawarei/32/44280_2.png) [@nawarei](https://meta.discourse.org/u/nawarei)
#### Post date: [August 13, 2015, 12:29am UTC](https://meta.discourse.org/t/centos-7-docker-and-firewalld/32045/1 "2015-08-13T00:29:10Z")

</div>

Hi,

I am having a issue with Docker when I run FirewallD on my Centos 7 servers, what I have noticed is that when it runs I loss connectivity to the internet as well as my POSTFIX service I have on the host OS(I use this to send emails)

So with my setup I have Nginx running on the host as I am planning on running other sites off the server, that works fine based off the doco I have read.

I am more of an iptables guy as I have used it for years, I have read over what FirewallD can do it is something I want to use on my server.

If anyone can help me with this that would be great 😄

Thanks,

Rei

---

<div class="post-metadata">

### Author: ![AstonJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/astonj/32/215041_2.png) [@AstonJ](https://meta.discourse.org/u/AstonJ)
#### Post date: [August 13, 2015, 12:43am UTC](https://meta.discourse.org/t/centos-7-docker-and-firewalld/32045/2 "2015-08-13T00:43:00Z")

</div>

FirewallD is awesome 🙂

Run `firewall-cmd --get-services ` to get a list of services, then simply add the ones you want, such as:

```plaintext
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --permanent --add-service=pop3s
firewall-cmd --permanent --add-service=smtp

```

List your services with `firewall-cmd --permanent --list-services`

Then restart with `systemctl restart firewalld ` **and check everything is working on your server** , then `systemctl enable firewalld ` to enable and start the firewall on reboot.

Then restart docker with `systemctl restart docker` and if you ever restart the firewall, you need to restart docker.

It’s so easy I love it! 🙂

---

<div class="post-metadata">

### Author: ![nawarei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nawarei/32/44280_2.png) [@nawarei](https://meta.discourse.org/u/nawarei)
#### Post date: [August 13, 2015, 1:02am UTC](https://meta.discourse.org/t/centos-7-docker-and-firewalld/32045/3 "2015-08-13T01:02:21Z")

</div>

Thanks, I will try this when I get home and let you know how I get on.

---

<div class="post-metadata">

### Author: ![nawarei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nawarei/32/44280_2.png) [@nawarei](https://meta.discourse.org/u/nawarei)
#### Post date: [August 15, 2015, 2:27am UTC](https://meta.discourse.org/t/centos-7-docker-and-firewalld/32045/4 "2015-08-15T02:27:24Z")

</div>

I have made the changes and it has helped a bit, what I am getting now is a no route to host from Docker when I try to get it to talk to my SMTP server on my host.

I have added this in but it did not help

```
firewall-cmd --permanent --zone=trusted --add-interface=docker0

```

Any ideas?

---

<div class="post-metadata">

### Author: ![nawarei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nawarei/32/44280_2.png) [@nawarei](https://meta.discourse.org/u/nawarei)
#### Post date: [August 15, 2015, 2:40am UTC](https://meta.discourse.org/t/centos-7-docker-and-firewalld/32045/5 "2015-08-15T02:40:36Z")

</div>

Hi,

Ok I got it going, I needed to add this in as well

```
firewall-cmd --permanent --zone=trusted --add-port=25/tcp

```

Now when you do this you will start getting other issues with docker not being able to resolve DNS etc, so you will need to add those rules in as well.

Regards,

Rei

---

<div class="post-metadata">

### Author: ![AstonJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/astonj/32/215041_2.png) [@AstonJ](https://meta.discourse.org/u/AstonJ)
#### Post date: [August 15, 2015, 12:12pm UTC](https://meta.discourse.org/t/centos-7-docker-and-firewalld/32045/6 "2015-08-15T12:12:58Z")

</div>

Why didn’t just opening the SMTP port work? (You need to restart Docker after starting FirewallD)

_I did not need to do any of those steps in your posts._

---

<div class="post-metadata">

### Author: ![nawarei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nawarei/32/44280_2.png) [@nawarei](https://meta.discourse.org/u/nawarei)
#### Post date: [August 16, 2015, 4:39am UTC](https://meta.discourse.org/t/centos-7-docker-and-firewalld/32045/7 "2015-08-16T04:39:07Z")

</div>

I think it is the fact that I had the SMTP server on the host OS and not some where else, I did some reading about the no route to host issues I was getting from Docker and Firewalld. What I put as the steps I did to get it working was what I read.

Granted as I said the knock on affect of doing what I did was the fact that I need to add all of the required ports in the trusted zone.

It seemed to be the only way I could get what I wanted working.

Cheers,

Rei

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [October 30, 2018, 11:44pm UTC](https://meta.discourse.org/t/centos-7-docker-and-firewalld/32045/8 "2018-10-30T23:44:37Z")

</div>



---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [August 4, 2021, 5:59pm UTC](https://meta.discourse.org/t/centos-7-docker-and-firewalld/32045/9 "2021-08-04T17:59:29Z")

</div>


