summaryrefslogtreecommitdiff
blob: 50a08fa4d96adf4b43536bd655abae5fe494b7e2 (plain)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
--- client/scripts/bsdos
+++ client/scripts/bsdos
@@ -81,6 +81,9 @@
 if [ x$alias_subnet_mask != x ]; then
   alias_subnet_arg="netmask $alias_subnet_mask"
 fi
+if [ x$IF_METRIC != x ]; then
+  metric_arg="metric $IF_METRIC"
+fi
 
 if [ x$reason = xMEDIUM ]; then
   eval "ifconfig $interface $medium"
@@ -141,7 +141,7 @@
 					$new_broadcast_arg $medium"
     route add $new_ip_address 127.1 >/dev/null 2>&1
     for router in $new_routers; do
-      route add default $router >/dev/null 2>&1
+      route add default $router $metric_arg dev $interface >/dev/null 2>&1
     done
     if [ "$new_static_routes" != "" ]; then
       set $new_static_routes
@@ -207,7 +207,7 @@
       fi
       route add $new_ip_address 127.1 >/dev/null 2>&1
       for router in $new_routers; do
-	route add default $router >/dev/null 2>&1
+	route add default $router $metric_arg dev $interface >/dev/null 2>&1
       done
       set $new_static_routes
       while [ $# -gt 1 ]; do
--- client/scripts/freebsd
+++ client/scripts/freebsd
@@ -91,6 +91,9 @@
 if [ x$alias_subnet_mask != x ]; then
   alias_subnet_arg="netmask $alias_subnet_mask"
 fi
+if [ x$IF_METRIC != x ]; then
+  metric_arg="metric $IF_METRIC"
+fi
 
 if [ x$reason = xMEDIUM ]; then
   eval "ifconfig $interface $medium"
@@ -157,7 +157,7 @@
     fi
     route add $new_ip_address 127.1 >/dev/null 2>&1
     for router in $new_routers; do
-      route add default $router >/dev/null 2>&1
+      route add default $router $metric_arg dev $interface >/dev/null 2>&1
     done
     if [ -n "$new_static_routes" ]; then
       $LOGGER "New Static Routes: $new_static_routes"
@@ -228,7 +228,7 @@
       fi
       route add $new_ip_address 127.1 >/dev/null 2>&1
       for router in $new_routers; do
-	route add default $router >/dev/null 2>&1
+	route add default $router $metric_arg dev $interface >/dev/null 2>&1
       done
       set -- $new_static_routes
       while [ $# -gt 1 ]; do
--- client/scripts/linux
+++ client/scripts/linux
@@ -103,6 +103,9 @@
 if [ x$alias_subnet_mask != x ]; then
   alias_subnet_arg="netmask $alias_subnet_mask"
 fi
+if [ x$IF_METRIC != x ]; then
+  metric_arg="metric $IF_METRIC"
+fi
 
 if [ x$reason = xMEDIUM ]; then
   # Linux doesn't do mediums (ok, ok, media).
@@ -148,13 +148,11 @@
   if [ x$old_ip_address != x ] && [ x$alias_ip_address != x ] && \
 		[ x$alias_ip_address != x$old_ip_address ]; then
     # Possible new alias. Remove old alias.
-    ifconfig $interface:0- inet 0
+    ifconfig $interface:0- inet 0.0.0.0
   fi
   if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ]; then
-    # IP address changed. Bringing down the interface will delete all routes,
-    # and clear the ARP cache.
-    ifconfig $interface inet 0 down
-
+    # IP address changed - set existing to 0. 
+    ifconfig $interface inet 0.0.0.0
   fi
   if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \
      [ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then
@@ -167,14 +165,14 @@
       route add -net $new_network_number $new_subnet_arg dev $interface
     fi
     for router in $new_routers; do
-      route add default gw $router
+      route add default gw $router $metric_arg dev $interface
     done
   fi
   if [ x$new_ip_address != x$alias_ip_address ] && [ x$alias_ip_address != x ];
    then
     ifconfig $interface:0- inet 0
     ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
-    route add -host $alias_ip_address $interface:0
+    route add -host $alias_ip_address dev $interface:0
   fi
   make_resolv_conf
   exit_with_hooks 0
@@ -187,12 +185,12 @@
     ifconfig $interface:0- inet 0
   fi
   if [ x$old_ip_address != x ]; then
-    # Shut down interface, which will delete routes and clear arp cache.
-    ifconfig $interface inet 0 down
+    # Remove old address
+    ifconfig $interface inet 0.0.0.0
   fi
   if [ x$alias_ip_address != x ]; then
     ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
-    route add -host $alias_ip_address $interface:0
+    route add -host $alias_ip_address dev $interface:0
   fi
   exit_with_hooks 0
 fi
@@ -213,15 +211,15 @@
     fi
     if [ $relmajor -lt 2 ] || \
 		( [ $relmajor -eq 2 ] && [ $relminor -eq 0 ] ); then
-      route add -net $new_network_number
+      route add -net $new_network_number dev $interface
     fi
     for router in $new_routers; do
-      route add default gw $router
+      route add default gw $router $metric_arg dev $interface
     done
     make_resolv_conf
     exit_with_hooks 0
   fi
-  ifconfig $interface inet 0 down
+  ifconfig $interface inet 0.0.0.0 
   exit_with_hooks 1
 fi
 
--- client/scripts/netbsd
+++ client/scripts/netbsd
@@ -81,6 +81,9 @@
 if [ x$alias_subnet_mask != x ]; then
   alias_subnet_arg="netmask $alias_subnet_mask"
 fi
+if [ x$IF_METRIC != x ]; then
+  metric_arg="metric $IF_METRIC"
+fi
 
 if [ x$reason = xMEDIUM ]; then
   eval "ifconfig $interface $medium"
@@ -141,7 +141,7 @@
 					$new_broadcast_arg $medium"
     route add $new_ip_address 127.1 >/dev/null 2>&1
     for router in $new_routers; do
-      route add default $router >/dev/null 2>&1
+      route add default $router $metric_arg dev $interface >/dev/null 2>&1
     done
     if [ "$new_static_routes" != "" ]; then
       set $new_static_routes
@@ -207,7 +207,7 @@
       fi
       route add $new_ip_address 127.1 >/dev/null 2>&1
       for router in $new_routers; do
-	route add default $router >/dev/null 2>&1
+	route add default $router $metric_arg dev $interface >/dev/null 2>&1
       done
       set $new_static_routes
       while [ $# -gt 1 ]; do
--- client/scripts/openbsd
+++ client/scripts/openbsd
@@ -81,6 +81,9 @@
 if [ x$alias_subnet_mask != x ]; then
   alias_subnet_arg="netmask $alias_subnet_mask"
 fi
+if [ x$IF_METRIC != x ]; then
+  metric_arg="metric $IF_METRIC"
+fi
 
 if [ x$reason = xMEDIUM ]; then
   eval "ifconfig $interface $medium"
@@ -141,7 +141,7 @@
 					$new_broadcast_arg $medium"
     route add $new_ip_address 127.1 >/dev/null 2>&1
     for router in $new_routers; do
-      route add default $router >/dev/null 2>&1
+       route add default $router $metric_arg dev $interface >/dev/null 2>&1
     done
     if [ "$new_static_routes" != "" ]; then
       set $new_static_routes
@@ -207,7 +207,7 @@
       fi
       route add $new_ip_address 127.1 >/dev/null 2>&1
       for router in $new_routers; do
-	route add default $router >/dev/null 2>&1
+	route add default $router $metric_arg dev $interface >/dev/null 2>&1
       done
       set $new_static_routes
       while [ $# -gt 1 ]; do