Open & Close a port in a machine

本文详细介绍了如何将WAR文件部署到虚拟机上进行测试或其它目的,并提供了检查与配置防火墙端口的方法,包括使用iptables命令行工具进行端口开放与关闭的具体步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

As a developer, you also need to deploy some war file to a VM  so that yo can have a test or for other aim.

You need to know that the configuration file is located in :/etc/sysconfig/iptables

First, you may want to check whether the port is opened , you can run this command: iptabes -nL,

then you will see all of the opened ports.

After that , there are two ways to open port:

  1. vi /etc/sysconfig/iptables  -> add one more line: -A INPUT -p tcp -m tcp --dport 8889 -j ACCEPT ->/etc/init.d/iptables restart
  2. if you don't want to modify the iptables file, you can simply run the comman: iptables -I INPUT -p tcp --dport 8889 -j ACCEPT

 

You might have a case that need to close a port, then you can :

iptables -I OUTPUT -p tcp --dport 8889 -j DROP     

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值