创建账号
#添加账号名为seven
adduser seven
#为seven设置密码
passwd seven77
关闭firewall
#停止firewall
systemctl stop firewall.service
#禁止firewall开机启动
systemctl disable firewall.service
安装iptables防火墙
#安装iptables
yum install iptables-services
#编辑防火墙文件
vim /etc/sysconfig/iptables
#开放80和3306端口
-A INPUT -m state –state NEW -m tcp -p tcp –dport 8080 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT
#重启防火墙使配置文件生效
systemctl restart iptables.service
#设置iptables防火墙为开机启动项
systemctl enable iptables.service
关闭SELINUX
vi /etc/selinux/config
#注释以下配置
SELINUX=enforcing
SELINUXTYPE=targeted
#增加以下配置
SELINUX=disabled
#使配置立即生效
setenforce 0
修改默认SSH端口
vim /etc/ssh/sshd_config //修改ssh的配置文件
找到port 22改成你想改的端口就行了.
service sshd restart //重新ssh服务
端口重定向
iptables -t nat -A PREROUTING -p tcp –dport 443 -j REDIRECT –to-port 8443
另外如果防火墙重新启动,该命令就会失效,可以使用下面的命令把该规则保存到iptables里面。
service iptables save