1. 程式人生 > >centos 7 中防火牆的關閉問題

centos 7 中防火牆的關閉問題

新安裝的centos 7 發現有些程式埠是關閉的,想到了防火牆和selinux  selinx 好關閉 /etc/sysconfig/selinux 中 追加 SELINUX=disabled 防火牆以為也是很好弄,按照以前的老規矩,service iptables stop 或者 chkconfig --level 35 iptables off  重啟後 執行 systemctl list-unit-files | grep ip  發現還有個ip6tables 沒關  chkconfig --level 35 ip6tables off 再執行 systemctl list-unit-files | grep ip 發現全部都disables 還是不通 沒辦法,只有新增規則了,tptables -I INPUT 1 -p tcp --dport 6259 -j ACCEPT  然後service iptables save  埠通了 我想這個是不是個BUG , 也許我沒有找到方法,請告知 Centos7中的防火牆調整為firewalld,試一下systemctl stop firewalld關閉防火牆。



I installed CentOS 7 with minimal configuration (os + dev tools). I am trying to open 80 port for httpdservice, but something wrong with my iptables service ... what's wrong with it? What am I doing wrong?

# ifconfig/sbin/service iptables save
bash: ifconfig/sbin/service: No such file or directory


# /sbin/service iptables save
The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.

# sudo service iptables status
Redirecting to /bin/systemctl status  iptables.service
iptables.service
   Loaded: not-found (Reason: No such file or directory)
   Active: inactive (dead)

# /sbin/service iptables save
The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.

# sudo service iptables start
Redirecting to /bin/systemctl start  iptables.service
Failed to issue method call: Unit iptables.service failed to load: No such file or directory.


With RHEL 7 / CentOS 7, firewalld was introduced to manage iptables. IMHO, firewalld is more suited for workstations than for server environments.

It is possible to go back to a more classic iptables setup. First, stop and mask the firewalld service:
 

systemctl stop firewalld
systemctl mask firewalld

Then, install the iptables-services package:

yum install iptables-services

Enable the service at boot-time:

systemctl enable iptables

Managing the service

systemctl [stop|start|restart] iptables

Saving your firewall rules can be done as follows:

service iptables save

or

/usr/libexec/iptables/iptables.init save
第三種辦法

[[email protected] ~]# service iptables status

防火牆已停

[[email protected] ~]# service iptables start

[[email protected] ~]# service iptables status

防火牆已停

解決方法:

一、初始化iptables。

iptables -F

service iptables save

service iptables restart

vi /etc/sysconfig/iptables

二、把預置的iptables規則新增進去就可以了:

# Firewall configuration written by system-config-securitylevel

# Manual customization of this file is not recommended.

*filter

:INPUT ACCEPT [0:0]

:FORWARD ACCEPT [0:0]

:OUTPUT ACCEPT [0:0]

:RH-Firewall-1-INPUT - [0:0]

-A INPUT -j RH-Firewall-1-INPUT

-A FORWARD -j RH-Firewall-1-INPUT

-A RH-Firewall-1-INPUT -i lo -j ACCEPT

-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT

-A RH-Firewall-1-INPUT -p 50 -j ACCEPT

-A RH-Firewall-1-INPUT -p 51 -j ACCEPT

-A RH-Firewall-1-INPUT -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT

-A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT

-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 631 -j ACCEPT

-A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT

-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited

COMMIT

相關推薦

centos 7 防火牆關閉問題

新安裝的centos 7 發現有些程式埠是關閉的,想到了防火牆和selinux  selinx 好關閉 /etc/sysconfig/selinux 中 追加 SELINUX=disabled 防火牆以為也是很好弄,按照以前的老規矩,service iptable

CentOS 7.0如何關閉防火牆

CentOS 7.0預設使用的是firewall作為防火牆,使用iptables必須重新設定一下 1、直接關閉防火牆 systemctl stop firewalld.service #停止firewall systemctl disable firewalld.service&nb

CentOS 7firewall防火牆詳解和配置以及切換為iptables防火牆

原文連結:http://blog.csdn.net/xlgen157387/article/details/52672988 一、firewall介紹 CentOS 7中防火牆是一個非常的強大的功能,在CentOS 6.5中在iptables防火牆中進行了升級了。

如何在 CentOS 7 安裝、配置和安全加固 FTP 服務

cte success fire lease 註意 tps tran sub linux 步驟 1:安裝 FTP 服務器 1、 安裝 vsftpd 服務器很直接,只要在終端運行下面的命令。 # yum install vsftpd 2、 安裝完成後,服務先是被禁用的,因

CentOS-7安裝與配置Tomcat8.5

ane dsc 配置 pub add ted tar.gz 分享 cal 第一步:下載Tomcat8.5,通過地址:http://tomcat.apache.org/download-80.cgi下載 最後得到下載文件 apache-tomcat-8.5.15.tar.g

CentOS 7一些參數的設定

linux1、設置時區timedatectl list-timezones #列出所有時區 timedatectl set-local-rtc 1 #將硬件時鐘調整為與本地時鐘一致,0為設置為UTC時間 timedatectl set-timezone Asia/Shan

centos 7安裝phpmyadmin

sys 3.2 管理系 https art start ges 數據庫管理系統 執行 安裝phpmyadmin數據庫管理系統//1.下載phpmyadmin包wget https://files.phpmyadmin.net/phpMyAdmin/4.7.0/phpMyA

CentOS 7Nginx1.9.5編譯安裝教程systemctl啟動

pat align temp prefix 軟件 復制代碼 all automake 軟件目錄 先安裝gcc 等 yum -y install gcc gcc-c++ wget 復制代碼 .然後裝一些庫 yum -y install gcc wget automa

centos 7 conda 環境和Python2.7 安裝遠程jupyter

配置 pass 準備 pen env conda 其他 nbsp 隔離 折騰了半天,為了能夠方便學習TensorFlow,搞了遠程的jupyter,方便在本地使用它,今天填了不少坑。 裝完後截圖: 下面是一些步驟: 檢查 Python 環境 CentOS 7

Centos 7安裝二進制數據庫mariadb最新版本

mysql 數據庫 mariadb 安裝二進制數據庫 my.conf 一:實驗背景;在馬哥教育學習到MYSQL這章時,留作業練習的實驗二:實驗準備;1、先檢查虛擬機上是否存在mariadb: rpm -qa mariadb*,若有的話,則卸載;2、通過yum info mariadb查

CentOS 7以runfile形式安裝CUDA 9.0

more tex egl ttr rom pack nvi black ons GPU: NVIDIA Tesla K40C Enter the ‘root‘ mode: $ su - 1. Pre-installation 1.1 Verify you have a

centos 7安裝nginx並配置nginx反向代理

nginx linux proxy 反向代理 Nginx是一款輕量級的Web 服務器/反向代理服務器及電子郵件(IMAP/POP3)代理服務器,並在一個BSD-like 協議下發行。其特點是占有內存少,並發能力強,事實上nginx的並發能力確實在同類型的網頁服務器中表現較好,中國大陸使用ngi

CentOS 7 打開關閉FirewallD防火墻端口命令

new 協議 font accept 作用 com etc 鏈接 state CentOS 7 使用firewalld代替了原來的iptables,使用方法如下: >>>關閉防火墻 systemctl stop firewalld.service

CentOS 7mariadb編譯安裝教程systemctl啟動

mysqld complete 復制 sin 安裝包 useradd 雲盤 http limit mariadb做為mysql的替代品 現在centos的新版本yum包已換成mariadb 跟上篇一樣只是啟動方式改為systemd安裝一些庫 yum install g

Centos 7的網卡一致性命名規則

ron dell服務器 guide 技術 grub -i udev gid sysconfig 一致性網絡設備命名,即Consistent Network Device Naming 一、為什麽需要這個 服務器通常有多塊網卡,有板載集成的,同時也有插在PCIe插槽的。 Li

CentOS 7基於rpm包方式安裝部署apm(php-fpm) + xcache

基於rpm包方式安裝部署apmCentOS 7, 基於rpm包方式安裝部署apm(php-fpm) + xcache;a) httpd, php, mariadb分別部署在一個單獨的主機上;b) 一個虛擬主機提供phpMyAdmin,另一個虛擬主機提供wordpress;c) 為phpMyAdmim提供htt

CentOS 7 使用NTP進行時間同步

clock disabled tle pda Language 網絡 using interface var 1. NTP時鐘同步方式說明NTP在linux下有兩種時鐘同步方式,分別為直接同步和平滑同步: 直接同步 使用ntpdate命令進行同步,直接進行時間變更。如果服務

CentOS 7 Docker 的安裝

-i 控制臺 HA emctl art doc kcon sta 捕獲 CentOS 7 中 Docker 的安裝 Docker 軟件包已經包括在默認的 CentOS-Extras 軟件源裏。因此想要安裝 docker,只需要運行下面的 yum 命令: [roo

CentOS 7使用VS Code編譯調試C++項目

ace found target makefile mic ext false format 指定 1. 安裝VSCODE 見VSCode官方鏈接 https://code.visualstudio.com/docs/setup/linux#_rhel-fedora-an

CentOS 7搭建KVM虛擬化平臺

創建虛擬機 防火 數量 默認 ESS rep 環境準備 linu 工具 什麽是虛擬化 虛擬化就是把硬件資源從物理方式轉變為邏輯方式,打破原有物理結構,使用戶可以靈活管理這些資源,並且允許1臺物理機上同時運行多個操作系統,以實現資源利用率最大化和靈活管理的一項技術。 虛擬化的