iptables

来源:互联网 发布:c语言总结 编辑:程序博客网 时间:2024/04/26 04:34

第一张 防火墙基本概念

TCP/IP 把网络分成四层

      应用层 Application layer

     传输层 Transport Layer

     网络层 Network layer

    链路层 Link Layer


Socket 有65536个洞

公认  0-1023

注册的端口 1024-49151

动态端口 59152-65536


---------------默认规则-----------------------------------

iptables -t  (filter,nat, mangle, raw)  -L 列出 -F 清楚,-A 新加,-P 设置默认, -I 插入新规则,-R 取代规则, -D删除规则


修改FORWARD的默认规则

iptables -t filter -P FORWARD DROP


---------------插入规则----------------------------------------------------

iptables -t filter -L INPUT

iptables -t filter -L INPUT --line-number

iptables -t filter -I INPUT 2 -p icmp -j ACCEPT

----------------替换已有规则---------------------------------------------------------

iptables -t filter -R INPUT 2 -p tcp -j ACCEPT

------------------删除规则--------------------------

iptables -t filter -D INPUT 2

------------允许192.168.1.0/24网段向本机192.168.0.1提出任何请求

iptables -A INPUT -p all -s 192.168.1.0/24 -d 192.168.0.1 -j ACCEPT

-----------只允许客户端从eth1网卡访问本机的ssh

iptables -A INPUT -p tcp -i eth1 --dport 22 -j ACCEPT

----------不允许本机应用程序从eth0接口发送数据访问edu.uuu.com.tw以外的网站

iptables -A INPUT -p tcp -i eth0  -d ! edu.uuu.com.tw -dport 80 -j REJECT