1.设置selinux端口

[root@hn ~]# semanage port -l|grep ssh
-bash: semanage: 未找到命令
[root@hn ~]# whereis semanage
semanage:

缺少semanage,需要安装net-tools (这个包同时还包含了ifconfig,否则只能用ip addr看了~)

[root@hn ~]# yum install net-tools
[root@hn ~]# semanage port -l|grep ssh
-bash: semanage: 未找到命令

安装后还是提示未找到,还需要安装policycoreutils-python

[root@hn ~]# yum -y install policycoreutils-python

[root@hn ~]# semanage port -l|grep ssh
ssh_port_t tcp 22
[root@hn ~]# semanage port -a -t ssh_port_t -p tcp 12345
[root@hn ~]# semanage port -l|grep ssh
ssh_port_t tcp 12345, 22

如果要添加mysql端口,可以: semanage port -a -t mysqld_port_t -p tcp 3306

2.设置firewalld里的端口(特定ip参考:http://www.z4zr.com/page/1006.html, 更多可参考: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7-Beta/html/Security_Guide/sec-Using_Firewalls.html)

[root@hn ~]# systemctl status firewalld
firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled)
Active: active (running) since 六 2015-10-17 15:51:47 CST; 3h 5min ago
Main PID: 807 (firewalld)
CGroup: /system.slice/firewalld.service
└─807 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid 10月 17 15:51:46 hn.kd.ny.adsl systemd[1]: Starting firewalld - dynamic firewall daemon...
10月 17 15:51:47 hn.kd.ny.adsl systemd[1]: Started firewalld - dynamic firewall daemon.
[root@hn ~]# firewall-cmd --zone=public --add-port=12345/tcp --permanent
success
[root@hn ~]# firewall-cmd --query-port=12345/tcp
no
[root@hn ~]# systemctl reload firewalld
[root@hn ~]# firewall-cmd --query-port=12345/tcp
FirewallD is not running
[root@hn ~]# firewall-cmd --query-port=12345/tcp
FirewallD is not running
[root@hn ~]# systemctl start firewalld
[root@hn ~]# firewall-cmd --query-port=12345/tcp
yes

如果添加mysql端口,使其可局部访问,则:firewall-cmd --zone=public --add-rich-rule="rule family="ipv4" source address="192.168.0.4/24" port protocol="tcp" port="3306" accept" --permanent

3.修改sshd_config中的Port

[root@hn ~]# vi /etc/ssh/sshd_config

Port 12345
[root@hn ~]# systemctl restart  sshd.service

4.测试  

  

centos7通过firewalld更改sshd端口的更多相关文章

  1. CentOS7使用firewalld防火墙配置端口

    安装启用firewalld防火墙 CentOS7默认的防火墙是firewalld 如果没有firewalld防火墙,可以执行yum install firewalld 命令进行安装 firewalld ...

  2. centos7安装Jenkins更改默认端口并配置Ldap服务器进行用户认证

    应用环境:Jenkins是一个开源软件项目,是基于Java开发的一种持续集成工具,用于监控持续重复的工作.   Jenkins官网:https://jenkins.io/ 测试环境:一台Centos ...

  3. CentOS7为firewalld添加开放端口及相关操作

    1.firewalld的基本使用 启动: systemctl start firewalld 查看状态: systemctl status firewalld 停止: systemctl disabl ...

  4. CentOS7为firewalld添加开放端口

    运行.停止.禁用firewalld 启动:# systemctl start  firewalld 查看状态:# systemctl status firewalld 或者 firewall-cmd ...

  5. CentOS7 为firewalld添加开放端口

    1.运行.停止.禁用firewalld 启动:# systemctl start  firewalld 查看状态:# systemctl status firewalld 或者 firewall-cm ...

  6. centos7更改远程端口

    centos7更改远程端口 一.创建个普通账户(useradd work),给普通账户创建密码(password work) 二.查看应有的软件是否安装 1.查看semanager是否安装执行下面命令 ...

  7. CentOS7使用firewalld打开关闭防火墙与端口(转载)

    1.firewalld的基本使用 启动: systemctl start firewalld 查看状态: systemctl status firewalld 停止: systemctl disabl ...

  8. 关于学习CentOS7使用firewalld打开关闭防火墙和端口

    1.firewalld简介 firewalld是centos7的一大特点,主要有两个优点:一是支持动态更新,不需要重启服务:二就是加入了防火墙的“zone”概念. firewalld有图形界面和工具界 ...

  9. centos7 && centos6.5部KVM使用NAT联网并为虚拟机配置firewalld && iptables防火墙端口转发

    centos7 && centos6.5 部KVM使用NAT联网并为虚拟机配置firewalld && iptables防火墙端口转发 一.准备工作: 1: 检查kvm ...

随机推荐

  1. Get access to Servlet

    import java.io.*;import javax.servlet.*;import javax.servlet.http.*;public class LoginServlet extend ...

  2. ExtJS常用的正则表达式

    正则表达式用于字符串处理.表单验证等场合,实用高效.现将一些常用的表达式收集于此,以备不时之需. Ext.onReady(function(){ Ext.QuickTips.init(); }); E ...

  3. C++@冒号(:)和双冒号(::)的用法

    转自:http://blog.csdn.net/zimingjushi/article/details/6549390 1.冒号(:)用法 (1)表示机构内位域的定义(即该变量占几个bit空间) ty ...

  4. 嵌入式系统Linux内核开发工程师必须掌握的三十道题(转)

    嵌入式系统Linux内核开发工程师必须掌握的三十道题 如果你能正确回答以下问题并理解相关知识点原理,那么你就可以算得上是基本合格的Linux内核开发工程师,试试看! 1) Linux中主要有哪几种内核 ...

  5. NodeJS记录

    https://nqdeng.github.io/7-days-nodejs/#3.3.4

  6. 亲测 logminer挖掘

    LogMiner两种使用类型,一种是使用源数据库的数据字典分析DML操作,别一种是摘取LogMiner数据字典到字典文件分析DDL操作.检查下suppplemental logging:SQL> ...

  7. asp.net系统过滤器、自定义过滤器

    原文地址:http://www.cnblogs.com/kissdodog/archive/2013/05/21/3090513.html 一.系统过滤器使用说明 1.OutputCache过滤器 O ...

  8. 使用Myeclipse 2015 进行 Hdp 4 windows 开发

    在本地环境下进行开发,使用cygwin安装 Hdp那就是一个呵呵岂能概括. 所以啊,还是用Hdp windows进行开发测试吧.这样感觉省心点.具体 Hdp windows的安装参看前面的文章或自行G ...

  9. webpack 多entry 配置

    // webpack 多entry 配置var path = require('path'); module.exports = { entry: { entry2: './entry.js', de ...

  10. Hadoop学习地址

    hortonworks: http://zh.hortonworks.com/hdp/downloads/ http://zh.hortonworks.com/hadoop-tutorial/supe ...