- 论坛徽章:
- 0
|
自己在检查中发现了几个问题
我要做的是到目的地址的某个端口的包走eth2
所以我标记的包应该是
iptables -t mangle -A PREROUTING -p tcp --dport 80 -d 218.30.60.101 -j MARK --set-mark 1
而不是
iptables -t mangle -A PREROUTING -p tcp --dport 80 -s 218.30.60.101 -j MARK --set-mark 1
所以在mangle 表中相应的是
mangle表
iptables -t mangle -L
Chain FORWARD (policy ACCEPT)
target prot opt source destination
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
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
MARK tcp -- anywhere 218.30.60.101 tcp dpt:www MARK set 0x1
但是不论源还是目的 只要访问218.30.60.101包都是在增加的
目的为218。30。60。101
iptables -t mangle -nvL
Chain FORWARD (policy ACCEPT 15620 packets, 9856K bytes)
pkts bytes target prot opt in out source destination
Chain INPUT (policy ACCEPT 3417 packets, 223K bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 3769 packets, 377K bytes)
pkts bytes target prot opt in out source destination
Chain POSTROUTING (policy ACCEPT 19388 packets, 10M bytes)
pkts bytes target prot opt in out source destination
Chain PREROUTING (policy ACCEPT 19040 packets, 10M bytes)
pkts bytes target prot opt in out source destination
29 7803 MARK tcp -- 218.30.60.101 anywhere tcp dpt:www MARK set 0x1
源为218。
ptables -t mangle -nvL
Chain FORWARD (policy ACCEPT 15620 packets, 9856K bytes)
pkts bytes target prot opt in out source destination
Chain INPUT (policy ACCEPT 3417 packets, 223K bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 3769 packets, 377K bytes)
pkts bytes target prot opt in out source destination
Chain POSTROUTING (policy ACCEPT 19388 packets, 10M bytes)
pkts bytes target prot opt in out source destination
Chain PREROUTING (policy ACCEPT 19040 packets, 10M bytes)
pkts bytes target prot opt in out source destination
23 1803 MARK tcp -- anywhere 218.30.60.101 tcp dpt:www MARK set 0x1
这是为什么啊
但不论是源地址 218.30.60.101 还是目的为218.30.60.101是至少是能表明那是我打过标记的包吧 但为什么又不走table 1中的路由
我用
ip rule add to 218.30.60.101 table 1能够使他走eth2走
但是我现在要他根据是不是对218。30。60。101的端口来判断得不是走eth2
一直怀疑是不是方法有问题 |
|