Gentoo Archives: gentoo-user-ru

From: Vladimir Solomatin <slash@×××××.ru>
To: gentoo-user-ru@l.g.o
Subject: Re: [gentoo-user-ru] Squid и два аплинка
Date: Fri, 22 Oct 2010 11:22:13
Message-Id: 4CC173D1.6030004@relex.ru
In Reply to: Re: [gentoo-user-ru] Squid и два аплинка by Nikita Kipriyanov
1 On 10/22/2010 02:49 PM, Nikita Kipriyanov wrote:
2 >>>> В общем, вам либо поменять функции и убрать это добавление iif $IFACE,
3 >>>> либо добавлять правила другим способом.
4 >>>>
5 >>>>
6 >>> Добавка: если убрать концовку dev "${IFACE}" в postup в строке
7 >>> ip rule add ${x} dev "${IFACE}"
8 >>> то postdown не сможет найти свои правила (т.к. оно их находит grepом по
9 >>> iif ${IFACE}).
10 >> Заменил ip rule add ${x} dev "${IFACE}" на ip rule add ${x} - работает.
11 >>
12 >> Сейчас буду думать как бы привязать правила к интерфейсу, чтобы
13 >> postdown() могла их корректно удалить...
14 >>
15 > Можно попробовать получать список правил для удаления не из ip rule show
16 > | grep что-нибудь, а из той же самой rules_...
17 >
18
19 config_eth2=(
20 "77.241.x.x/28 brd 77.241.x.x"
21 "213.128.x.x/28 brd 213.128.x.x"
22 "213.129.x.x/28 brd 213.129.x.x"
23 )
24
25 routes_eth2=(
26 "77.241.x.x/28 dev eth2 src 77.241.x.x table isp1 proto static"
27 "77.241.x.x/28 dev eth2 src 77.241.x.x table isp2 proto static"
28 "77.241.x.x/28 dev eth2 src 77.241.x.x table isp3 proto static"
29 "77.241.x.x/28 dev eth2 src 77.241.x.x table isp4 proto static"
30 "213.128.x.x/28 dev eth2 src 213.128.x.x table isp1 proto static"
31 "213.128.x.x/28 dev eth2 src 213.128.x.x table isp2 proto static"
32 "213.128.x.x/28 dev eth2 src 213.128.x.x table isp3 proto static"
33 "213.128.x.x/28 dev eth2 src 213.128.x.x table isp4 proto static"
34 "213.129.x.x/28 dev eth2 src 213.129.x.x table isp1 proto static"
35 "213.129.x.x/28 dev eth2 src 213.129.x.x table isp2 proto static"
36 "213.129.x.x/28 dev eth2 src 213.129.x.x table isp3 proto static"
37 "213.129.x.x/28 dev eth2 src 213.129.x.x table isp4 proto static"
38 )
39
40 postup() {
41 local x="rules_${IFVAR}[@]"
42 local -a rules=( "${!x}" )
43 if [[ -n ${rules} ]] ; then
44 einfo "Adding IP policy routing rules"
45 eindent
46 # Ensure that the kernel supports policy routing
47 if ! ip rule list | grep -q "^" ; then
48 eerror "You need to enable IP Policy Routing
49 (CONFIG_IP_MULTIPLE_TABLES)"
50 eerror "in your kernel to use ip rules"
51 else
52 for x in "${rules[@]}" ; do
53 ebegin "${x}"
54 # ip rule add ${x} dev "${IFACE}"
55 ip rule add ${x}
56 eend $?
57 done
58 fi
59 eoutdent
60 # Flush the cache
61 ip route flush cache dev "${IFACE}"
62 fi
63 }
64
65 postdown() {
66 # Automatically erase any ip rules created in the example postup above
67 if interface_exists "${IFACE}" ; then
68 local x="rules_${IFVAR}[@]"
69 local -a rules=( "${!x}" )
70 if [[ -n ${rules} ]] ; then
71 einfo "Removing IP policy routing rules"
72 eindent
73 for x in "${rules[@]}" ; do
74 ebegin "${x}"
75 ip rule del ${x}
76 eend $?
77 done
78 eoutdent
79 # Flush the route cache
80 ip route flush cache dev "${IFACE}"
81 fi
82 fi
83
84 # Return 0 always
85 return 0
86 }
87
88 см. http://geekscrap.com/2010/02/multiple-ip-uplinks-with-gentoo/
89
90 --
91 Vladimir Solomatin (slash@×××××.ru)
92 Phone: + 7 (4732) 711711
93 Relex Inc, Voronezh.

Replies

Subject Author
Re: [gentoo-user-ru] Squid и два аплинка Vladimir Solomatin <slash@×××××.ru>