iptables and ebtables

2024-05-27 02:32
文章标签 iptables ebtables

本文主要是介绍iptables and ebtables,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

iptablesebtables都是linux上常用的防火墙,前者主要负责网络层的数据包过滤,后者则负责数据链路层的包过滤。对于两者的语法,可以参考博文 http://blog.csdn.net/windxxf/article/details/815973  

http://itoedr.blog.163.com/blog/static/1202842972012101022023796/

下面是本人总结的相关防火墙策略

iptables

1) Allow all packets input from eth1

2) Allow all packets output to eth0

3) Transmit packets from eth1 to eth0

4) Defend SYN Flood

5) Forbid new access request from eth0

6) Accept tcp traffic from 01:02:03:04:05:06

7) Deny pings from outside

8) Allow the source ip 202.106.12.130 to connect theSSH service port:

9) Drop all request of icmp echo request from eth1

10) Replace the source address and port to one of194.236.50.155~194.236.50.160 and one of 1024~32000 for all tcp traffic frometh0

11) Allow 192.168.1.34 pretend to access outsidenetwork’s 25 port from eth0

12) Transmit all traffic send to 15.45.23.67 to arange of LAN: 192.168.1.2~192.168.1.10. 

1. iptables -A INPUT -i eth1 -j ACCEPT

2. iptables -A OUTPUT -i eth0 -j ACCEPT

3. iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT

4. iptables -A INPUT -p tcp --syn -m limit --limit1/s -j ACCEPT

5. iptables -A INPUT -i eth0 -m state --state NEW -jDROP

6. iptables -A INPUT -p tcp -m mac --mac-source01:02:03:04:05:06 -j ACCEPT

7. iptables -A INPUT -p icmp --icmp-type 8 -j DROP

8. iptables -A INPUT -p tcp -s 202.106.12.130--dport 22 -j ACCEPT

9. iptables -A INPUT -p icmp --icmp-type echo-request-i eth1 -j DROP

10. iptables -t nat -A POSTROUTING -p tcp -o eth0 -jSNAT --to-source 194.236.50.155-194.236.50.160:1024-32000

11. iptables -A INPUT -s 192.168.1.34 -i eth0--dport 25 -j ACCEPT

12. iptables -t nat -A PREROUTING -d 15.45.23.67 -jDNAT --to-destination 192.168.1.2-19.168.1.10

ebtables

1)Forward the packets with source MAC00:11:22:33:44:55

2) Change the iptables rule to ebtables: iptables -AFORWARD -s 172.16.1.4 -m mac --mac-source ! 00:11:22:33:44:55 -j DROP

3) Drop all traffic with matching MAC-IP sourceaddress pairs: 00:11:22:33:44:55->192.168.1.300:66:77:88:00:11->192.168.1.4

4) Make all frames destined to 00:11:22:33:44:55that arrived on interface eth0 be transferred to 54:44:33:22:11:00 instead

5) br0 is 0.0.0.0, eth0 is 172.16.1.1, br0 has eth0,make the IP packets must be routed enter the IP routing code through the eth0device, not through the br0 device

6) Make all IP traffic that entered through eth0with the second mark value; and let later rules have the chance of seeing theframe/packet

7) Using arpreply for arp requests and letting thearp request populate the arp cache

8) send all to be forwarded packets to userspaceprograms listening on netlink group number 5 before dropping the packets

1. ebtables -A FORWARD -s 00:11:22:33:44:55 -jACCEPT

2. ebtables -A FORWARD -p ipv4 --ip-src 172.16.1.4-s!00:11:22:33:44:55 -j DROP

3. ebtables -N MACHINE-MC-IP-PAIR

   ebtables -AFORWARD -p ipv4 --among-dst00:11:22:33:44:55=172.16.1.4,00:11:33:44:22:55=172.16.1.5 -j MACHINE-MC-IP-PAIR

4. ebtables -t nat -A PREROUTING -d00:11:22:33:44:55 -i eth0 -j DNAT --to-destination 54:44:33:22:11:00

5. ebtables -t broute -A BROUTING -p ipv4 -i eth0--ip-dst 172.16.1.1 -j DROP

6. ebtables -t broute -A BROUTING -i eth0 -p ipv4 -jREDIRECT --redirect-target DROP

7. ebtables -t nat -A PREROUTING -p arp --arp-opcodeRequest -j ARPREPLY --arpreply-mac 10:11:12:13:14:15

8. ebtables -A FORWARD --ulog-nlgroup 5 -j DROP


这篇关于iptables and ebtables的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1006278

相关文章

iptables(7)扩展模块state

简介         前面文章我们已经介绍了一些扩展模块,如iprange、string、time、connlimit、limit,还有扩展匹配条件如--tcp-flags、icmp。这篇文章我们介绍state扩展模块  state          在 iptables 的上下文中,--state 选项并不是直接关联于一个扩展模块,而是与 iptables 的 state 匹配机制相关,特

CentOS linux关闭iptables防火墙(Linux中的防火墙叫iptables)

linux服务器下防火墙为iptables组件,在安装一些软件的时候,iptables防火墙会阻止我们一些必要的连接。 查看iptables状态:service iptables status iptables开机自动启动: 开启: chkconfig iptables on  关闭: chkconfig iptables off iptables关闭服务: 开启: service

运维iptables与firewalld详解

iptables与firewalld 一、iptables 1.1 iptables简介 iptables 是一个在 Linux 系统上用来配置 IPv4 数据包过滤规则的工具。它允许系统管理员控制数据包的流向,实现网络安全、网络地址转换(NAT)和端口转发等功能。 具体来说,iptables 可以用来定义规则集(ruleset),这些规则决定了哪些数据包可以通过系统,哪些需要被丢弃或者拒

Iptables(1)基本概念

简介 iptables 是一个用于 Linux 操作系统的包过滤防火墙工具,可帮助管理网络流量和实施安全策略。它允许用户配置规则集以控制数据包如何在计算机上移动和处理。通过定义规则来允许或拒绝特定类型的流量,iptables 可以提供有效的网络安全保护。 主要功能包括: 数据包过滤:基于规则集来决定是否接受、拒绝或转发数据包。网络地址转换:支持网络地址转换 (NAT) 功能,允许隐藏内部网络

【Linux】使用 iptables 验证访问HDFS 所使用到的端口

目录 ​编辑 一、实操背景 二、iptables 简介 三、模拟操作 一、实操背景 背景: 在客户有外网的服务器需要访问内网大数据集群HDFS,使用iptable模拟测试需要开放的端口。 二、iptables 简介 具体介绍看文章: 【Linux】Iptables 详解与实战案例_linux iptable-CSDN博客 表(tables)提供特定的功能

Linux 防火墙 Firewall 和 Iptables 的使用

如果我们在Linux服务器的某个端口上运行了个服务,需要外网能访问到,就必须通过防火墙将服务运行端口给开启。Linux中有两种防火墙软件,CentOS7.0以上使用的是firewall,CentOS7.0以下使用的是iptables(使用较少且不建议使用)。  Firewall 开启防火墙: systemctl start firewalld 关闭防火墙: systemctl st

iptables 从放弃 到 熟悉

之前碰到 iptables 就感觉像天书一样,其实找到靠谱的资料,然后自己理解,也并不是那么难。 靠谱资料 强烈推荐–>http://www.zsythink.net/archives/tag/iptables/page/2/ 如果认真读完,可以有个很全面的理解视频:http://www.imooc.com/video/7602

初探iptables -- 下

接上篇blog。 具体流程估计都了解了吧。 下面来看看他具体是如何操作,添加,删除以及修改规则。 先上个例子。 iptables -t filter -I INPUT -p icmp -j DROP-t   -->  tables -I   -->  插入方式 INPUT  -->  chain -p  --> 匹配的选项 后面接着协议 -j  -->  target

初探iptables -- 上

最近看了下iptables  给自己总结一下 什么是iptables? 他是一种linux的访问控制机制,也就是大家所说的防火墙了。目前大部分的linux基本都是预装的。 iptables在的实现是通过和底层的netfilter内核模块的调用。iptables/netfilter就是一个工作于用户空间和防火墙的应用软件。 那他能做些什么? netfilter 支持的常用过滤模块

iptables常用命令总结

1.iptables 是什么 在Linux中,iptables就是一款强大而灵活的防火墙工具,它为系统管理员提供了广泛的配置选项,可以有效地控制数据包的流动,实现网络访问的控制及安全性增强。 iptables 使用三个不同的链来允许或阻止流量:输入(input)、输出(output)和转发(forward) 输入(input) —— 此链用于控制传入连接的行为 输出(output) —— 此