① 当一个数据包进入网卡时,它首先进入PREROUTING链,内核根据数据包目的IP判断是否需要转送出去。
② 如果数据包就是进入本机的,它就会沿着图向下移动,到达INPUT链。数据包到了INPUT链后,任何进程都会收到它。本机上运行的程序可以发送数据包,这些数据包会经过OUTPUT链,然后到达POSTROUTING链输出。
③ 如果数据包是要转发出去的,且内核允许转发,数据包就会如图所示向右移动,经过FORWARD链,然后到达POSTROUTING链输出。
列出所有规则
iptables -L -n --line-numbers
#保存配置
iptables-save -c > /etc/sysconfig/iptables
#清空
iptabls -F
#恢复
iptables-restore -c -n < /etc/sysconfig/iptables
参数-c 要求装入包和字节计数器。如果你用 iptables-save 保存了计数器,现在想重新装入,就必须用这个参数。
参数-n 告诉 iptables-restore 不要覆盖已有的表或表内的规则。默认情况是清除所有已存的规则
mark 打标记 用 mangle 表
iptables -t mangle -A PREROUTING -mttl --ttl-eq 64 -j MARK --set-mark 10
iptables -t mangle -A PREROUTING -mttl --ttl-eq 123 -j MARK --set-mark 20
iptables -t filter -A FORWARD -m mark--mark 10 -j ACCEPT
iptables -t filter -A FORWARD -m mark--mark 20 -j DROP
# *****centos8 删除网桥 ifconfig -a
ip link set dev virbr0-nic down
nmcli d del virbr0-nic
ip link set dev virbr0 down
nmcli d del virbr0
ip link set dev cni0 down
nmcli d del cni0
ip link set dev flannel.1 down
nmcli d del flannel.1
#ip link set dev tunl0 down
#nmcli d del tunl0
#删除tunl0
ifconfig tunl0 down
ifconfig tunl0 up
tunl0的ip 是可以ping 通的
#直接删除无法删除
ip tunnel del tunl0
# delete tunnel "tunl0" failed: Operation not permitted
ip tunnel show
#查看加载模块
lsmod |grep ipip
ipip 16384 0
tunnel4 16384 1 ipip
ip_tunnel 28672 1 ipip
#卸载该模块
modprobe -r ipip
lsmod |grep ipip
然后tul0 就没有了
参考 https://www.cnblogs.com/snooker/p/9945863.html
参考文档
这篇文章不错
iptables-朱双印博客-第2页https://www.zsythink.net/archives/tag/iptables/page/2
iptables详解及一些常用规则 - 简书https://www.jianshu.com/p/ee4ee15d3658 ptables详解及一些常用规则
关于IPTABLES 各种MARK 功能的用法_bytxl的专栏-CSDN博客_iptables匹配markhttps://blog.csdn.net/bytxl/article/details/44855521 关于IPTABLES 各种MARK 功能的用法
死磕k8s之calico-nodeport_shen的博客-CSDN博客https://blog.csdn.net/u010927340/article/details/109630096 死磕k8s之calico-nodeport
如何优雅的使用 IPtables 在多租户环境中实现 TCP 限速https://mp.weixin.qq.com/s/93uZsUbxnxZ2zGbDZsojHQPer-IP rate limiting with iptables - Making Pusherhttps://making.pusher.com/per-ip-rate-limiting-with-iptables/index.html