【题目】iptables进行防火墙设置以使得可以访问虚拟机的端口
【时间】2022.03.09 周三
一、问题描述
有的应用在VMWare虚拟机上运行的,想要在物理机上访问对应的应用端口,如flink的web UI(默认端口8081)、tomcat(默认端口8080)等。
由于linux的防火墙限制,往往无法访问,需要使用 iptables命令设置防火墙规则放开端口访问。
2、解决方法:iptables命令设置防火墙放开端口访问
1、查看INPUT链规则
iptables -L INPUT
发现有一条REJECT拒绝的命令:
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT udp -- anywhere anywhere udp dpt:domain
ACCEPT tcp -- anywhere anywhere tcp dpt:domain
ACCEPT udp -- anywhere anywhere udp dpt:bootps
ACCEPT tcp -- anywhere anywhere tcp dpt:bootps
ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
ACCEPT all -- anywhere anywhere
INPUT_direct al