avahi-autoipd实验

avahi-autoipd的link-local实验参考:
https://developer.apple.com/library/archive/qa/qa1357/_index.html
前提:

  1. windows上安装Bonjour服务 和Bonjour软件
  2. linux设备上有avahi的服务

windows

下面命令二选一:

route add 169.254.0.0 mask 255.255.0.0 169.254.0.111 /
route add 0.0.0.0 mask 0.0.0.0 169.254.0.222
ipconfig

linux

linux设备上执行

/etc/avahi/avahi-autoipd.action eth0 169.254.0.210
ifconfig

下面是/etc/avahi/avahi-autoipd.action脚本内容

set -e

# Command line arguments:
#   $1 event that happened:
#          BIND:     Successfully claimed address
#          CONFLICT: An IP address conflict happened
#          UNBIND:   The IP address is no longer needed
#          STOP:     The daemon is terminating
#   $2 interface name
#   $3 IP adddress

if [ -x /bin/ip -o -x /sbin/ip ] ; then

    # We have the Linux ip tool from the iproute package

    case "$1" in
        BIND)
            ip addr add "$3"/16 brd 169.254.255.255 label "$2:avahi" scope link dev "$2" 
            ;;

        CONFLICT|UNBIND|STOP)
            ip addr del "$3"/16 brd 169.254.255.255 label "$2:avahi" scope link dev "$2" 
            ;;

        *)
            echo "Unknown event $1" >&2
            exit 1
            ;;
    esac

elif [ -x /bin/ifconfig -o -x /sbin/ifconfig ] ; then

    # We have the old ifconfig tool

    case "$1" in
        BIND)
            ifconfig "$2:3" inet "$3" netmask 255.255.0.0 broadcast 169.254.255.255 up
            ;;

        CONFLICT|STOP|UNBIND)
            ifconfig "$2:3" down
            ;;

        *)
            echo "Unknown event $1" >&2
            exit 1
            ;;
    esac

else

    echo "No network configuration tool found." >&2
    exit 1

fi

exit 0

你可能感兴趣的:(linux,协议)