在 Linux 虚拟机中关闭防火墙的方法如下:
1. 查看当前防火墙的状态:
- systemd 系统(如 Ubuntu、CentOS 7+):
```
systemctl status firewalld
```
- iptables 系统(如 CentOS 6):
```
service iptables status
```
2. 停止防火墙服务:
- systemd 系统:
```
systemctl stop firewalld
```
- iptables 系统:
```
service iptables stop
```
3. 禁用防火墙开机自启:
- systemd 系统:
```
systemctl disable firewalld
```
- iptables 系统:
```
chkconfig iptables off
```
4. 如果需要永久关闭防火墙,可以删除防火墙相关的配置文件:
- systemd 系统:
```
rm -f /etc/systemd/system/multi-user.target.wants/firewalld.service
```
- iptables 系统:
```
rm -f /etc/init.d/iptables
```
注意,关闭防火墙可能会降低系统的安全性,请根据实际需求谨慎操作。如果只是为了临时测试,建议在使用完毕后重新启用防火墙。