#!/bin/shmake_resolv_conf() {if [ x"$new_domain_name_servers" != x ]; thencat /dev/null > /etc/resolv.conf.dhclientif [ x"$new_domain_search" != x ]; thenecho search $new_domain_search >> /etc/resolv.conf.dhclientelif [ x"$new_domain_name" != x ]; then# Note that the DHCP 'Domain Name Option' is really just a domain# name, and that this practice of using the domain name option as# a search path is both nonstandard and deprecated.echo search $new_domain_name >> /etc/resolv.conf.dhclientfifor nameserver in $new_domain_name_servers; doecho nameserver $nameserver >>/etc/resolv.conf.dhclientdonemv /etc/resolv.conf.dhclient /etc/resolv.confelif [ "x${new_dhcp6_name_servers}" != x ] ; thencat /dev/null > /etc/resolv.conf.dhclient6chmod 644 /etc/resolv.conf.dhclient6if [ "x${new_dhcp6_domain_search}" != x ] ; thenecho search ${new_dhcp6_domain_search} >> /etc/resolv.conf.dhclient6fifor nameserver in ${new_dhcp6_name_servers} ; do# If the nameserver has a link-local address# add a <zone_id> (interface name) to it.case $nameserver infe80:*) zone_id="%$interface";;FE80:*) zone_id="%$interface";;*) zone_id="";;esacecho nameserver ${nameserver}$zone_id >> /etc/resolv.conf.dhclient6donemv /etc/resolv.conf.dhclient6 /etc/resolv.conffi}# Must be used on exit. Invokes the local dhcp client exit hooks, if any.exit_with_hooks() {exit_status=1ドルif [ -f /etc/dhclient-exit-hooks ]; then. /etc/dhclient-exit-hooksfi# probably should do something with exit status of the local scriptexit $exit_status}# This function was largely borrowed from dhclient-script that# ships with Centos, authored by Jiri Popelka and David Cantrell# of Redhat. Thanks guys.add_ipv6_addr_with_DAD() {ifconfig ${interface} inet6 ${new_ip6_address}/${new_ip6_prefixlen} aliasif [ ${dad_wait_time} -le 0 ]then# if we're not waiting for DAD, assume we're goodreturn 0fi# Repeatedly test whether newly added address passed# duplicate address detection (DAD)i=0while [ $i -lt ${dad_wait_time} ]; dosleep 1 # give the DAD some timeaddr=$(ifconfig ${interface} \| grep "${new_ip6_address} prefixlen ${new_ip6_prefixlen}")# tentative flag == DAD is still not completetentative=$(echo "${addr}" | grep tentative)# dadfailed flag == address is already in use somewhere elsedadfailed=$(echo "${addr}" | grep duplicated)if [ -n "${dadfailed}" ] ; then# dad failed, remove the addressifconfig ${interface} inet6 ${new_ip6_address}/${new_ip6_prefixlen} -aliasexit_with_hooks 3fiif [ -z "${tentative}" ] ; thenif [ -n "${addr}" ]; then# DAD is overreturn 0else# address was auto-removed (or not added at all)exit_with_hooks 3fifitrue $(( i++ ))donereturn 0}# Invoke the local dhcp client enter hooks, if they exist.if [ -f /etc/dhclient-enter-hooks ]; thenexit_status=0. /etc/dhclient-enter-hooks# allow the local script to abort processing of this state# local script must set exit_status variable to nonzero.if [ $exit_status -ne 0 ]; thenexit $exit_statusfifiif [ x$new_network_number != x ]; thenecho New Network Number: $new_network_numberfiif [ x$new_broadcast_address != x ]; thenecho New Broadcast Address: $new_broadcast_addressnew_broadcast_arg="broadcast $new_broadcast_address"fiif [ x$old_broadcast_address != x ]; thenold_broadcast_arg="broadcast $old_broadcast_address"fiif [ x$new_subnet_mask != x ]; thennew_netmask_arg="netmask $new_subnet_mask"fiif [ x$old_subnet_mask != x ]; thenold_netmask_arg="netmask $old_subnet_mask"fiif [ x$alias_subnet_mask != x ]; thenalias_subnet_arg="netmask $alias_subnet_mask"fiif [ x$reason = xMEDIUM ]; theneval "ifconfig $interface$medium"eval "ifconfig $interface inet -alias 0.0.0.0 $medium" >/dev/null 2>&1sleep 1exit_with_hooks 0fi###### DHCPv4 Handlers###if [ x$reason = xPREINIT ]; thenif [ x$alias_ip_address != x ]; thenifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1fiifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 \broadcast 255.255.255.255 upexit_with_hooks 0fiif [ x$reason = xARPCHECK ] || [ x$reason = xARPSEND ]; thenexit_with_hooks 0;fiif [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \[ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; thencurrent_hostname=`hostname`if [ x$current_hostname = x ] || \[ x$current_hostname = x$old_host_name ]; thenif [ x$current_hostname = x ] || \[ x$new_host_name != x$old_host_name ]; thenhostname $new_host_namefifiif [ x$old_ip_address != x ] && [ x$alias_ip_address != x ] && \[ x$alias_ip_address != x$old_ip_address ]; thenifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1fiif [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ]theneval "ifconfig $interface inet -alias $old_ip_address$medium"route delete $old_ip_address 127.1 >/dev/null 2>&1for router in $old_routers; doroute delete default $router >/dev/null 2>&1doneif [ "$old_static_routes" != "" ]; thenset $old_static_routeswhile [ $# -gt 1 ]; doroute delete 1ドル 2ドルshift; shiftdonefiarp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d 1円/p' |shfiif [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \[ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; theneval "ifconfig $interface inet $new_ip_address$new_netmask_arg\$new_broadcast_arg$medium"route add $new_ip_address 127.1 >/dev/null 2>&1for router in $new_routers; doroute add default $router >/dev/null 2>&1doneif [ "$new_static_routes" != "" ]; thenset $new_static_routeswhile [ $# -gt 1 ]; doroute add 1ドル 2ドルshift; shiftdonefielse# 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.$LOGGER "New Routers: $new_routers"for router in $old_routers; doroute delete default $router >/dev/null 2>&1donefor router in $new_routers; doroute add default $router >/dev/null 2>&1donefifiif [ x$new_ip_address != x$alias_ip_address ] && [ x$alias_ip_address != x ];thenifconfig $interface inet alias $alias_ip_address $alias_subnet_argroute add $alias_ip_address 127.0.0.1fimake_resolv_confexit_with_hooks 0fiif [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ] || [ x$reason = xRELEASE ] \|| [ x$reason = xSTOP ]; thenif [ x$alias_ip_address != x ]; thenifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1fiif [ x$old_ip_address != x ]; theneval "ifconfig $interface inet -alias $old_ip_address$medium"route delete $old_ip_address 127.1 >/dev/null 2>&1for router in $old_routers; doroute delete default $router >/dev/null 2>&1doneif [ "$old_static_routes" != "" ]; thenset $old_static_routeswhile [ $# -gt 1 ]; doroute delete 1ドル 2ドルshift; shiftdonefiarp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d 1円/p' \|sh >/dev/null 2>&1fiif [ x$alias_ip_address != x ]; thenifconfig $interface inet alias $alias_ip_address $alias_subnet_argroute add $alias_ip_address 127.0.0.1fiexit_with_hooks 0fiif [ x$reason = xTIMEOUT ]; thenif [ x$alias_ip_address != x ]; thenifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1fieval "ifconfig $interface inet $new_ip_address$new_netmask_arg\$new_broadcast_arg$medium"sleep 1if [ "$new_routers" != "" ]; thenset $new_routersif ping -q -c 1 -w 1 1ドル; thenif [ x$new_ip_address != x$alias_ip_address ] && \[ x$alias_ip_address != x ]; thenifconfig $interface inet alias $alias_ip_address $alias_subnet_argroute add $alias_ip_address 127.0.0.1firoute add $new_ip_address 127.1 >/dev/null 2>&1for router in $new_routers; doroute add default $router >/dev/null 2>&1doneset $new_static_routeswhile [ $# -gt 1 ]; doroute add 0ドル 1ドルshift; shiftdonemake_resolv_confexit_with_hooks 0fifieval "ifconfig $interface inet -alias $new_ip_address$medium"for router in $old_routers; doroute delete default $router >/dev/null 2>&1doneif [ "$old_static_routes" != "" ]; thenset $old_static_routeswhile [ $# -gt 1 ]; doroute delete 1ドル 2ドルshift; shiftdonefiarp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d 1円/p' \|sh >/dev/null 2>&1exit_with_hooks 1fi###### DHCPv6 Handlers###if [ ${reason} = PREINIT6 ] ; then# Ensure interface is up.ifconfig ${interface} up# XXX: Remove any stale addresses from aborted clients.# We need to give the kernel some time to active interfaceinterface_up_wait_time=5i=0while [ $i -lt ${interface_up_wait_time} ]; doifconfig ${interface} | grep inactive >/dev/null 2>&1if [ $? -ne 0 ]; thenbreak;fisleep 1true $(( i++ ))done# Wait for duplicate address detection for this interface if the# --dad-wait-time parameter has been specified and is greater than# zero.if [ ${dad_wait_time} -gt 0 ]; then# Check if any IPv6 address on this interface is marked as# tentative.ifconfig ${interface} | grep inet6 | grep tentative \>/dev/null 2>&1if [ $? -eq 0 ]; then# Wait for duplicate address detection to complete or for# the timeout specified as --dad-wait-time.i=0while [ $i -lt ${dad_wait_time} ]; do# We're going to poll for the tentative flag every second.sleep 1ifconfig ${interface} | grep inet6 | grep tentative \>/dev/null 2>&1if [ $? -ne 0 ]; thenbreak;fitrue $(( i++ ))donefifiexit_with_hooks 0fiif [ x${old_ip6_prefix} != x ] || [ x${new_ip6_prefix} != x ] ; thenecho Prefix ${reason} old=${old_ip6_prefix} new=${new_ip6_prefix}exit_with_hooks 0fiif [ ${reason} = BOUND6 ] ; thenif [ x${new_ip6_address} = x ] || [ x${new_ip6_prefixlen} = x ] ; thenexit_with_hooks 2;fi# Add address to interface, check for DAD if dad_wait_time > 0add_ipv6_addr_with_DAD# Check for nameserver options.make_resolv_confexit_with_hooks 0fiif [ ${reason} = RENEW6 ] || [ ${reason} = REBIND6 ] ; then# Make sure nothing has moved around on us.# Nameservers/domains/etc.if [ "x${new_dhcp6_name_servers}" != "x${old_dhcp6_name_servers}" ] ||[ "x${new_dhcp6_domain_search}" != "x${old_dhcp6_domain_search}" ] ; thenmake_resolv_conffiexit_with_hooks 0fiif [ ${reason} = DEPREF6 ] ; thenif [ x${new_ip6_prefixlen} = x ] ; thenexit_with_hooks 2;fi# XXX:# There doesn't appear to be a way to update an addr to indicate# preference.exit_with_hooks 0fiif [ ${reason} = EXPIRE6 -o ${reason} = RELEASE6 -o ${reason} = STOP6 ] ; thenif [ x${old_ip6_address} = x ] || [ x${old_ip6_prefixlen} = x ] ; thenexit_with_hooks 2;fiifconfig ${interface} inet6 -alias ${old_ip6_address}/${old_ip6_prefixlen}exit_with_hooks 0fiexit_with_hooks 0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。