缺少semanage,需要安裝net-tools (這個包同時還包含了ifconfig,否則只能用ip addr看了~)
創(chuàng)新互聯(lián)公司基于十年網(wǎng)站建設(shè)行業(yè)經(jīng)驗,一直致力于為中小型企業(yè)提供信息化解決方案,創(chuàng)新互聯(lián)公司做到開放、開源,讓企業(yè)所有核心數(shù)據(jù)掌握到企業(yè)手里,打破行業(yè)亂象,讓企業(yè)被網(wǎng)絡(luò)公司掌控的局面不再發(fā)生;美工設(shè)計部,產(chǎn)品/程序研發(fā)部,營銷策劃部,售后客服部。一切服務(wù)為企業(yè)量身定制,專注為您![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.設(shè)置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.service4.測試