1. 程式人生 > >linux 下剛裝入centos 防火牆情況

linux 下剛裝入centos 防火牆情況

1:檢查是否安裝iptables防火牆:

[[email protected] bin]# service iptables status
Redirecting to /bin/systemctl status  iptables.service
iptables.service
   Loaded: not-found (Reason: No such file or directory)

   Active: inactive (dead)

2:沒有安裝的話預設使用的是firewall作為防火牆,所以把他停掉,安裝一個iptables

[[email protected] sysconfig]# systemctl stop firewalld 
[[email protected] sysconfig]# systemctl mask firewalld 
ln -s '/dev/null' '/etc/systemd/system/firewalld.service'
[[email protected] sysconfig]# yum install -y iptables    (安裝iptables)
已載入外掛:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.cn99.com
 * updates: mirrors.njupt.edu.cn
正在解決依賴關係
--> 正在檢查事務
---> 軟體包 iptables.x86_64.0.1.4.21-13.el7 將被 升級

---> 軟體包 iptables.x86_64.0.1.4.21-24.1.el7_5 將被 更新

[[email protected] sysconfig]# systemctl start iptables.service
[[email protected] sysconfig]# systemctl enable iptables.service   //設定開機自啟
ln -s '/usr/lib/systemd/system/iptables.service' '/etc/systemd/system/basic.target.wants/iptables.service'
[

[email protected] sysconfig]# service iptables status  //狀態
Redirecting to /bin/systemctl status  iptables.service
iptables.service - IPv4 firewall with iptables
   Loaded: loaded (/usr/lib/systemd/system/iptables.service; enabled)
   Active: active (exited) since 四 2018-07-12 23:58:08 CST; 47s ago
 Main PID: 17625 (code=exited, status=0/SUCCESS)

[[email protected] sysconfig]# vi /etc/sysconfig/iptables  //新增開放埠