自宅システム構築シリーズは以下から参照できます。

はじめに
前回の記事で自宅システム構築プロジェクトの土台となるサーバ(自作PC)を組み立てました。
これからこいつにはサーバとして稼働していただく予定なんですが、、
まずはこいつを接続するための基礎ネットワークを構築していこうと思います。
使用する機器
自宅のネットワークで使用する機器は以下に決定しました。
ルータやスイッチはCisco機器で各インターフェース速度が1Gbpsで、なるべく安価なものを選びました。
無線APはほどほどに新しめの機能を持ち、SSIDごとにVLANを分けられるもので選定しました。
色々悩みましたが、netgearの機器が比較的安くて機能が豊富なのでこれに決定!
ルータ‥C891FJ-K9
スイッチ‥Catalyst2960CG-8TC-L
無線AP‥WAC510-10000S
構築
とりあえず簡単な構成図作ってみました。

ある程度試行錯誤しながらも先日やっと構築が完了しました。
こだわりポイントをいくつか紹介します。
こだわりポイント
VLAN
解説
VLANは3と5と17で分けています。ちなみにこの数字はフェルマー素数から取っています(笑)
VLAN 3は管理用、5は自宅のイントラ通信用、17はゲスト通信用のVLANとなっています。無線APには自分が接続する用SSIDと来客用SSIDそれぞれで接続することができ、接続したSSIDによってVLANで分けられるようになっています。
config
ルータ
interface GigabitEthernet0
switchport trunk native vlan 3
switchport mode trunk
no ip address
!
interface GigabitEthernet1
switchport trunk native vlan 3
switchport mode trunk
!
スイッチ
interface GigabitEthernet0/1
switchport trunk native vlan 3
switchport mode trunk
IPセグメント
解説
自宅なのでもちろんプライベートIPセグメントから割り当てています。第3オクテットの数字はVLAN番号と合わせています。
config
ルータ
interface Vlan3
ip address 192.168.3.254 255.255.255.0
ip nat inside
ip virtual-reassembly in
ip verify unicast source reachable-via any
!
interface Vlan5
ip address 192.168.5.254 255.255.255.0
ip helper-address 192.168.254.171
ip nat inside
ip virtual-reassembly in
ip verify unicast source reachable-via any
!
interface Vlan17
ip address 192.168.17.254 255.255.255.0
ip access-group guest-ACL in
ip nat inside
ip virtual-reassembly in
ip verify unicast source reachable-via any
!
interface Vlan254
ip address 192.168.254.254 255.255.255.0
ip nat inside
ip virtual-reassembly in
ip verify unicast source reachable-via any
!
スイッチ
interface Vlan3
ip address 192.168.3.221 255.255.255.0
!
NAPT
解説
キャリアからのグローバルIPアドレスはルータで受け取っているため、インターネット接続するためにはルータでNAPTを行う必要があります。自分の自宅にはグローバルIPアドレスが1つ割り当てられているので、自宅から外に出る通信はそのグローバルIPアドレスを共有する設定を入れました。
config
ルータ
interface GigabitEthernet8
ip nat outside
!
interface Vlan3
ip nat inside
!
interface Vlan5
ip nat inside
!
interface Vlan17
ip nat inside
!
interface Vlan254
ip nat inside
!
ip nat inside source list nat-inside-segment interface GigabitEthernet8 overload
ip access-list standard nat-inside-segment
permit 192.168.3.0 0.0.0.255
permit 192.168.5.0 0.0.0.255
permit 192.168.17.0 0.0.0.255
permit 192.168.254.0 0.0.0.255
!
CBAC
解説
気になるのは外から自宅への攻撃です。
見ての通り、ファイアウォールは置いていないため、何かしらの対策が必要となります。
そこでCiscoルータのセキュリティ機能である、CBACを入れました。これにより、内から発した通信の戻り通信のみ許可し、外から内への通信はすべて遮断することができます。
ちなみにDHCPの通信は許可しないと、グローバルIPアドレスを受け取ることができなくなってしまったため、許可しています。
config
ルータ
ip inspect name CBAC tcp
ip inspect name CBAC udp
ip inspect name CBAC icmp
ip inspect name CBAC ftp
interface GigabitEthernet8
ip access-group from-INTERNET in
ip inspect CBAC out
!
ip access-list extended from-INTERNET
permit udp any any eq bootps
permit udp any any eq bootpc
deny ip any any
ACL
解説
ゲスト用LAN(VLAN 17)がイントラ内にアクセスできてしまってはいけません。そこで自宅のセグメント向け通信はすべて拒否するよう、ルータにACL設定を入れました。またルータにSSHなどでアクセスできてもいけないので、SSHの送信元IPアドレスも制限しています。
ちなみにSSHだけではなく192.168.17.254への全通信のアクセスを拒否してしまうと、通信に問題がありました。あまり原因はわかっていませんが、デフォルトゲートウェイへアクセスができなくなると通信に支障が出るんですかね。なので、アクセス拒否はSSHのみにしています。
config
ルータ
interface Vlan17
ip access-group guest-ACL in
!
ip access-list extended SSH-restrict
permit ip 192.168.5.0 0.0.0.255 any
deny ip any any
ip access-list extended guest-ACL
deny ip any 192.168.3.0 0.0.0.255
deny ip any 192.168.5.0 0.0.0.255
deny ip any 192.168.254.0 0.0.0.255
permit ip any any
!
line vty 0 4
access-class SSH-restrict in
exec-timeout 0 0
privilege level 15
logging synchronous
transport input ssh
line vty 5 15
access-class SSH-restrict in
exec-timeout 0 0
privilege level 15
logging synchronous
transport input ssh
!
スパニングツリー
解説
ルータとスイッチの間のリンクは冗長化したいと思いました。本来はLAGを組みたいのですが、ルータの仕様でLAGは使えないみたいです。
そのためスパニングツリープロトコルで片方のリンクはアクティブ、もう片方はスタンバイで接続しています。一応VLANごとに経由するリンクは振り分けています。
config
ルータ
no spanning-tree vlan 1
spanning-tree vlan 3 priority 0
spanning-tree vlan 5 priority 0
spanning-tree vlan 17 priority 0
no spanning-tree vlan 254
interface GigabitEthernet0
switchport trunk native vlan 3
switchport mode trunk
no ip address
spanning-tree vlan 3 port-priority 0
spanning-tree vlan 5 port-priority 0
!
interface GigabitEthernet1
switchport trunk native vlan 3
switchport mode trunk
no ip address
spanning-tree vlan 17 port-priority 0
!
DHCP
解説
ゲストLAN(VLAN 17)用のDHCPはルータで設定しようと思います。
ちなみにイントラネットワーク(VLAN 5)のDHCPは以前作った自作PCをDHCPサーバにする予定です。
config
ルータ
!ip dhcp excluded-address 192.168.17.161 192.168.17.254
!
ip dhcp pool segment-17
network 192.168.17.0 255.255.255.0
default-router 192.168.17.254
dns-server 8.8.8.8 8.8.4.4
!
全config
ルータとスイッチの全configも載せておきます。
ルータ
RO-001#sh run
Building configuration...
(省略)
version 15.8
service timestamps debug datetime msec localtime show-timezone
service timestamps log datetime msec localtime show-timezone
service password-encryption
service sequence-numbers
!
hostname RO-001
!
boot-start-marker
(省略)
boot-end-marker
!
aqm-register-fnf
!
logging buffered 32768
(省略)
!
aaa new-model
!
!
aaa group server radius G-radius
server name main
server name sub
!
aaa authentication login default group G-radius local
aaa authentication enable default enable group G-radius
aaa authentication dot1x default group radius
!
aaa session-id common
clock timezone JST 9 0
!ip dhcp excluded-address 192.168.17.161 192.168.17.254
!
ip dhcp pool segment-17
network 192.168.17.0 255.255.255.0
default-router 192.168.17.254
dns-server 8.8.8.8 8.8.4.4
!
no ip domain lookup
ip domain name intra.home
ip inspect name CBAC tcp
ip inspect name CBAC udp
ip inspect name CBAC icmp
ip inspect name CBAC ftp
ip cef
no ipv6 cef
!
!
(省略)
!
multilink bundle-name authenticated
!
(省略)
dot1x system-auth-control
!
!
archive
log config
logging enable
hidekeys
!
no spanning-tree vlan 1
spanning-tree vlan 3 priority 0
spanning-tree vlan 5 priority 0
spanning-tree vlan 17 priority 0
no spanning-tree vlan 254
(省略)
!
redundancy
!
class-map match-all intra-class
match access-group name CoPP-intra-segment
!
policy-map intra-policy
class intra-class
police 8000 conform-action transmit exceed-action drop
!
interface BRI0
no ip address
encapsulation hdlc
shutdown
isdn termination multidrop
!
interface FastEthernet0
no ip address
shutdown
duplex auto
speed auto
!
interface GigabitEthernet0
switchport trunk native vlan 3
switchport mode trunk
no ip address
spanning-tree vlan 3 port-priority 0
spanning-tree vlan 5 port-priority 0
!
interface GigabitEthernet1
switchport trunk native vlan 3
switchport mode trunk
no ip address
spanning-tree vlan 17 port-priority 0
!
interface GigabitEthernet2
switchport access vlan 17
no ip address
shutdown
!
interface GigabitEthernet3
switchport access vlan 17
no ip address
shutdown
!
interface GigabitEthernet4
switchport access vlan 17
no ip address
shutdown
!
interface GigabitEthernet5
switchport access vlan 17
no ip address
shutdown
!
interface GigabitEthernet6
switchport access vlan 17
no ip address
shutdown
!
interface GigabitEthernet7
switchport access vlan 17
switchport mode trunk
no ip address
!
interface GigabitEthernet8
ip address dhcp
ip access-group from-INTERNET in
ip nat outside
ip inspect CBAC out
ip virtual-reassembly in
duplex auto
speed auto
media-type rj45
!
interface Vlan1
no ip address
shutdown
!
interface Vlan3
ip address 192.168.3.254 255.255.255.0
ip nat inside
ip virtual-reassembly in
ip verify unicast source reachable-via any
!
interface Vlan5
ip address 192.168.5.254 255.255.255.0
ip helper-address 192.168.254.171
ip nat inside
ip virtual-reassembly in
ip verify unicast source reachable-via any
!
interface Vlan17
ip address 192.168.17.254 255.255.255.0
ip access-group guest-ACL in
ip nat inside
ip virtual-reassembly in
ip verify unicast source reachable-via any
!
interface Vlan254
ip address 192.168.254.254 255.255.255.0
ip nat inside
ip virtual-reassembly in
ip verify unicast source reachable-via any
!
interface Async3
no ip address
encapsulation slip
!
ip forward-protocol nd
no ip http server
no ip http secure-server
!
!
ip ftp source-interface Vlan3
ip nat inside source list nat-inside-segment interface GigabitEthernet8 overload
ip ssh version 2
!
ip access-list standard CoPP-intra-segment
deny 192.168.3.0 0.0.0.255
deny 192.168.5.0 0.0.0.255
deny 192.168.254.0 0.0.0.255
permit any
ip access-list standard nat-inside-segment
permit 192.168.3.0 0.0.0.255
permit 192.168.5.0 0.0.0.255
permit 192.168.17.0 0.0.0.255
permit 192.168.254.0 0.0.0.255
!
ip access-list extended SSH-restrict
permit ip 192.168.5.0 0.0.0.255 any
deny ip any any
ip access-list extended from-INTERNET
permit udp any any eq bootps
permit udp any any eq bootpc
deny ip any any
ip access-list extended guest-ACL
deny ip any 192.168.3.0 0.0.0.255
deny ip any 192.168.5.0 0.0.0.255
deny ip any 192.168.254.0 0.0.0.255
permit ip any any
!
ip radius source-interface Vlan3
logging source-interface Vlan3
logging host 192.168.254.171
ipv6 ioam timestamp
!
snmp-server community intrasnmp RW
snmp-server ifindex persist
snmp-server trap-source Vlan3
snmp-server enable traps snmp authentication linkdown linkup coldstart warmstart
snmp-server enable traps aaa_server
snmp-server enable traps config-copy
snmp-server enable traps config
snmp-server enable traps cpu threshold
snmp-server enable traps syslog
snmp-server enable traps firewall serverstatus
snmp-server host 192.168.254.171 informs version 2c intrasnmp
!
radius server main
address ipv4 192.168.254.181 auth-port 1812 acct-port 1813
(省略)
!
radius server sub
address ipv4 192.168.254.182 auth-port 1812 acct-port 1813
(省略)
!
control-plane
!
mgcp behavior rsip-range tgcp-only
mgcp behavior comedia-role none
mgcp behavior comedia-check-media-src disable
mgcp behavior comedia-sdp-force disable
!
mgcp profile default
!
line con 0
exec-timeout 0 0
privilege level 15
(省略)
logging synchronous
no modem enable
line aux 0
exec-timeout 0 0
privilege level 15
(省略)
logging synchronous
line 3
modem InOut
speed 115200
flowcontrol hardware
line vty 0 4
access-class SSH-restrict in
exec-timeout 0 0
privilege level 15
logging synchronous
transport input ssh
line vty 5 15
access-class SSH-restrict in
exec-timeout 0 0
privilege level 15
logging synchronous
transport input ssh
!
scheduler allocate 20000 1000
ntp source Vlan3
ntp server 192.168.254.171
!
end
スイッチ
SW-001#sh run
Building configuration...
(省略)
version 15.2
no service pad
service timestamps debug datetime msec localtime show-timezone
service timestamps log datetime msec localtime show-timezone
service password-encryption
service sequence-numbers
!
hostname SW-001
!
boot-start-marker
boot-end-marker
!
logging buffered 32768
(省略)
!
(省略)
aaa new-model
!
!
aaa group server radius G-radius
server name main
server name sub
!
aaa authentication login default group G-radius local
aaa authentication enable default enable group G-radius
aaa authentication dot1x default group radius
!
aaa session-id common
clock timezone JST 9 0
!
no ip domain-lookup
ip domain-name intra.home
ip name-server 8.8.8.8
ip name-server 8.8.4.4
!
archive
log config
logging enable
hidekeys
dot1x system-auth-control
!
spanning-tree mode pvst
spanning-tree portfast bpduguard default
spanning-tree extend system-id
no spanning-tree vlan 1
!
vlan internal allocation policy ascending
!
ip ftp source-interface Vlan3
ip ssh version 2
!
interface GigabitEthernet0/1
switchport trunk native vlan 3
switchport mode trunk
!
interface GigabitEthernet0/2
switchport access vlan 5
switchport mode access
authentication event fail retry 0 action authorize vlan 17
authentication event server dead action authorize vlan 17
authentication event no-response action authorize vlan 17
authentication event server alive action reinitialize
authentication order mab dot1x
authentication priority mab dot1x
authentication port-control auto
mab
dot1x pae authenticator
spanning-tree portfast
!
interface GigabitEthernet0/3
switchport access vlan 17
switchport mode access
spanning-tree portfast
!
interface GigabitEthernet0/4
switchport access vlan 5
switchport mode access
authentication event fail retry 0 action authorize vlan 17
authentication event server dead action authorize vlan 17
authentication event no-response action authorize vlan 17
authentication event server alive action reinitialize
authentication order mab dot1x
authentication priority mab dot1x
authentication port-control auto
mab
dot1x pae authenticator
spanning-tree portfast
!
interface GigabitEthernet0/5
switchport access vlan 5
switchport mode access
authentication event fail retry 0 action authorize vlan 17
authentication event server dead action authorize vlan 17
authentication event no-response action authorize vlan 17
authentication event server alive action reinitialize
authentication order mab dot1x
authentication priority mab dot1x
authentication port-control auto
mab
dot1x pae authenticator
spanning-tree portfast
!
interface GigabitEthernet0/6
switchport access vlan 5
switchport mode access
authentication event fail retry 0 action authorize vlan 17
authentication event server dead action authorize vlan 17
authentication event no-response action authorize vlan 17
authentication event server alive action reinitialize
authentication order mab dot1x
authentication priority mab dot1x
authentication port-control auto
mab
dot1x pae authenticator
spanning-tree portfast
!
interface GigabitEthernet0/7
switchport access vlan 5
switchport mode access
authentication event fail retry 0 action authorize vlan 17
authentication event server dead action authorize vlan 17
authentication event no-response action authorize vlan 17
authentication event server alive action reinitialize
authentication order mab dot1x
authentication priority mab dot1x
authentication port-control auto
mab
dot1x pae authenticator
spanning-tree portfast
!
interface GigabitEthernet0/8
switchport access vlan 5
switchport mode access
authentication event fail retry 0 action authorize vlan 17
authentication event server dead action authorize vlan 17
authentication event no-response action authorize vlan 17
authentication event server alive action reinitialize
authentication order mab dot1x
authentication priority mab dot1x
authentication port-control auto
mab
dot1x pae authenticator
spanning-tree portfast
!
interface GigabitEthernet0/9
switchport trunk native vlan 3
switchport mode trunk
!
interface GigabitEthernet0/10
switchport trunk native vlan 3
switchport mode trunk
!
interface Vlan1
no ip address
shutdown
!
interface Vlan3
ip address 192.168.3.221 255.255.255.0
!
interface Vlan17
no ip address
!
ip default-gateway 192.168.3.254
no ip http server
no ip http secure-server
!
!
ip access-list extended test
ip radius source-interface Vlan3
logging source-interface Vlan3
logging host 192.168.254.171
!
snmp-server community intrasnmp RW
snmp-server trap-source Vlan3
snmp-server enable traps snmp authentication linkdown linkup coldstart warmstart
snmp-server enable traps transceiver all
snmp-server enable traps call-home message-send-fail server-fail
snmp-server enable traps tty
snmp-server enable traps license
snmp-server enable traps auth-framework sec-violation
snmp-server enable traps cluster
snmp-server enable traps config-copy
snmp-server enable traps config
snmp-server enable traps config-ctid
snmp-server enable traps trustsec-sxp conn-srcaddr-err msg-parse-err conn-config-err binding-err conn-up conn-down binding-expn-fail oper-nodeid-change binding-conflict
snmp-server enable traps energywise
snmp-server enable traps fru-ctrl
snmp-server enable traps entity
snmp-server enable traps event-manager
snmp-server enable traps ike policy add
snmp-server enable traps ike policy delete
snmp-server enable traps ike tunnel start
snmp-server enable traps ike tunnel stop
snmp-server enable traps ipsec cryptomap add
snmp-server enable traps ipsec cryptomap delete
snmp-server enable traps ipsec cryptomap attach
snmp-server enable traps ipsec cryptomap detach
snmp-server enable traps ipsec tunnel start
snmp-server enable traps ipsec tunnel stop
snmp-server enable traps ipsec too-many-sas
snmp-server enable traps power-ethernet police
snmp-server enable traps cpu threshold
snmp-server enable traps rep
snmp-server enable traps vstack
snmp-server enable traps bridge newroot topologychange
snmp-server enable traps stpx inconsistency root-inconsistency loop-inconsistency
snmp-server enable traps syslog
snmp-server enable traps vtp
snmp-server enable traps vlancreate
snmp-server enable traps vlandelete
snmp-server enable traps flash insertion removal
snmp-server enable traps port-security
snmp-server enable traps envmon fan shutdown supply temperature status
snmp-server enable traps stackwise
snmp-server enable traps bulkstat collection transfer
snmp-server enable traps errdisable
snmp-server enable traps mac-notification change move threshold
snmp-server enable traps vlan-membership
snmp-server host 192.168.254.171 informs version 2c intrasnmp
snmp ifmib ifindex persist
!
radius-server dead-criteria time 60 tries 1
radius-server deadtime 300
!
radius server main
address ipv4 192.168.254.181 auth-port 1812 acct-port 1813
key 7 04731C373C075E7E3F3C174E1A2A1529307F
!
radius server sub
address ipv4 192.168.254.182 auth-port 1812 acct-port 1813
key 7 013B1135682D143F17695C5011240E3F1158
!
line con 0
exec-timeout 0 0
privilege level 15
logging synchronous
line vty 0 4
exec-timeout 0 0
privilege level 15
logging synchronous
transport input ssh
line vty 5 15
exec-timeout 0 0
privilege level 15
logging synchronous
transport input ssh
!
ntp source Vlan3
ntp server 192.168.254.171
end
さぁこれで一旦土台はできた。次はサーバやらを接続していこうと思っています!
コメント