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持久化命令:netfilter-persistent save

在Linux上,使用netfilter-persistent命令可以保存iptables防火墙规则,确保它们在系统重启后仍然有效。以下是如何使用netfilter-persistent来保存iptables规则的步骤: 打开终端:首先,你需要打开Linux系统的终端。保存规则:使用netfilter-persistent save命令可以保存当前的iptables规则。这个命令会调用所有插件,将

Netfilter学习之NAT类型动态配置(六)全锥型NAT用户空间iptables命令行实现

本文主要实现全锥型NAT的用户空间iptables命令行扩展的实现,实现思路见上文,具体可以模仿MASQUERADE的源码进行改写。 1.关键部分实现代码   由于fullcone类型并不需要输入参数,因此parse可以为空,print和save也很简单,只需要help和结构注册两部分保证正确即可。   help如下: static void FULLCONE_help(void){

iptables四表五链

netfilter/iptables netfilter是Linux内核中的一个框架,工作在网络层,用于处理ip数据包,iptables 则是一个命令行工具,通过与netfilter框架交互,实现对数据包的过滤和转发等操作 常见的UFW防火墙、firewalld防火墙都是基于iptables的,它们提供了更简单的管理iptables的rules的命令 Tables 表 filter 过滤

Linux运维--iptables防火墙命令以及端口号等详解(全)

Linux之iptable防火墙命令以及端口号等详解(全) 在Linux系统中,你可以使用firewalld和iptables来管理和设置防火墙规则。Firewalld是一个动态管理防火墙的工具,而iptables是一个更底层的工具,可以直接配置Linux内核的防火墙规则。 在RHEL 6.9及更早版本中,使用的是iptables作为防火墙管理工具,而在RHEL 7及更新版本中则使用Fire

iptables官方手册整理

1. 简介 2. 首先,什么是包过滤? 3. 快速入门指南 4. 数据包过滤流程 5. 具体如何使用 Iptables 命令实现过滤功能 6. 地址转换(NAT) 7. 排除建议 1. 简介   ———————————————————————————————————————————————— 读者们,大家好:   在这里我们假设你已经有一定的 IP 地址、网络地址、子网掩码、路由、DNS 基

iptables四个表五条链

iptables四个表五条链     其实关于iptables的使用网上的资料和教程也比较多,主要是要理解其中的路由前和路由后每个表和链所处的位置和作用,明白了也就简单了,以下是我转载的觉得写的比较详细的一篇博客,有时间我将写一篇关于这些表和链的实质性的配置例子。 一、netfilter和iptables说明:     1、   netfilter/ip

linux防火墙iptables详细教程

2.1 框架图 -->PREROUTING-->[ROUTE]-->FORWARD-->POSTROUTING-->  mangle     |     mangle     ^ mangle    nat       | & 2.1 框架图  -->PREROUTING-->[ROUTE]-->FORWARD-->POSTROUTING-->   mangle

CentOS 7告iptables防火墙提示Unit iptables.service failed to load

使用CentOS 7时发现使用iptables防火墙时提示错误Unit iptables.service failed to load,意思是防火墙运行启动失败了,那么要如何处理呢。 一直用CentOS 6 习惯了,一下没适应过来。防火墙配置后执行service iptables save 出现”Failed to restart iptables.service: Unit iptables.

centos7.5防火墙(iptables和firewall)的相关操作命令

iptables防火墙 1、基本操作 #查看防火墙状态 # ​service iptables status   # 停止防火墙 # service iptables stop  # 启动防火墙 # service iptables start   # 重启防火墙 # service iptables restart   # 永久关闭防火墙 # chkconfig iptab

iptables笔记汇总

iptables笔记汇总 一、基础概念 iptables其实不是真正的防火墙,我们可以把它理解成一个客户端代理,用户通过iptables这个代理,将用户的安全设定执行到对应的”安全框架”中,这个”安全框架”才是真正的防火墙,这个框架的名字叫netfilternetfilter才是防火墙真正的安全框架(framework),netfilter位于内核空间。iptables其实是一个命令行工具,位