bin bash ip_eth1 192 168 ip от провайдера ip_eth2 80 70 xxx yyy ip от

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
ip_eth1=192.168.0.4 # ip от провайдера 1
ip_eth2=80.70.xxx.yyy # ip от провайдера 2
route_default=192.168.0.1 # дефолтный шлюз
route_eth1=192.168.0.1 # шлюз провайдера 1
route_eth2=80.70.xxx.zzz # шлюз провайдера 2
. /lib/lsb/init-functions
start() {
log_daemon_msg "Setting routes"
ip route replace default via $route_eth1 table intranet && echo -n "eth1 "
ip route replace default via $route_eth2 table internet && echo -n "eth2 "
ip rule add from $ip_eth1 table intranet
ip rule add from $ip_eth2 table internet
ip route add default via $route_default
log_end_msg 0
}
stop() {
log_daemon_msg "Unsetting routes"
route del default dev eth1 && echo -n "eth1 "
route del default dev eth2 && echo -n "eth2 "
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|reload}"
;;
esac