1#!/usr/bin/perl 2# 3# Copyright (C) Internet Systems Consortium, Inc. ("ISC") 4# 5# This Source Code Form is subject to the terms of the Mozilla Public 6# License, v. 2.0. If a copy of the MPL was not distributed with this 7# file, you can obtain one at https://mozilla.org/MPL/2.0/. 8# 9# See the COPYRIGHT file distributed with this work for additional 10# information regarding copyright ownership. 11 12# Test whether the interfaces on 10.53.0.* are up. 13 14require 5.001; 15 16use Socket; 17use Getopt::Long; 18 19my $port = 0; 20my $id = 0; 21GetOptions("p=i" => \$port, 22 "i=i" => \$id); 23 24my @ids; 25if ($id != 0) { 26 @ids = ($id); 27} else { 28 @ids = (1..8); 29} 30 31foreach $id (@ids) { 32 my $addr = pack("C4", 10, 53, 0, $id); 33 my $sa = pack_sockaddr_in($port, $addr); 34 socket(SOCK, PF_INET, SOCK_STREAM, getprotobyname("tcp")) 35 or die "$0: socket: $!\n"; 36 setsockopt(SOCK, SOL_SOCKET, SO_REUSEADDR, pack("l", 1)); 37 38 bind(SOCK, $sa) 39 or die sprintf("$0: bind(%s, %d): $!\n", 40 inet_ntoa($addr), $port); 41 close(SOCK); 42} 43