3
3

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.

FreeRADIUSでレルムをもとにVLAN番号を返す

Last updated at Posted at 2016-03-30

はじめに

無線LANなどで1X認証する際に「ID@グループ名」のようなレルム付きアカウントにして
利用するネットワークを決めれるとうれしいですね

設定方法

CentOS6にバンドルされたバージョン2系のFreeRADIUSを使います

/etc/raddb/radiusd.conf
instantiate {
        echo
}

としてechoを有効にします

/etc/raddb/users
DEFAULT         User-Name =~ "^([^@]+)@([a-z]+)"
                Tunnel-Type = "VLAN",
                Tunnel-Medium-Type = "IEEE-802",
                Tunnel-Private-Group-Id = `%{echo:/etc/raddb/conv_vlan.sh %{1} %{2} %{Client-Shortname}}`,

シェルスクリプトはこんな感じです

conv_vlan.sh
#!/bin/sh

PATH='/usr/local/bin:/usr/bin:/bin'
USERLIST='/etc/raddb/userlist'

test $# -eq 3 || exit 1
case "${3}" in
  'network1')
    VLANLIST='/etc/raddb/vlanlist1'
    ;;
  'network2')
    VLANLIST='/etc/raddb/vlanlist2'
    ;;
  *)
    exit 2
    ;;
esac
grep -q "^${1}@${2}$" ${USERLIST} || exit 3
( grep "^${2}:" ${VLANLIST} | cut -d: -f2 | tr -d "\n" ) || exit 4
exit 0

そのグループのVLANが使えるユーザリスト

userlist
taro@hoge
jiro@hoge
saburo@fuga

グループ名とVLAN番号の変換テーブル

vlanlist1
hoge:100
fuga:200

とするとTunnel-Private-Group-Idに適切なVLAN番号が割り当てられます
例えばあるネットワークだとhogeは100番だけど違うネットワークだと別の番号になる場合は別途VLAN変換テーブルvlanlist2を準備するとよいです

無線LANのAPのアドレス帯で
%{Client-Shortname}を分けるには下記のような設定をします

/etc/raddb/clients.conf
client 192.168.0.0/24 {
        shortname   = network1
}
client 192.168.1.0/24 {
        shortname   = network2
}
3
3
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
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?