CentOS 6.8 下 iptables开机脚本设置
  dIZ4mPo2q5Ch 2023年11月02日 58 0


 1、创建

vim /usr/local/sbin/iptables.sh
#!/bin/bash

# Stop iptables service first
service iptables stop

# Load FTP Kernel modules
/sbin/modprobe ip_conntrack_ftp
/sbin/modprobe ip_nat_ftp

# Inital chains default policy
/sbin/iptables -F -t filter
/sbin/iptables -P INPUT DROP
/sbin/iptables -P OUTPUT ACCEPT


# Enable Native Network Transfer
/sbin/iptables -A INPUT -i lo -j ACCEPT

# Accept Established Connections
/sbin/iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

# ICMP Control
/sbin/iptables -A INPUT -p icmp -j ACCEPT

# SSH Service
/sbin/iptables -A INPUT -p tcp --dport 22-j ACCEPT

# WEB Service
/sbin/iptables -A INPUT -p tcp --dport 80 -j ACCEPT

# VNC Service
/sbin/iptables -A INPUT -p tcp --dport 5901 -j ACCEPT

# FTP Service
/sbin/iptables -A INPUT -p tcp --dport 21 -j ACCEPT

2、添加开机启动脚本

vim /etc/rc.local

# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

/usr/local/sbin/iptables.sh

 

【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

上一篇: CentOS 挂载新硬盘 下一篇: Centos 安装 helm3
  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
  sX9JkgY3DY86   2023年11月13日   23   0   0 分屏vim另存为
  3M67F8YJLxn2   2023年11月13日   31   0   0 vimgitc++
dIZ4mPo2q5Ch