1.1. View the hostname
[root@ball-1 data]# hostnamectl status Static hostname: ball-1 Icon name: computer-vm Chassis: vm Machine ID: 45461f76679f48ee96e95da6cc798cc8 Boot ID: a2f12ecd869045d695586365479419d9 Virtualization: xen Operating System: CentOS Linux 7 (Core) CPE OS Name: cpe:/o:centos:centos:7 Kernel: Linux 3.10.0-123.9.3.el7.x86_64 Architecture: x86_64 [root@ball-1 data]#
1.2. Modification
sudo hostnamectl set-hostname "my-host-name"
2. Enlarge the ssh port
2.1, modify the port
vi /etc/ssh/sshd_config Port 24367
2.2, restart the ssh service
systemctl restart sshd.service
3. Turn off selinux
3.1, check the status of selinux
sestatus [root@ball-1 data]# sestatus SELinux status: disabled
3.2. If enable means enable, then close
vi /etc/selinux/config Modify SELINUX=disabled
4. Enable iptables,
#Not used to firewall #Still
used to iptables
4.1, close firewall
systemctl stop firewalld.service systemctl disable firewalld.service
4.2, enable iptables
yum install iptables-services vi /etc/sysconfig/iptables content: # 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] :MY-Firewall-1-INPUT - [0:0] -A INPUT -j MY-Firewall-1-INPUT -A FORWARD -j MY-Firewall-1-INPUT -A MY-Firewall-1-INPUT -i lo -j ACCEPT -A MY-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT -A MY-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT -A MY-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT -A MY-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT -A MY-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT -A MY-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited COMMIT
#start iptables systemctl restart iptables.service #Configure startup systemctl enable iptables.service