aboutsummaryrefslogtreecommitdiff
blob: 040ef779d761a9e0cfa337d86ed219967c259a7b (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
--- client/scripts/bsdos
+++ client/scripts/bsdos
@@ -84,6 +84,9 @@
 if [ x$new_interface_mtu != x ]; then
   mtu_arg="mtu $new_interface_mtu"
 fi
+if [ x$IF_METRIC != x ]; then
+  metric_arg="metric $IF_METRIC"
+fi
 
 if [ x$reason = xMEDIUM ]; then
   eval "ifconfig $interface $medium"
@@ -141,7 +144,7 @@
   if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \
      [ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then
     eval "ifconfig $interface inet $new_ip_address $new_netmask_arg \
-					$new_broadcast_arg $mtu_arg $medium"
+			$new_broadcast_arg $mtu_arg $metric_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
@@ -198,7 +201,7 @@
     route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
   fi
   eval "ifconfig $interface inet $new_ip_address $new_netmask_arg \
-					$new_broadcast_arg $mtu_arg $medium"
+			$new_broadcast_arg $mtu_arg $metric_arg $medium"
   sleep 1
   if [ "$new_routers" != "" ]; then
     set $new_routers
--- client/scripts/freebsd
+++ client/scripts/freebsd
@@ -94,6 +94,9 @@
 if [ x$new_interface_mtu != x ]; then
   mtu_arg="mtu $new_interface_mtu"
 fi
+if [ x$IF_METRIC != x ]; then
+  metric_arg="metric $IF_METRIC"
+fi
 
 if [ x$reason = xMEDIUM ]; then
   eval "ifconfig $interface $medium"
@@ -151,7 +154,7 @@
   if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \
      [ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then
     eval "ifconfig $interface inet $new_ip_address $new_netmask_arg \
-					$new_broadcast_arg $mtu_arg $medium"
+			$new_broadcast_arg $mtu_arg $metric_arg $medium"
     $LOGGER "New IP Address ($interface): $new_ip_address"
     $LOGGER "New Subnet Mask ($interface): $new_subnet_mask"
     $LOGGER "New Broadcast Address ($interface): $new_broadcast_address"
@@ -215,7 +218,7 @@
     route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
   fi
   eval "ifconfig $interface inet $new_ip_address $new_netmask_arg \
-					$new_broadcast_arg $mtu_arg $medium"
+			$new_broadcast_arg $mtu_arg $metric_arg $medium"
   $LOGGER "New IP Address ($interface): $new_ip_address"
   $LOGGER "New Subnet Mask ($interface): $new_subnet_mask"
   $LOGGER "New Broadcast Address ($interface): $new_broadcast_address"
--- client/scripts/linux
+++ client/scripts/linux
@@ -83,11 +83,6 @@
   fi
 fi
 
-release=`uname -r`
-release=`expr $release : '\(.*\)\..*'`
-relminor=`echo $release |sed -e 's/[0-9]*\.\([0-9][0-9]*\)\(\..*\)*$/\1/'`
-relmajor=`echo $release |sed -e 's/\([0-9][0-9]*\)\..*$/\1/'`
-
 if [ x$new_broadcast_address != x ]; then
   new_broadcast_arg="broadcast $new_broadcast_address"
 fi
@@ -106,6 +101,9 @@
 if [ x$new_interface_mtu != x ]; then
   mtu_arg="mtu $new_interface_mtu"
 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).
@@ -117,15 +115,7 @@
     # Bring down alias interface. Its routes will disappear too.
     ifconfig $interface:0- inet 0
   fi
-  if [ $relmajor -lt 2 ] || ( [ $relmajor -eq 2 ] && [ $relminor -eq 0 ] )
-   then
-    ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 \
-		broadcast 255.255.255.255 up
-    # Add route to make broadcast work. Do not omit netmask.
-    route add default dev $interface netmask 0.0.0.0
-  else
-    ifconfig $interface 0 up
-  fi
+  ifconfig $interface 0 up
 
   # We need to give the kernel some time to get the interface up.
   sleep 1
@@ -164,12 +154,14 @@
     ifconfig $interface inet $new_ip_address $new_subnet_arg \
 					$new_broadcast_arg $mtu_arg
     # Add a network route to the computed network address.
-    if [ $relmajor -lt 2 ] || \
-		( [ $relmajor -eq 2 ] && [ $relminor -eq 0 ] ); then
-      route add -net $new_network_number $new_subnet_arg dev $interface
+    if [ x$IF_METRIC != x ] && [ x$IF_METRIC != x0 ]; then
+      route del -net $new_network_number $new_subnet_arg \
+        dev $interface
+      route add -net $new_network_number $new_subnet_arg $metric_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 ];
@@ -213,12 +205,15 @@
       ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
       route add -host $alias_ip_address dev $interface:0
     fi
-    if [ $relmajor -lt 2 ] || \
-		( [ $relmajor -eq 2 ] && [ $relminor -eq 0 ] ); then
-      route add -net $new_network_number
+    # Add a network route to the computed network address.
+    if [ x$IF_METRIC != x ] && [ x$IF_METRIC != x0 ]; then
+      route del -net $new_network_number $new_subnet_arg \
+        dev $interface
+      route add -net $new_network_number $new_subnet_arg $metric_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
     make_resolv_conf
     exit_with_hooks 0
--- client/scripts/netbsd
+++ client/scripts/netbsd
@@ -84,6 +84,9 @@
 if [ x$new_interface_mtu != x ]; then
   mtu_arg="mtu $new_interface_mtu"
 fi
+if [ x$IF_METRIC != x ]; then
+  metric_arg="metric $IF_METRIC"
+fi
 
 if [ x$reason = xMEDIUM ]; then
   eval "ifconfig $interface $medium"
@@ -141,7 +144,7 @@
   if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \
      [ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then
     eval "ifconfig $interface inet $new_ip_address $new_netmask_arg \
-					$new_broadcast_arg $mtu_arg $medium"
+			$new_broadcast_arg $mtu_arg $metric_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
@@ -198,7 +201,7 @@
     route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
   fi
   eval "ifconfig $interface inet $new_ip_address $new_netmask_arg \
-					$new_broadcast_arg $mtu_arg $medium"
+			$new_broadcast_arg $mtu_arg $metric_arg $medium"
   sleep 1
   if [ "$new_routers" != "" ]; then
     set $new_routers
--- client/scripts/solaris
+++ client/scripts/solaris
@@ -79,6 +79,9 @@
 if [ x$new_interface_mtu != x ]; then
   mtu_arg="mtu $new_interface_mtu"
 fi
+if [ x$IF_METRIC != x ]; then
+  metric_arg="metric $IF_METRIC"
+fi
 
 ifconfig=/sbin/ifconfig
 
@@ -141,7 +144,7 @@
   if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \
      [ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then
     eval "$ifconfig $interface inet $new_ip_address $new_netmask_arg \
-					$new_broadcast_arg $mtu_arg $medium"
+			$new_broadcast_arg $mtu_arg $metric_arg $medium"
     route add $new_ip_address 127.1 1 >/dev/null 2>&1
     for router in $new_routers; do
       route add default $router 1 >/dev/null 2>&1
@@ -182,7 +185,7 @@
     route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
   fi
   eval "$ifconfig $interface inet $new_ip_address $new_netmask_arg \
-					$new_broadcast_arg $mtu_arg $medium"
+			$new_broadcast_arg $mtu_arg $metric_arg $medium"
   sleep 1
   set $new_routers
   if ping -s -n -I 1 $1 64 1; then