iptables 打开端口_如何在iptables中打开端口?

iptables 打开端口

How to open a port, say 3389, in iptables to allow incoming traffics to it?

如何在iptables中打开一个端口(例如3389),以允许传入流量到该端口?

There are several cases for this question: ipv4 or ipv6 or both, TCP or UDP or both and which interface?

这个问题有几种情况:ipv4或ipv6或两者,TCP或UDP或两者,以及哪个接口?

For simplicity, I give commands to allow all (ipv4 and ipv6, TCP and UDP from all interfaces) using port 3389 as an example. You may choose which ones to be used. For other ports, replace 3389 with the port you want to open.

为简单起见,我以端口3389为例给出命令以允许所有命令(所有接口的ipv4和ipv6,TCP和UDP)。 您可以选择要使用的那些。 对于其他端口,将3389替换为要打开的端口。

# allow TCP ipv4
iptables -I INPUT -p tcp --dport 3389 -j ACCEPT
# allow UDP ipv4
iptables -I INPUT -p udp --dport 3389 -j ACCEPT
# allow TCP ipv6
ip6tables -I INPUT -p tcp --dport 3389 -j ACCEPT
# allow UDP ipv6
ip6tables -I INPUT -p udp --dport 3389 -j ACCEPT

Note that the rules are in memory only after these commands and will be lost after Linux reboots. If you would like to make it permanent (take effect after reboot), please check How to make iptables/ip6tables configurations permanent across reboot on CentOS 7 Linux? .

请注意,只有在执行这些命令后,规则才会在内存中 ,并且在Linux重新引导后将丢失。 如果您想使其永久( 重新启动后生效),请检查如何在CentOS 7 Linux上重新启动时使iptables / ip6tables配置永久?

翻译自: https://www.systutorials.com/how-to-open-a-port-in-iptables/

iptables 打开端口

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值