网络里的“逆世界”—— 不让邻居蹭网

邻居偷用我的无线网,我可以设置访问密码,但我决定捉弄他们。

拆分网络

我先把网络分成两部分——一部分受信,一部分不受信。受信的部分使用一个网段,不受信的是其它网段。我使用DHCP服务器限制MAC地址,过滤无关地址。

/etc/dhcpd.conf

01 ddns-updates off;
02 ddns-update-style interim;
03 authoritative;
04  
05 shared-network local {
06  
07         subnet *.*.*.* netmask 255.255.255.0 {
08                 range *.*.*.* *.*.*.*;
09                 option routers *.*.*.*;
10                 option subnet-mask 255.255.255.0;
11                 option domain-name "XXXXX";
12                 option domain-name-servers *.*.*.*;
13                 deny unknown-clients;
14  
15                 host trusted1 {
16                         hardware ethernet *:*:*:*:*:*;
17                         fixed-address *.*.*.*;
18                 }
19         }
20  
21         subnet 192.168.0.0 netmask 255.255.255.0 {
22                 range 192.168.0.2 192.168.0.10;
23                 option routers 192.168.0.1;
24                 option subnet-mask 255.255.255.0;
25                 option domain-name-servers 192.168.0.1;
26                 allow unknown-clients;
27  
28         }
29 }

IPtables很有趣!

一下子,满世界全是小猫!猫的世界。

1 /sbin/iptables -A PREROUTING -s 192.168.0.0/255.255.255.0 -p tcp -j DNAT --to-destination 64.111.96.38

对于非法访问者,他们会被重定向到kittenwar

为了让事情更有兴趣,我修改iptables,把所有请求都秘密的转向到一台计算机上的squid代理服务器的80端口。

1 /sbin/iptables -A PREROUTING -s 192.168.0.0/255.255.255.0 -p tcp -m tcp --dport 80 -j DNAT --to-destination 192.168.0.1

这台机器上的squid代理加载了一个小的脚步程序,用来下载图片,并使其上下颠倒,然后发出去。

重定向脚本

01 #!/usr/bin/perl
02 $|=1;
03 $count = 0;
04 $pid = $$;
05 while (<>) {
06         chomp $_;
07         if ($_ =~ /(.*\.jpg)/i) {
08                 $url $1;
09                 system("/usr/bin/wget""-q""-O","/space/WebPages/images/$pid-$count.jpg""$url");
10                 system("/usr/bin/mogrify""-flip","/space/WebPages/images/$pid-$count.jpg");
11                 print "http://127.0.0.1/images/$pid-$count.jpg\n";
12         }
13         elsif ($_ =~ /(.*\.gif)/i) {
14                 $url $1;
15                 system("/usr/bin/wget""-q""-O","/space/WebPages/images/$pid-$count.gif""$url");
16                 system("/usr/bin/mogrify""-flip","/space/WebPages/images/$pid-$count.gif");
17                 print "http://127.0.0.1/images/$pid-$count.gif\n";
18  
19         }
20         else {
21                 print "$_\n";;
22         }
23         $count++;
24 }

于是整个互联网变成了这个样子!

shot1

shot3

如果你将脚本这的flip命令加上 -blur 4 参数,你就创造了一个模糊的世界。

shot5

[英文原文: Upside-Down-Ternet ]
原文地址:https://www.cnblogs.com/hnrainll/p/3123180.html