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. Linux 的多线程编程的高效开发经验(转)

    http://www.ibm.com/developerworks/cn/linux/l-cn-mthreadps/ 背景 Linux 平台上的多线程程序开发相对应其他平台(比如 Windows)的多 ...

  2. Java——设计模式(单例模式)

     /* * 设计模式: 对问题行之有效的解决方式,其实他是一种思想. * 1.单例设计模式. *  解决问题:  就是可以保证一个列在内存中的对象唯一性. * *如何保证对象的唯一性: *1. 不 ...

  3. 自然语言处理2.1——NLTK文本语料库

    1.获取文本语料库 NLTK库中包含了大量的语料库,下面一一介绍几个: (1)古腾堡语料库:NLTK包含古腾堡项目电子文本档案的一小部分文本.该项目目前大约有36000本免费的电子图书. >&g ...

  4. 解决 nginx https反向代理http协议 302重定向localtion到http问题

    location /rest { #proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remot ...

  5. 【Reporting Services 报表开发】— 页码编列

    一.打开 SQL Server Business Intelligence Development Studio,新建项目—>商业智能项目—> 报表服务器项目,命名为CH4 二.在报表文件 ...

  6. oracle11g服务项及其启动顺序

    oracle安装完成后共七个服务,含义分别为: 1. Oracle ORCL VSS Writer Service:Oracle卷映射拷贝写入服务,VSS(Volume Shadow Copy Ser ...

  7. spring 中事务的PROPAGATION_REQUIRED,Readonly的解释

                 一.事务传播行为种类 Spring在TransactionDefinition接口中规定了7种类型的事务传播行为, 它们规定了事务方法和事务方法发生嵌套调用时事务如何进行传播 ...

  8. jQuery Wookmark 瀑布流布局

    瀑布流布局非常适合大量图片的展示,一改过去裁剪图片尺寸统一的排版,每张图片都能完全展示,并错落有致,让人眼前一亮. 版本: jQuery v1.4.3+ jQuery Wookmark Load v1 ...

  9. 【shell】通配符

    ‘’与“” [root@andon ~]# name='$date' [root@andon ~]# echo $name $date [root@andon ~]# name=abc [root@a ...

  10. js 字符串类型转为数组类型

    以前从来没有想过这个转换,以为直接拼出来就可以了,今天同事问我这个问题,特记录如下. var test='["colkey", "col", "col ...