博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
iptables 程序简介
阅读量:4187 次
发布时间:2019-05-26

本文共 1108 字,大约阅读时间需要 3 分钟。

1、简介

      iptables或netfilter(网络过滤器) 是一个用户态的防火墙应用软件,允许系统管理员可以调整设定X表(Xtables)提供相关的系统表格(目前主要是在 iptables/netfilter 底下)以及相关的“链”与“规则”来管理网络封包的流动与转送的动作。因为相关动作上的需要,所以 iptables 的操作需要用到系统管理员的权限,不然就无法运作下去。在大部份的 Linux 系统上面, iptables 是使用/usr/sbin/iptables 来操作,文件则放置在手册页(Man page)(参考: [1])底下,也可以透过 man iptables 的方式来取得这份文件。通常 iptables 都需要核心层级(kernel)的模组来配合运作,Xtables 是主要在核心层级里面 iptables API 运作功能的模组。

2、参数说明

      -A 向规则链中添加一条规则,默认被添加到末尾

      -T指定要操作的表,默认是filter
      -D从规则链中删除规则,可以指定序号或者匹配的规则来删除
      -R进行规则替换
      -I插入一条规则,默认被插入到首部
      -F清空所选的链,重启后恢复
      -N新建用户自定义的规则链
      -X删除用户自定义的规则链
      -p用来指定协议可以是tcp,udp,icmp等也可以是数字的协议号,
      -s指定源地址
      -d指定目的地址
      -i进入接口
      -o流出接口
      -j采取的动作,accept,drop,snat,dnat,masquerade
      --sport源端口
      --dport目的端口,端口必须和协议一起来配合使用

3、iptable配置实例

3.1 设定默认规则
     在iptables规则中没有匹配到规则则使用默认规则进行处理
     iptables -P INPUT DROP
     iptables -P OUTPUT ACCEPT
     iptables -P FORWARD DROP
3.2 配置SSH规则
     iptables -A INPUT -p tcp --dport 22 -j ACCEPT
     iptables -A OUTPUT -p tcp --sport 22 -j ACCEPT  
     如果你把OUTPUT 设置成DROP,就需要加上这个规则,否则SSH还是不能登录,因为SSH服务之进不能出。
     只允许192.168.0.3的机器进行SSH连接
     iptables -A INPUT -s 192.168.0.3 -p tcp --dport 22 -j ACCEPT
     如果要允许,或限制一段IP地址可用 192.168.0.0/24 表示192.168.0.1-255端的所有IP.

转载地址:http://gedoi.baihongyu.com/

你可能感兴趣的文章
Find the number of subsets such that the sum of numbers in the subset is a prime number
查看>>
CareerCup Binary Tree the Maximum of 人
查看>>
CareerCup Divide n cakes to k different people
查看>>
CareerCup Randomly return a node in a binary tree
查看>>
CareerCup Given a sorted array which contains scores. Write a program to find occurrence
查看>>
CareerCup The number of pairs (x, y) of distinct elements with condition x + y <= Threshold
查看>>
Build a key-value data structure which can perform lookup and rangeLookup(key1, key2)
查看>>
整数划分问题---动态规划、递归
查看>>
Balanced Partition
查看>>
Number of 1s
查看>>
CareerCup Find all the conflicting appointments from a given list of n appointments.
查看>>
CareerCup Given an array having positive integers, find a subarray which adds to a given number
查看>>
CareerCup Generate all the possible substrings
查看>>
CareerCup Given an array A[], find (i, j) such that A[i] < A[j] and (j - i) is maximum.
查看>>
Brain Teaser 球变色
查看>>
(2)考试大纲---信息系统项目管理师考试系列
查看>>
(3)教材目录---信息系统项目管理师考试系列
查看>>
商城基础E-R模型图
查看>>
飞翔的小鸟--键盘事件案例
查看>>
一个sql函数group_concat详解
查看>>