1 |
On 10/22/2010 03:21 PM, Vladimir Solomatin wrote: |
2 |
|
3 |
правила забыл указать |
4 |
|
5 |
rules_eth2=( |
6 |
"from 77.241.x.x/28 to all table isp1 priority 530" |
7 |
"from 213.129.x.x/28 to all table isp2 priority 630" |
8 |
"from 213.128.x.x/28 to all table isp3 priority 730" |
9 |
) |
10 |
|
11 |
Правила как добавляются так и удаляются. |
12 |
|
13 |
host ~# /etc/init.d/net.eth2 restart |
14 |
* Stopping eth2 |
15 |
* Bringing down eth2 |
16 |
* Shutting down eth2 |
17 |
... [ ok ] |
18 |
* Running postdown function |
19 |
* Removing IP policy routing rules |
20 |
* from 77.241.x.x/28 to all table isp1 priority 530 |
21 |
... [ ok ] |
22 |
* from 213.129.x.x/28 to all table isp2 priority 630 |
23 |
... [ ok ] |
24 |
* from 213.128.x.x/28 to all table isp3 priority 730 ... |
25 |
[ ok ] |
26 |
* Starting eth2 |
27 |
* Bringing up eth2 |
28 |
* |
29 |
77.241.x.x/28 |
30 |
[ ok ] |
31 |
* |
32 |
213.128.x.x/28 |
33 |
[ ok ] |
34 |
* |
35 |
213.129.x.x/28 |
36 |
[ ok ] |
37 |
* Adding routes |
38 |
* 77.241.x.x/28 dev eth2 src 77.241.x.x table artnet proto static |
39 |
... [ ok ] |
40 |
* 77.241.x.x/28 dev eth2 src 77.241.x.x table uvttk proto static |
41 |
... [ ok ] |
42 |
* 77.241.x.x/28 dev eth2 src 77.241.x.x table sibintek proto |
43 |
static ... [ ok ] |
44 |
* 77.241.x.x/28 dev eth2 src 77.241.x.x table domolink proto |
45 |
static ... [ ok ] |
46 |
* 213.128.218.16/28 dev eth2 src 213.128.x.x table artnet proto |
47 |
static ... [ ok ] |
48 |
* 213.128.218.16/28 dev eth2 src 213.128.x.x table uvttk proto |
49 |
static ... [ ok ] |
50 |
* 213.128.218.16/28 dev eth2 src 213.128.x.x table sibintek proto |
51 |
static ... [ ok ] |
52 |
* 213.128.218.16/28 dev eth2 src 213.128.x.x table domolink proto |
53 |
static ... [ ok ] |
54 |
* 213.129.x.x/28 dev eth2 src 213.129.x.x table artnet proto |
55 |
static ... [ ok ] |
56 |
* 213.129.x.x/28 dev eth2 src 213.129.x.x table uvttk proto static |
57 |
... [ ok ] |
58 |
* 213.129.x.x/28 dev eth2 src 213.129.x.x table sibintek proto |
59 |
static ... [ ok ] |
60 |
* 213.129.x.x/28 dev eth2 src 213.129.x.x table domolink proto |
61 |
static ... [ ok ] |
62 |
* Running postup function |
63 |
* Adding IP policy routing rules |
64 |
* from 77.241.x.x/28 to all table isp1 priority 530 |
65 |
... [ ok ] |
66 |
* from 213.129.x.x/28 to all table isp2 priority 630 |
67 |
... [ ok ] |
68 |
* from 213.128.x.x/28 to all table isp3 priority 730 |
69 |
... [ ok ] |
70 |
|
71 |
>>>> Добавка: если убрать концовку dev "${IFACE}" в postup в строке |
72 |
>>>> ip rule add ${x} dev "${IFACE}" |
73 |
>>>> то postdown не сможет найти свои правила (т.к. оно их находит grepом по |
74 |
>>>> iif ${IFACE}). |
75 |
>>> Заменил ip rule add ${x} dev "${IFACE}" на ip rule add ${x} - работает. |
76 |
>>> |
77 |
>>> Сейчас буду думать как бы привязать правила к интерфейсу, чтобы |
78 |
>>> postdown() могла их корректно удалить... |
79 |
>>> |
80 |
>> Можно попробовать получать список правил для удаления не из ip rule show |
81 |
>> | grep что-нибудь, а из той же самой rules_... |
82 |
>> |
83 |
> |
84 |
> В общем, вам либо поменять функции и убрать это добавление iif $IFACE, |
85 |
> либо добавлять правила другим способом. |
86 |
|
87 |
> config_eth2=( |
88 |
> "77.241.x.x/28 brd 77.241.x.x" |
89 |
> "213.128.x.x/28 brd 213.128.x.x" |
90 |
> "213.129.x.x/28 brd 213.129.x.x" |
91 |
> ) |
92 |
> |
93 |
> routes_eth2=( |
94 |
> "77.241.x.x/28 dev eth2 src 77.241.x.x table isp1 proto static" |
95 |
> "77.241.x.x/28 dev eth2 src 77.241.x.x table isp2 proto static" |
96 |
> "77.241.x.x/28 dev eth2 src 77.241.x.x table isp3 proto static" |
97 |
> "77.241.x.x/28 dev eth2 src 77.241.x.x table isp4 proto static" |
98 |
> "213.128.x.x/28 dev eth2 src 213.128.x.x table isp1 proto static" |
99 |
> "213.128.x.x/28 dev eth2 src 213.128.x.x table isp2 proto static" |
100 |
> "213.128.x.x/28 dev eth2 src 213.128.x.x table isp3 proto static" |
101 |
> "213.128.x.x/28 dev eth2 src 213.128.x.x table isp4 proto static" |
102 |
> "213.129.x.x/28 dev eth2 src 213.129.x.x table isp1 proto static" |
103 |
> "213.129.x.x/28 dev eth2 src 213.129.x.x table isp2 proto static" |
104 |
> "213.129.x.x/28 dev eth2 src 213.129.x.x table isp3 proto static" |
105 |
> "213.129.x.x/28 dev eth2 src 213.129.x.x table isp4 proto static" |
106 |
> ) |
107 |
> |
108 |
> postup() { |
109 |
> local x="rules_${IFVAR}[@]" |
110 |
> local -a rules=( "${!x}" ) |
111 |
> if [[ -n ${rules} ]] ; then |
112 |
> einfo "Adding IP policy routing rules" |
113 |
> eindent |
114 |
> # Ensure that the kernel supports policy routing |
115 |
> if ! ip rule list | grep -q "^" ; then |
116 |
> eerror "You need to enable IP Policy Routing |
117 |
> (CONFIG_IP_MULTIPLE_TABLES)" |
118 |
> eerror "in your kernel to use ip rules" |
119 |
> else |
120 |
> for x in "${rules[@]}" ; do |
121 |
> ebegin "${x}" |
122 |
> # ip rule add ${x} dev "${IFACE}" |
123 |
> ip rule add ${x} |
124 |
> eend $? |
125 |
> done |
126 |
> fi |
127 |
> eoutdent |
128 |
> # Flush the cache |
129 |
> ip route flush cache dev "${IFACE}" |
130 |
> fi |
131 |
> } |
132 |
> |
133 |
> postdown() { |
134 |
> # Automatically erase any ip rules created in the example postup |
135 |
> above |
136 |
> if interface_exists "${IFACE}" ; then |
137 |
> local x="rules_${IFVAR}[@]" |
138 |
> local -a rules=( "${!x}" ) |
139 |
> if [[ -n ${rules} ]] ; then |
140 |
> einfo "Removing IP policy routing rules" |
141 |
> eindent |
142 |
> for x in "${rules[@]}" ; do |
143 |
> ebegin "${x}" |
144 |
> ip rule del ${x} |
145 |
> eend $? |
146 |
> done |
147 |
> eoutdent |
148 |
> # Flush the route cache |
149 |
> ip route flush cache dev "${IFACE}" |
150 |
> fi |
151 |
> fi |
152 |
> |
153 |
> # Return 0 always |
154 |
> return 0 |
155 |
> } |
156 |
> |
157 |
> см. http://geekscrap.com/2010/02/multiple-ip-uplinks-with-gentoo/ |
158 |
> -- |
159 |
> Vladimir Solomatin (slash@×××××.ru) |
160 |
> Phone: + 7 (4732) 711711 |
161 |
> Relex Inc, Voronezh. |
162 |
|
163 |
|
164 |
-- |
165 |
Vladimir Solomatin (slash@×××××.ru) |
166 |
Phone: + 7 (4732) 711711 |
167 |
Relex Inc, Voronezh. |