0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

YAMAHA RTシリーズのACLをテストするPERL

Posted at

自宅でyamahaのルータを使っていて、擬似FWとしてACLを入れている。通信の許可・拒否をシミュレートするPERLを作成した。

  • 対応するACLの書式は一部限定となっている
  • 会社のCiscoACLに対応したものとしたいが、まず初歩として作成

結果サンプル

検証パターン -> ヒットしたACLの番号:ACLの内容

lan2 in 192.168.0.1 192.168.0.1 tcp netbios_ns 99999 -> 130010:pass 192.168.0.0/16 192.168.0.0/16 tcp,udp 445,netbios_ns-netbios_ssn *
lan2 in  8.8.8.8 192.168.0.120 tcp * 2222 -> 160230:pass-log * 192.168.0.120 tcp * 2222
lan2 out 192.168.0.120 8.8.8.8 tcp 2222 * -> 260230:pass-log 192.168.0.120 * tcp 2222 *
lan2 in  8.8.8.8 192.168.0.1 tcp * 2222 -> 919999:reject * * * * *
lan2 out 192.168.0.1 8.8.8.8 tcp 2222 * -> 929999:pass * * * * *

ソース

Packege

オブジェクト志向にはなっていません。試験が足りていません。
Package

ドライバ

コンフィグファイル名を引数で、標準入力からテストパターンを入力してチェックする。

./ymh_ut01_sotu.pl /path/to/yamaha.cf < test-pattern.txt
ymh_ut01_sotu.pl
# !/usr/bin/perl
use strict;
require './ip_ymhcommon.pl';

$YmhCfg::Cfgfname = $ARGV[0];
die "die at Conf_Read()\n" if (YmhCfg::Conf_Read() == $YmhCfg::RtnERR);
$YmhCfg::DBG1 = 0;
$YmhCfg::DBG4 = 0;

# YmhCfg::dump_Mnemonic();
# YmhCfg::dump_SecFilter_all();
# YmhCfg::dump_SecFilter("lan2", "in");
# YmhCfg::dump_SecFilter("lan2", "out");

YmhCfg::checkmain();
yamaha.cfg
ip lan2 secure filter in 130010 130011 139999 160010 160011 160020 160021 160030 160031 160041 160051 160210 160220 160230 160240 160250 160260 160270 160280 160290 160300 170010 170011 169999 919999
ip lan2 secure filter out 230010 230011 239999 260210 260220 260230 260240 260250 260260 260270 260280 260290 260300 270010 270011 929999

p filter 130010 pass 192.168.0.0/16 192.168.0.0/16 tcp,udp 445,netbios_ns-netbios_ssn *
ip filter 130011 pass 192.168.0.0/16 192.168.0.0/16 tcp,udp * 445,netbios_ns-netbios_ssn
ip filter 139999 pass 192.168.0.0/16 192.168.0.0/16 * * *
ip filter 160010 pass * * icmp
ip filter 160011 pass * * established
ip
....
ip filter 160210 pass-log * 192.168.0.103 tcp * https
ip filter 160220 pass-log * 192.168.0.120 tcp * www,8080
ip filter 160230 pass-log * 192.168.0.120 tcp * 2222
....
test-pattern.txt
$ cat ymh_test01_ip01.txt 
# PORT FROM
lan2 in 192.168.0.1 192.168.0.1 tcp netbios_ns 99999
# PORT TO
lan2 in 192.168.0.1 192.168.0.1 udp 99999 netbios_ssn

検証パターンの書式

書式:IF DIRECTION FROM-IP TO-IP PROTOCOL FROM-PORT TO-PORT
IFとDIRECTIONは、コンフィグのこの箇所を一致します。

  • IF:ip [lan2] secure filter in
  • DIRECTION:ip lan2 secure filter [in]
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?