1.简单写一个网页
下载nginx
setenforce 0
systemctl stop firewalld
systemctl disable firewalld
yum install nginx -y
启动
systemctl start nginx
编写网页内容
mkdir -p /www/haha
echo "hello world" >/www/haha/index.html
vim /etc/nginx/conf.d/vshost.conf
server{
listen 80;
server_name 192.168.132.129;
root /www/haha;
}
重启
systemctl restart nginx
1、安装iptables
yum install -y iptables-services
2、关闭firewalld,开启iptables
systemctl stop firewalld
systemctl start iptables
3、添加规则:ssh服务端口22,dns服务53,httpd服务80,chrony服务123,nfs服务111
iptables -t filter -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -t filter -A INPUT -p udp --dport 53 -j ACCEPT
iptables -t filter -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -t filter -A INPUT -p udp --dport 123 -j ACCEPT
iptables -t filter -A INPUT -p udp --dport 111 -j ACCEPT
4、添加一条拒绝所有
iptables -t filter -A INPUT -p ip -j REJECT
由于匹配原则从上至下依次匹配最后一条为拒绝所有所以最后会拒绝
5、查看规则表
iptables -vnL --line-numbers
6、清空所有的规则表
iptables -F
- table有优先级:由高到低排列为:raw -> mangle -> nat -> filter;
- 当有多个table包含同一类型的chain时,所有的table都会按照上面table优先级被遍历,执行table中实际的chain下的规则。
- 注意不要直接在第一条就拒绝所有,负责会坏掉