Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4173924
  • 博文数量: 601
  • 博客积分: 15410
  • 博客等级: 上将
  • 技术积分: 6884
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-16 08:11
个人简介

独学而无友,则孤陋而寡闻!

文章分类

全部博文(601)

文章存档

2020年(1)

2018年(4)

2017年(7)

2016年(42)

2015年(25)

2014年(15)

2013年(36)

2012年(46)

2011年(117)

2010年(148)

2009年(82)

2008年(37)

2007年(41)

分类: BSD

2015-09-28 20:40:37

1、wlan界面,用于模拟内网:
 # ifconfig wlan0
wlan0: flags=8943 metric 0 mtu 1500
        ether 4c:0f:6e:71:9c:8c
        inet6 fe80::4e0f:6eff:fe71:9c8c%wlan0 prefixlen 64 tentative scopeid 0x5
        nd6 options=29
        media: IEEE 802.11 Wireless Ethernet autoselect mode 11ng
        status: running
        ssid fb channel 6 (2437 MHz 11g ht/20) bssid 4c:0f:6e:71:9c:8c
        regdomain 101 indoor ecm authmode OPEN privacy OFF txpower 20
        mcastrate 15 scanvalid 60 protmode CTS ampdulimit 64k ampdudensity 8
        shortgi puren wme burst -apbridge dtimperiod 6 -dfs -inact bintval 280

2、网桥:
# ifconfig bridge0
bridge0: flags=8843 metric 0 mtu 1500
        ether 02:5f:7a:b0:95:00
        inet 192.168.100.100 netmask 0xffffff00 broadcast 192.168.100.255
        nd6 options=1
        id 00:00:00:00:00:00 priority 32768 hellotime 2 fwddelay 15
        maxage 20 holdcnt 6 proto rstp maxaddr 2000 timeout 1200
        root id 00:00:00:00:00:00 priority 32768 ifcost 0 port 0
        member: wlan0 flags=143
                ifmaxaddr 0 port 5 priority 128 path cost 33333
        member: wlan1 flags=143
                ifmaxaddr 0 port 6 priority 128 path cost 33333

3、natd命令,注意该规则在内网网卡上运行:
natd -p 3333 -proxy_only -proxy_rule "server 192.168.6.6 proto udp" -log -reverse

4、ipfw规则:
00010 allow ip from any to 192.168.1.9
00011 allow ip from 192.168.1.9 to any
00090 divert 3333 udp from 192.168.100.0/24 to any dst-port 53 recv bridge0
00095 divert 3333 udp from 192.168.6.6 53 to any out via bridge0
00200 nat 10 ip from any to any out via re0
00500 nat 10 ip from any to any in via re0
65530 allow ip from any to any

5、说明事项:
(1)nat做在re0上面,但是通过re0连接了一台dns(192.168.6.6),希望通过这个dns来解析所有地址,即使wlan0下的终端另外设置了dns,也会通过ipfw强制转为192.168.6.6,这就是所谓的dns劫持,并且还是深度的劫持。
(2)wlan0直接通过ipfw会出现包不匹配的情况,所以最好是把规则做到bridge0上面,无线芯片对ipfw支持还不是很完善。做到wlan0或ath0上面,效果都不好。另外即使是netstat -i,对于wlan0和ath0的支持也有限。
(3)95号规则的返回包,一定要用dns的地址,因为这时dns请求包已经被修改,在bridge0上面,所有进入的dns请求包的目标地址已经被替换,当请求包到达re0时,已经是“192.168.100.120->192.168.6.6”的形式了,然后再经过re0的nat,最终可以到达192.168.6.6。
       DNS请求包要分别在两个界面上经过ipfw次,也就是4次通过ipfw。
(4)由于Proxy在内网地址上工作,所以要用reverse参数。

附:pppoe接入实际用规则
/sbin/ipfw add 1000 divert 3333 udp from any to not 192.168.6.6 dst-port 53 recv ng*
/sbin/ipfw add 1001 divert 3333 udp from 192.168.6.192 53 to any recv vlan550
/sbin/natd -p 3333 -proxy_only -proxy_rule "server 192.168.6.192 proto udp" -log -reverse

阅读(1703) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~