(ubuntu ufw)My firewall is blocking network connections from the docker container to outside

Maybe this is due to the current version, but the current answer doesn‘t work on my system (Docker 0.7.2 with base Ubuntu image).

The solution is explained here in the official Docker documentation.

For the lazy ones:

edit /etc/default/ufw to change DEFAULT_FORWARD_POLICY‘s value to "ACCEPT",
    reload with [sudo] ufw reload.

This ensures ufw forward your traffic to the Docker‘s bridged network (as of my current understanding of these things...).

This fixed it for me:

ufw allow in on docker0

Edit /etc/ufw/before.rules as follows:

In the *filter section, after the first block of required lines, add:

# docker rules to enable external network access from the container
# forward traffic accross the bridge
-A ufw-before-forward -i docker0 -j ACCEPT
-A ufw-before-forward -i testbr0 -j ACCEPT
-A ufw-before-forward -m state --state RELATED,ESTABLISHED -j ACCEPT

At the end of the file, after the line that says COMMIT, add the following section:

*nat
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -s 172.16.42.0/8 -o eth0 -j MASQUERADE
# don‘t delete the ‘COMMIT‘ line or these rules won‘t be processed
COMMIT

After saving the file, restart ufw with sudo ufw disable && sudo ufw enable

时间: 2024-08-01 08:42:43

(ubuntu ufw)My firewall is blocking network connections from the docker container to outside的相关文章

Ubuntu ufw防火墙规则顺序问题

本文以Ubuntu 14.04为例,讲讲ufw防火墙规则顺序问题. --------------------------------此处应该优雅的使用分割线-------------------------------- 先说原理再吐槽! Linux系统及其许多其他软件中都有访问控制(Access Control)功能,比如系统中的防火墙,Cisco ios中的ACL(Access Control Lists),Web服务器中的Access Module.在有些访问控制的实现中,有一些访问控制的

Network Connections UVA 793(并查集)

Network Connections Time Limit: 3000ms            Memory Limit: 131072KB [PDF Link]  Network Connections  Bob, who is a network administrator, supervises a network of computers. He is keeping a log connections between the computers in the network. Ea

ubuntu ufw防火墙软件的配置入门

顺便,一条龙作完安全吧. ufw的使用,是比iptables简单.但只能作简单的事儿,更改简单的netfilter里的iptable里的记录.难点的,可能还是得iptables原生命令. 自打2.4版本以后的Linux内核中, 提供了一个非常优秀的防火墙工具.这个工具可以对出入服务的网络数据进行分割.过滤.转发等等细微的控制,进而实现诸如防火墙.NAT等功能. 一般来说, 我们会使用名气比较的大iptables等程序对这个防火墙的规则进行管理.iptables可以灵活的定义防火墙规则, 功能非常

ubuntu ufw

UFW 是Ubuntu下的一个主机端的iptables类防火墙配置工具(底层调用iptables来处理). 这个工具的目的是提供给用户一个可以轻松驾驭的界面,就像包集成和动态检测开放的端口一样. 虽然功能较简单,但对桌面型应用来说比较实用,基本常用功能都有,使用也较为容易. UFW参考: https://help.ubuntu.com/community/UFW http://blog.bodhizazen.net/linux/firewall-ubuntu-servers/ http://bl

ubuntu ufw防火墙简易教程(转)

ufw是一个主机端的iptables类防火墙配置工具,比较容易上手.一般桌面应用使用ufw已经可以满足要求了. 安装方法 sudo apt-get install ufw 当然,这是有图形界面的(比较简陋),在新立得里搜索gufw试试…… 使用方法 1 启用 sudo ufw enable sudo ufw default deny 作用:开启了防火墙并随系统启动同时关闭所有外部对本机的访问(本机访问外部正常). 2 关闭 sudo ufw disable 2 查看防火墙状态 sudo ufw

Ubuntu ufw指令

防火墙 防火墙的本义,是指古代运用木制结构房子时,为防止火灾发生及曼延,(qz66k)人们将石块堆砌在房子周围做为屏障,这种防护修建就被称为防火墙.现代网络时代参照此喻意,指阻隔本机网络与外界网络或是区域网路间与网际网络的一道防御系统,藉由控制.过滤.束缚信息来维护内部网络数据的安全. 用途: 运用者在上网时,常会有个资问题.防火墙防止hacker取得个资 Packet Filtering(封包过滤) 封包过滤就是用一个软件检查所流经封包之标头(header)﹐由此决议整个封包的命运.它或许会决

Uva 793 Network Connections

题目意思是有几台电脑,c开头的行是两个计算机相连,q开头是查询两个是否相连. 思路:并查集. 题目应该可以有几组输入,这是我在algorithm网站上找的样例: 输入: 2 10c 1 5c 2 7q 7 1c 3 9q 9 6c 2 5q 7 5 10c 1 5c 2 7q 7 1c 3 9q 9 6c 2 5q 7 5 输出: 1,2 1,2 1 #include <cstdio> 2 #include <cstring> 3 #include <iostream>

Solve Docker for Windows error: docker detected, A firewall is blocking file Sharing between Windows and the containers

被这个"分享硬盘"问题烦了我好几个小时,终于在一个叫Marco Mansi外国人博客上找到解决方法了,真的很无奈 https://blog.olandese.nl/2017/05/03/solve-docker-for-windows-error-a-firewall-is-blocking-file-sharing-between-windows-and-the-containers/#comment-99

ORA-12528: TNS:listener: all appropriate instances are blocking new connections

Oracle问题:ORA-12528: TNS: 监听程序: 所有适用例程都无法建立新连接 问题原始描述: 发现问题: 通过在CMD下用lsnrctl status 查看出的问题:发现BLOCKED: 然后:尝试启动oracle数据库: [[email protected] ~]# su - oracle Last login: Thu Jul 18 22:01:58 CST 2019 on pts/1 [[email protected] ~]$ sqlplus / as sysdba SQL