linux 服务器 iptables 防止arp病毒,Linux下防御ARP病毒攻击
Linux下防御ARP病毒攻擊的類似文章網(wǎng)絡上太多了,但效果各有千秋,這里寫下我自己的心得。
方法一:
此法比較簡單,簡言之就是綁定網(wǎng)關的IP和MAC,命令如下:
$ sudo arp -s 192.168.1.1 00:14:78:BB:89:E2
前者是網(wǎng)關IP,后者是網(wǎng)關MAC,可能還需要
$ sudo ifconfig eth0 -arp
但我的archlinux如果執(zhí)行這一步,將導致斷網(wǎng),因此我將它省掉了,沒發(fā)現(xiàn)什么問題。
這個方法雖然簡單,但有其局限性,就是必須雙向綁定IP-MAC,如果你無法控制路由器,不能在網(wǎng)關那里設置靜態(tài)IP,這個方法就無效了。
方法二:
這個方法復雜一點,需要用到arpspoof,它屬于dsniff,所以先安裝dsniff。
默認的arpspoof每秒執(zhí)行一次,顯然對付不了arp攻擊,所以要修改源代碼,自己重新編譯arpspoof,有補丁如下:(論壇里找到的,出處忘記了)
#! /bin/sh /usr/share/dpatch/dpatch-run
diff -urNad dsniff-2.4b1+debianold/arpspoof.c dsniff-2.4b1+debian/arpspoof.c
--- dsniff-2.4b1+debianold/arpspoof.c?? 2001-03-15 16:32:58.000000000 +0800
+++ dsniff-2.4b1+debian/arpspoof.c?? 2008-02-24 20:30:11.000000000 +0800
@@ -31,6 +31,7 @@
static struct ether_addr spoof_mac, target_mac;
static in_addr_t spoof_ip, target_ip;
static char *intf;
+static useconds_t interval; /* time interval, add by AutumnCat */
static void
usage(void)
@@ -156,9 +157,15 @@
intf = NULL;
spoof_ip = target_ip = 0;
+??????? interval = 1000000UL;
-?? while ((c = getopt(argc, argv, "i:t:h?V")) != -1) {
+?? while ((c = getopt(argc, argv, "x:i:t:h?V")) != -1) {
switch (c) {
+??????????????? case 'x':
+??????????????????????? interval = (useconds_t)atoi(optarg);
+??????????????????????? if (interval < 1000UL)
+??????????????????????????????? interval = 1000000UL;
+??????????????????????? break;
case 'i':
intf = optarg;
break;
@@ -197,7 +204,8 @@
arp_send(llif, intf, ARPOP_REPLY, NULL, spoof_ip,
(target_ip ? (u_char *)&target_mac : NULL),
target_ip);
-????? sleep(2);
+?? /*?? sleep(2); */
+??????????????? usleep(interval);
}
/* NOTREACHED */
打好補丁后編譯出來的arpspoof多了一個參數(shù)x,用法如下:
$ arpspoof -i eth0 -t 網(wǎng)關IP 你的IP -x 50000
“-x 50000”的意思是每隔50000毫秒執(zhí)行一次,也就是每秒執(zhí)行20次
這個方法似乎有點暴力,以暴治暴,所以每秒執(zhí)行次數(shù)不能太多,否則路由器會掛掉的。
譯好的arpspoof
總結
以上是生活随笔為你收集整理的linux 服务器 iptables 防止arp病毒,Linux下防御ARP病毒攻击的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux自动运行python脚本,执行
- 下一篇: linux手机投屏软件,无线投屏器如此多