23,121
社区成员
发帖
与我相关
我的任务
分享
hello,我看了您的文章,下面的帖子也全部看了,我照着试验,用上INPUT、FORWARD链,确实成功;但是,我有一个疑惑,就是为什么,明明应该是FORWAR链上的,却跑到INPUT、OUTPUT链上了?
/ # ifconfig
br0 Link encap:Ethernet HWaddr 64:51:7E:01:01:04
inet addr:192.168.2.1 Bcast:192.168.2.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:845 errors:0 dropped:0 overruns:0 frame:0
TX packets:350 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:55334 (54.0 KiB) TX bytes:39909 (38.9 KiB)
eth0 Link encap:Ethernet HWaddr 64:51:7E:01:01:05
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:7219 errors:2 dropped:558 overruns:0 frame:0
TX packets:622 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:575080 (561.6 KiB) TX bytes:96451 (94.1 KiB)
eth0.1000 Link encap:Ethernet HWaddr 64:51:7E:01:01:05
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:870 errors:0 dropped:0 overruns:0 frame:0
TX packets:353 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:62210 (60.7 KiB) TX bytes:40047 (39.1 KiB)
eth0.784 Link encap:Ethernet HWaddr 64:51:7E:01:01:05
UP BROADCAST RUNNING MULTICAST MTU:1488 Metric:1
RX packets:5766 errors:0 dropped:5222 overruns:0 frame:0
TX packets:210 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:344839 (336.7 KiB) TX bytes:22336 (21.8 KiB)
eth0:mng Link encap:Ethernet HWaddr 64:51:7E:01:01:05
inet addr:192.168.0.1 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth1 Link encap:Ethernet HWaddr 64:51:7E:01:01:04
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
eth1.1 Link encap:Ethernet HWaddr 64:51:7E:01:01:04
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
eth1.2 Link encap:Ethernet HWaddr 64:51:7E:01:01:04
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
eth1.3 Link encap:Ethernet HWaddr 64:51:7E:01:01:04
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
eth1.4 Link encap:Ethernet HWaddr 64:51:7E:01:01:04
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
mon.wlan0 Link encap:UNSPEC HWaddr 64-51-7E-01-01-04-00-00-00-00-00-00-00-00-00-00
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:7991 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1726228 (1.6 MiB) TX bytes:0 (0.0 B)
ppp0 Link encap:Point-to-Point Protocol
inet addr:10.32.155.7 P-t-P:10.32.128.1 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1488 Metric:1
RX packets:98 errors:0 dropped:0 overruns:0 frame:0
TX packets:196 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:15150 (14.7 KiB) TX bytes:17561 (17.1 KiB)
wlan0 Link encap:Ethernet HWaddr 64:51:7E:01:01:06
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:259 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:29287 (28.6 KiB)
/ #
/ # iptables -vnL
Chain INPUT (policy ACCEPT 119 packets, 5640 bytes)
pkts bytes target prot opt in out source destination
Chain FORWARD (policy ACCEPT 51 packets, 4101 bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 STRING match "baidu.com" ALGO name bm TO 65535
0 0 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 STRING match "baidu.com" ALGO name bm TO 65535
33 1975 DROP udp -- * * 0.0.0.0/0 0.0.0.0/0 multiport dports 53
Chain OUTPUT (policy ACCEPT 74 packets, 12416 bytes)
pkts bytes target prot opt in out source destination
/ #
/ #
/ # iptables -vnL
Chain INPUT (policy ACCEPT 143 packets, 7179 bytes)
pkts bytes target prot opt in out source destination
Chain FORWARD (policy ACCEPT 66 packets, 5271 bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 STRING match "baidu.com" ALGO name bm TO 65535
0 0 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 STRING match "baidu.com" ALGO name bm TO 65535
33 1975 DROP udp -- * * 0.0.0.0/0 0.0.0.0/0 multiport dports 53
Chain OUTPUT (policy ACCEPT 152 packets, 21074 bytes)
pkts bytes target prot opt in out source destination
/ #
/ #
/ # iptables -t nat -L
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
DNAT 53 -- anywhere 192.168.2.1 PHYSDEV match --physdev-in wlan0 to:119.6.6.6
DNAT 53 -- anywhere 192.168.2.1 PHYSDEV match --physdev-in eth1.4 to:119.6.6.6
DNAT 53 -- anywhere 192.168.2.1 PHYSDEV match --physdev-in eth1.2 to:119.6.6.6
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
MASQUERADE all -- anywhere anywhere
/ #
/ # ps | grep dhcp
360 root 0:00 dhcpd -cf /var/etc/dhcpd0.conf -lf /var/run/dhcpd0.run -pf /var/run/dhcpd0.pid -q br0
442 root 0:00 grep dhcp
/ #
/ # cat va
cat: can't open 'va': No such file or directory
/ # cat var/etc/dhcpd0.conf
subnet 192.168.2.0 netmask 255.255.255.0 {
range 192.168.2.100 192.168.2.200;
default-lease-time 43200;
max-lease-time 86400;
option routers 192.168.2.1;
option ip-forwarding off;
option subnet-mask 255.255.255.0;
option domain-name-servers 61.139.2.69;
}
/ #
/ # iptables -F
/ # iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
/ #
/ #
/ #
/ #
/ #
/ #
/ #
/ # iptables -A FORWARD -p tcp -m string --algo bm --string "baidu.com" -j ACCEPT
/ # iptables -A FORWARD -p udp -m string --algo bm --string "baidu.com" -j ACCEPT
/ # iptables -A FORWARD -p udp -m multiport --dport 53 -j DROP
/ #
/ #
/ # iptables -vnL
Chain INPUT (policy ACCEPT 22 packets, 902 bytes)
pkts bytes target prot opt in out source destination
Chain FORWARD (policy ACCEPT 2 packets, 158 bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 STRING match "baidu.com" ALGO name bm TO 65535
0 0 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 STRING match "baidu.com" ALGO name bm TO 65535
3 181 DROP udp -- * * 0.0.0.0/0 0.0.0.0/0 multiport dports 53
Chain OUTPUT (policy ACCEPT 12 packets, 760 bytes)
pkts bytes target prot opt in out source destination
/ #
/ #
/ # iptables -vvnL
Chain INPUT (policy ACCEPT 47 packets, 2144 bytes)
pkts bytes target prot opt in out source destination
Chain FORWARD (policy ACCEPT 15 packets, 1175 bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 STRING match "baidu.com" ALGO name bm TO 65535
0 0 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 STRING match "baidu.com" ALGO name bm TO 65535
13 783 DROP udp -- * * 0.0.0.0/0 0.0.0.0/0 multiport dports 53
Chain OUTPUT (policy ACCEPT 23 packets, 2065 bytes)
pkts bytes target prot opt in out source destination
libiptc vlibxtables.so.6. 1552 bytes.
Table `filter'
Hooks: pre/in/fwd/out/post = ffffffff/0/98/4c8/ffffffff
Underflows: pre/in/fwd/out/post = ffffffff/0/430/4c8/ffffffff
Entry 0 (0):
SRC IP: 0.0.0.0/0.0.0.0
DST IP: 0.0.0.0/0.0.0.0
Interface: `'/................to `'/................
Protocol: 0
Flags: 00
Invflags: 00
Counters: 47 packets, 2144 bytes
Cache: 00000000
Target name: `' [40]
verdict=NF_ACCEPT
Entry 1 (152):
SRC IP: 0.0.0.0/0.0.0.0
DST IP: 0.0.0.0/0.0.0.0
Interface: `'/................to `'/................
Protocol: 6
Flags: 00
Invflags: 00
Counters: 0 packets, 0 bytes
Cache: 00000000
Match name: `string'
Target name: `' [40]
verdict=NF_ACCEPT
Entry 2 (496):
SRC IP: 0.0.0.0/0.0.0.0
DST IP: 0.0.0.0/0.0.0.0
Interface: `'/................to `'/................
Protocol: 17
Flags: 00
Invflags: 00
Counters: 0 packets, 0 bytes
Cache: 00000000
Match name: `string'
Target name: `' [40]
verdict=NF_ACCEPT
Entry 3 (840):
SRC IP: 0.0.0.0/0.0.0.0
DST IP: 0.0.0.0/0.0.0.0
Interface: `'/................to `'/................
Protocol: 17
Flags: 00
Invflags: 00
Counters: 13 packets, 783 bytes
Cache: 00000000
Match name: `multiport'
Target name: `' [40]
verdict=NF_DROP
Entry 4 (1072):
SRC IP: 0.0.0.0/0.0.0.0
DST IP: 0.0.0.0/0.0.0.0
Interface: `'/................to `'/................
Protocol: 0
Flags: 00
Invflags: 00
Counters: 15 packets, 1175 bytes
Cache: 00000000
Target name: `' [40]
verdict=NF_ACCEPT
Entry 5 (1224):
SRC IP: 0.0.0.0/0.0.0.0
DST IP: 0.0.0.0/0.0.0.0
Interface: `'/................to `'/................
Protocol: 0
Flags: 00
Invflags: 00
Counters: 23 packets, 2065 bytes
Cache: 00000000
Target name: `' [40]
verdict=NF_ACCEPT
Entry 6 (1376):
SRC IP: 0.0.0.0/0.0.0.0
DST IP: 0.0.0.0/0.0.0.0
Interface: `'/................to `'/................
Protocol: 0
Flags: 00
Invflags: 00
Counters: 0 packets, 0 bytes
Cache: 00000000
Target name: `ERROR' [64]
error=`ERROR'
/ #
/ #
/ # ip route
default dev ppp0
10.32.128.1 dev ppp0 src 10.32.155.7
192.168.0.0/24 dev eth0 src 192.168.0.1
192.168.2.0/24 dev br0 src 192.168.2.1
/ #
/ #
/ #