- 论坛徽章:
- 1
|
[root@machine1 ~]# iptables -vnL
Chain INPUT (policy ACCEPT 1 packets, 52 bytes)
pkts bytes target prot opt in out source destination
2448 184K ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
3 180 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0
4 288 ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0
8 470 ACCEPT tcp -- * * 192.168.221.211 0.0.0.0/0 tcp dpt:21
8 784 REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 2219 packets, 216K bytes)
pkts bytes target prot opt in out source destination
[root@machine1 ~]# iptables -t nat -vnL
Chain PREROUTING (policy ACCEPT 33 packets, 3167 bytes)
pkts bytes target prot opt in out source destination
Chain POSTROUTING (policy ACCEPT 6 packets, 528 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 6 packets, 528 bytes)
pkts bytes target prot opt in out source destination
测试,证明如上的配置是可以达到ls的目的的。
--------------------------------------------------------------------------------------------------------------
以下为我用tcpdump抓包的结果,我分别从192.168.221.211何192.168.221.1来ftp测试
[root@machine1 ~]# /usr/sbin/tcpdump -s 0 -i eth0 tcp port 21
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
15:49:34.348721 IP 192.168.221.1.17806 > machine1.ftp: S 2323538001:2323538001(0) win 65535 <mss 1460,nop,wscale 0,nop,nop,sackOK>
15:49:37.342698 IP 192.168.221.1.17806 > machine1.ftp: S 2323538001:2323538001(0) win 65535 <mss 1460,nop,wscale 0,nop,nop,sackOK>
15:49:43.378098 IP 192.168.221.1.17806 > machine1.ftp: S 2323538001:2323538001(0) win 65535 <mss 1460,nop,wscale 0,nop,nop,sackOK>
15:50:04.710598 IP machine2.48442 > machine1.ftp: S 2301095987:2301095987(0) win 5840 <mss 1460,sackOK,timestamp 3785626 0,nop,wscale 7>
15:50:04.710716 IP machine1.ftp > machine2.48442: S 2353854985:2353854985(0) ack 2301095988 win 5792 <mss 1460,sackOK,timestamp 4227326 3785626,nop,wscale 7>
15:50:04.713161 IP machine2.48442 > machine1.ftp: . ack 1 win 46 <nop,nop,timestamp 3785707 4227326>
15:50:04.719906 IP machine1.ftp > machine2.48442: P 1:21(20) ack 1 win 46 <nop,nop,timestamp 4227335 3785707>
15:50:04.721555 IP machine2.48442 > machine1.ftp: . ack 21 win 46 <nop,nop,timestamp 3785716 4227335>
15:50:04.722988 IP machine2.48442 > machine1.ftp: P 1:14(13) ack 21 win 46 <nop,nop,timestamp 3785717 4227335>
15:50:04.723031 IP machine1.ftp > machine2.48442: . ack 14 win 46 <nop,nop,timestamp 4227338 3785717>
15:50:04.724032 IP machine1.ftp > machine2.48442: P 21:59(3 ack 14 win 46 <nop,nop,timestamp 4227339 3785717>
15:50:04.726203 IP machine2.48442 > machine1.ftp: P 14:32(1 ack 59 win 46 <nop,nop,timestamp 3785722 4227339>
15:50:04.726534 IP machine1.ftp > machine2.48442: P 59:97(3 ack 32 win 46 <nop,nop,timestamp 4227342 3785722>
15:50:04.768604 IP machine2.48442 > machine1.ftp: . ack 97 win 46 <nop,nop,timestamp 3785764 4227342>
15:50:06.480769 IP machine2.48442 > machine1.ftp: P 32:46(14) ack 97 win 46 <nop,nop,timestamp 3787476 4227342>
15:50:06.481145 IP machine1.ftp > machine2.48442: P 97:131(34) ack 46 win 46 <nop,nop,timestamp 4229096 3787476>
15:50:06.484037 IP machine2.48442 > machine1.ftp: . ack 131 win 46 <nop,nop,timestamp 3787478 4229096>
15:50:07.930228 IP machine2.48442 > machine1.ftp: P 46:60(14) ack 131 win 46 <nop,nop,timestamp 3788926 4229096>
15:50:07.941828 IP machine1.ftp > machine2.48442: P 131:154(23) ack 60 win 46 <nop,nop,timestamp 4230557 3788926>
15:50:07.943624 IP machine2.48442 > machine1.ftp: . ack 154 win 46 <nop,nop,timestamp 3788938 4230557>
15:50:07.943668 IP machine2.48442 > machine1.ftp: P 60:66(6) ack 154 win 46 <nop,nop,timestamp 3788938 4230557>
15:50:07.944206 IP machine1.ftp > machine2.48442: P 154:173(19) ack 66 win 46 <nop,nop,timestamp 4230559 3788938>
15:50:07.985398 IP machine2.48442 > machine1.ftp: . ack 173 win 46 <nop,nop,timestamp 3788981 4230559>
ls,也可以尝试抓包查看,看数据包具体的状态 |
|