-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from mariux64/add-uvpn
Add uvpn
- Loading branch information
Showing
3 changed files
with
428 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
#!/bin/bash | ||
|
||
ip=/sbin/ip | ||
|
||
### | ||
### DHCPv4 Handlers | ||
### | ||
|
||
if [ x$new_broadcast_address != x ]; then | ||
new_broadcast_arg="broadcast $new_broadcast_address" | ||
fi | ||
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" | ||
fi | ||
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 = xBOUND ] || [ x$reason = xRENEW ] || \ | ||
[ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then | ||
|
||
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 | ||
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 | ||
|
||
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 | ||
# 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 | ||
ip route add $router dev $interface | ||
fi | ||
ip route add default via $router dev $interface $metric_arg | ||
done | ||
else | ||
# we haven't changed the address, have we changed other options | ||
# that we wish to update? | ||
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 | ||
ip route del default via $router | ||
done | ||
for router in $new_routers; do | ||
if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then | ||
ip route add $router dev $interface | ||
fi | ||
ip route add default via $router dev $interface $metric_arg | ||
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 | ||
ip route add $alias_ip_address dev $interface:0 | ||
fi | ||
exit 0 | ||
fi | ||
|
||
if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ] || [ x$reason = xRELEASE ] \ | ||
|| [ x$reason = xSTOP ]; then | ||
if [ x$alias_ip_address != x ]; then | ||
# Turn off alias interface. | ||
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 | ||
fi | ||
if [ x$alias_ip_address != x ]; then | ||
ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg | ||
ip route add $alias_ip_address dev $interface:0 | ||
fi | ||
exit 0 | ||
fi | ||
|
||
if [ x$reason = xTIMEOUT ]; then | ||
if [ x$alias_ip_address != x ]; then | ||
ifconfig $interface:0- inet 0 | ||
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 | ||
ip route add $alias_ip_address dev $interface:0 | ||
fi | ||
for router in $new_routers; do | ||
if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then | ||
ip route add $router dev $interface | ||
fi | ||
ip route add default via $router dev $interface $metric_arg | ||
done | ||
exit 0 | ||
fi | ||
ifconfig $interface inet 0 down | ||
exit 1 | ||
fi | ||
|
||
exit 0 |
Oops, something went wrong.