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
|
Found this patch here:
https://lists.isc.org/pipermail/dhcp-users/2011-January/012910.html
and made some adjustments/updates to make it work with this version.
Wasn't able to find that why this patch was not accepted by ISC DHCP developers.
Upstream-Status: Pending
Signed-off-by: Muhammad Shakeel <muhammad_shakeel@mentor.com>
--- dhcp-4.2.5-P1/client/scripts/linux.orig 2013-09-04 12:22:55.000000000 +0500
+++ dhcp-4.2.5-P1/client/scripts/linux 2013-09-04 12:52:19.068761518 +0500
@@ -103,17 +103,11 @@
if [ x$old_broadcast_address != x ]; then
old_broadcast_arg="broadcast $old_broadcast_address"
fi
-if [ x$new_subnet_mask != x ]; then
- new_subnet_arg="netmask $new_subnet_mask"
-fi
-if [ x$old_subnet_mask != x ]; then
- old_subnet_arg="netmask $old_subnet_mask"
-fi
-if [ x$alias_subnet_mask != x ]; then
- alias_subnet_arg="netmask $alias_subnet_mask"
+if [ -n "$new_subnet_mask" ]; then
+ new_mask="/$new_subnet_mask"
fi
-if [ x$new_interface_mtu != x ]; then
- mtu_arg="mtu $new_interface_mtu"
+if [ -n "$alias_subnet_mask" ]; then
+ alias_mask="/$alias_subnet_mask"
fi
if [ x$IF_METRIC != x ]; then
metric_arg="metric $IF_METRIC"
@@ -127,9 +121,9 @@
if [ x$reason = xPREINIT ]; then
if [ x$alias_ip_address != x ]; then
# Bring down alias interface. Its routes will disappear too.
- ifconfig $interface:0- inet 0
+ ${ip} -4 addr flush dev ${interface} label ${interface}:0
fi
- ifconfig $interface 0 up
+ ${ip} link set dev ${interface} up
# We need to give the kernel some time to get the interface up.
sleep 1
@@ -156,25 +150,30 @@
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
+ ${ip} -4 addr flush dev ${interface} label ${interface}: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} -4 addr flush dev ${interface} label ${interface}
fi
if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \
[ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then
- ifconfig $interface inet $new_ip_address $new_subnet_arg \
- $new_broadcast_arg $mtu_arg
+ ${ip} -4 addr add ${new_ip_address}${new_mask} ${new_broadcast_arg} \
+ dev ${interface} label ${interface}
+ if [ -n "$new_interface_mtu" ]; then
+ # set MTU
+ ${ip} link set dev ${interface} mtu ${new_interface_mtu}
+ fi
# Add a network route to the computed network address.
for router in $new_routers; do
if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then
- route add -host $router dev $interface
+ ${ip} -4 route add ${router} dev $interface >/dev/null 2>&1
fi
- route add default gw $router $metric_arg dev $interface
+ ${ip} -4 route add default via ${router} dev ${interface} \
+ ${metric_arg} >/dev/null 2>&1
done
else
# we haven't changed the address, have we changed other options
@@ -182,21 +181,23 @@
if [ x$new_routers != x ] && [ x$new_routers != x$old_routers ] ; then
# if we've changed routers delete the old and add the new.
for router in $old_routers; do
- route del default gw $router
+ ${ip} -4 route delete default via ${router}
done
for router in $new_routers; do
if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then
- route add -host $router dev $interface
- fi
- route add default gw $router $metric_arg dev $interface
+ ${ip} -4 route add ${router} dev $interface >/dev/null 2>&1
+ fi
+ ${ip} -4 route add default via ${router} dev ${interface} \
+ ${metric_arg} >/dev/null 2>&1
done
fi
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
+ ${ip} -4 addr flush dev ${interface} label ${interface}:0
+ ${ip} -4 addr add ${alias_ip_address}${alias_mask} \
+ dev ${interface} label ${interface}:0
+ ${ip} -4 route add ${alias_ip_address} dev ${interface} >/dev/null 2>&1
fi
make_resolv_conf
exit_with_hooks 0
@@ -206,42 +207,49 @@
|| [ x$reason = xSTOP ]; then
if [ x$alias_ip_address != x ]; then
# Turn off alias interface.
- ifconfig $interface:0- inet 0
+ ${ip} -4 addr flush dev ${interface} label ${interface}: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
+ ${ip} -4 addr flush dev ${interface} label ${interface}
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
+ ${ip} -4 addr add ${alias_ip_address}${alias_network_arg} \
+ dev ${interface} label ${interface}:0
+ ${ip} -4 route add ${alias_ip_address} dev ${interface} >/dev/null 2>&1
fi
exit_with_hooks 0
fi
if [ x$reason = xTIMEOUT ]; then
if [ x$alias_ip_address != x ]; then
- ifconfig $interface:0- inet 0
+ ${ip} -4 addr flush dev ${interface} label ${interface}:0
+ fi
+ ${ip} -4 addr add ${new_ip_address}${new_mask} ${new_broadcast_arg} \
+ dev ${interface} label ${interface}
+ if [ -n "$new_interface_mtu" ]; then
+ # set MTU
+ ip link set dev ${interface} mtu ${new_interface_mtu}
fi
- ifconfig $interface inet $new_ip_address $new_subnet_arg \
- $new_broadcast_arg $mtu_arg
set $new_routers
if ping -q -c 1 $1; then
if [ x$new_ip_address != x$alias_ip_address ] && \
[ x$alias_ip_address != x ]; then
- ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
- route add -host $alias_ip_address dev $interface:0
+ ${ip} -4 addr add ${alias_ip_address}${alias_mask} \
+ dev ${interface} label ${interface}:0
+ ${ip} -4 route add ${alias_ip_address} dev ${interface} >/dev/null 2>&1
fi
for router in $new_routers; do
if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then
- route add -host $router dev $interface
+ ${ip} -4 route add ${router} dev $interface >/dev/null 2>&1
fi
- route add default gw $router $metric_arg dev $interface
+ ${ip} -4 route add default via ${router} dev ${interface} \
+ ${metric_arg} >/dev/null 2>&1
done
make_resolv_conf
exit_with_hooks 0
fi
- ifconfig $interface inet 0 down
+ ${ip} -4 addr flush dev ${interface}
exit_with_hooks 1
fi
|