ゲストホットスポットの管理の難しさ(パート1)

この短い記事では、着信ユーザーへのインターネットの配布に関連する大きなサブネットを管理する際の頭痛を軽減する方法を説明します。

基本的なツール:



カットの下に書かれたすべてについて学びたい人は、残りは残りのトピックをよく見てください。

第二部へのリンク



大規模なDHCPサーバーの主な問題



isc-dhcpdを扱ったすべての人は、複数のIPネットワーク内でアクセスを操作することがいかに問題があるかを知っています。 主な問題は、特定のホストへの静的エントリの割り当て、アクセスを提供するためのファイアウォール内のルールのスペル、およびその他の適切なシステム管理者のルーチンです。 このソリューションは、数か月前に文字通り発見、作成、テストされました。 だから...



既存の管理方法



ISC-DHCPDサーバーには、その状態を管理するためのメソッドが実際には組み込まれていません。 唯一の例外は、表示されるomshellアペンデージです。これにより、内部データベースisc-dhcpdへのアクセスが提供され、サーバーを再起動せずに内部フィールドの値を取得および変更できます。 EMNIP構成ファイルdhcpd.confは変更されません。 変更はdhcpd.leasesに自動的に記録されます。 外観、アドレスの発行、およびステータスを制御するために、多くの人はすでにシステムログisc-dhcpdを解析する方法を試し、おそらく結果を得たかもしれませんが、100%満足しているわけではありません。 しかし、経験が示すように、あなたの多くはマニュアルでdhcpdイベントを使用する可能性を逃しました。



dhcpdイベントとは何ですか?



アドレスの発行、解放、削除の各操作(イベント)は、再割り当て可能な内部ハンドラーをトリガーします。 以下はman dhcpd.confからの小さな抜粋です



There are three kinds of events that can happen regarding a lease, and

it is possible to declare statements that occur when any of these

events happen. These events are the commit event, when the server has

made a commitment of a certain lease to a client, the release event,

when the client has released the server from its commitment, and the

expiry event, when the commitment expires.



To declare a set of statements to execute when an event happens, you

must use the on statement, followed by the name of the event, followed

by a series of statements to execute when the event happens, enclosed

in braces. Events are used to implement DNS updates, so you should

not define your own event handlers if you are using the built-in DNS

update mechanism.



The built-in version of the DNS update mechanism is in a text string

towards the top of server/dhcpd.c. If you want to use events for

things other than DNS updates, and you also want DNS updates, you will

have to start out by copying this code into your dhcpd.conf file and

modifying it.







これらの不思議な手紙はどういう意味ですか?

しかし、それらは次のことを意味します。 内部イベントを使用するisc-dhcpdはBINDでDNSレコードを更新できます。イベントハンドラーを再割り当てする場合は、ハンドラーでDNSレコードを更新するためのコードを追加することを忘れないでください。



混乱した? 解き明かす!



dhcpd.conf構成ファイル内のアドレスプールには、外部イベントハンドラーを指定できます。 設定のどの場所でも、次のようになります。

on commit {

}

on release {

}

on expiry {

}







ハンドラーは、アドレスプールに対してもシステム全体に対してもグローバルに定義できます。 最も興味深いのは、以前にアドレスプールで使用されたハンドラーがグローバルハンドラーと重複しないことです。 これにより、DNSの更新は影響を受けません。



実用化



以下に、ハンドラーを呼び出すための現在の構成を示します。 dhcpd内部データベースで使用されている内部データ形式を詳細に分析したり分析したりすることはせず、便利になる可能性のあるいくつかの点についてのみ説明します。



私たちの場合、ホスト名が空の場合、ホスト名とddnsホスト名のレコードは自動的に生成される必要があります( 注:UTF-8またはその他のエンコーディングのホスト名は空とは見なされません

on commit {

set clientIP = binary-to-ascii(10, 8, ".", leased-address);

set clientMAC = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));

if option host-name = "" {

option host-name = concat( "wifi-" , binary-to-ascii( 10, 8, "", substring( reverse( 1, leased-address), 0, 1)));

ddns-hostname = concat( "wifi-" , binary-to-ascii( 10, 8, "", substring( reverse( 1, leased-address), 0, 1)));

}

set clientHostName = option host-name;

execute("/usr/local/etc/dhcp_helper/publish-ip-mac.pl", "commit", clientIP, clientMAC);

execute("/usr/local/etc/dhcp_helper/publish-ip-mac.pl", "hostname", clientIP, clientHostName);

}



on release {

set clientIP = binary-to-ascii(10, 8, ".", leased-address);

set clientMAC = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));

execute("/usr/local/etc/dhcp_helper/publish-ip-mac.pl", "release", clientIP, clientMAC);

}



on expiry {

set clientIP = binary-to-ascii(10, 8, ".", leased-address);

if(exists agent.remote-id) {

set clientMAC = binary-to-ascii(16, 8, ":", substring(option agent.remote-id, 2, 6));

execute("/usr/local/etc/dhcp_helper/publish-ip-mac.pl", "expiry", clientIP, clientMAC);

} else {

execute("/usr/local/etc/dhcp_helper/publish-ip-mac.pl", "expiry", clientIP);

}







実際、上記のコードの一部が示すように、各タイプの操作に対してパラメーター付きのスクリプトが呼び出されます。 パラメーターはARGVに渡されます。 スクリプトは何でもかまいません(シェルスクリプト、php、python、その他のプログラム)。

さて、リリースと有効期限が切れると、すべてが明らかになるようです。 コミットがアドレスとホスト名に対して別々に2つのスクリプト呼び出しを使用するのはなぜですか? ホスト名がANSIにない場合、ハンドラが愚かにクラッシュし、スクリプトが呼び出されないためです。



さて、甘いスクリプトコードの

#!/usr/bin/perl

use strict;

use warnings;



my $type = shift;

my $ip = shift;

my $mac = shift;



# Fork so we can return control

# to the dhcp server ASAP.

my $pid = fork();



# If we're the child, do whatever we need to do

if($pid == 0) {

open OUT,">>/var/tmp/publish.tmp";

$mac = join(":",map { sprintf("%02s",$_); } split(":",$mac));

print OUT "$type $ip $mac\n";

close OUT;

}









pf、dhcpd、web muzzleを接続してこのすべての経済を管理する方法を学びたいすべての人にとって、続きは第2部になります。

それまでの間、あなたの脳はここに書かれていること、アプリケーションの方法、解決の容易さを知っているので、質問をすることができます。



©Aborche 2011








All Articles