話題の記事

インフラエンジニア向け、F5 BIG-IP Virtual Edition for AWS を使ってみる

2014.09.13

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

こんにちは、梶です。

インフラエンジニア向け第三弾として、F5 BIG-IP Vitrual Edition for AWSを使ってみたいと思います。

F5 BIG-IP Virtual Edition(以後BIG-IP VE)とは、簡単にいうとロードバランサー(負荷分散装置)です。 詳細はここ参照。 先日ブログに書いた、NetScalerとは競合製品です。

インフラエンジニア向け、Citrix NetScaler VPX for AWS を使ってみる

近年のサーバロードバランサーアプライアンス製品は、複数の負荷分散方式が選択できたり、SSLアクセラレーションを複数設定できたり、DDoS防御機能など色々な機能を併せ持っており多機能ですね。

  • ロードバランサーを触ってみたいが、身近にVMware vSphere(ESXi)やXenServerなどのハイパーバイザーが無く、検証してみたい
  • オンプレミスでロードバランサーを利用していて、クラウドでも同じものを利用したい という方に参考になれば幸いです。

 

あまりお金をかけず、検証するため、以下の内容で実施しました。

  • BIG-IP VEライセンスは、F5の30日間の試用版ライセンスでテストします。
  • 通信試験用のEC2サーバは12ヶ月の無料枠で作成できます。
  • F5 BIG-IPは有料枠のEC2サーバ上に作成する必要があります。

BIG-IP VE 試用版ライセンスは、以下のWebで発行される試用版ライセンスでライセンスて適応できなかったため、F5のサポートへ問い合わせし発行して頂きました。

 

この場をお借りし、お礼とさせて頂きます。

F5-BIG-IP-VE_2014-08-21_14_28_19

以下のリンクに参考になる資料はあるのですが、日本語版は無かったので参考になればと思います。

Deploying BIG-IP Virtual Edition

負荷分散設定について手順の記載が無く、NAT設定の手順が漏れて、少しハマったので参考になればと思います。

 

また、NetScalerと同様にライセンス選択で、従量課金方式とBYOL (Bring Your Own License)方式でサポートに差異があると思いますので代理店様へ確認下さい。

 

では早速、構築してみたいと思います。

 

構築の流れ

  • 検証環境ネットワークの構築
  • BIG-IPの構築
  • 初期パスワードの設定
  • External/Internalの設定
  • 経路情報の設定
  • 負荷分散の設定
  • NATの設定
  • 動作確認

検証環境ネットワークの構築

AWSのアカウントを取得し、VPC(Amazon Virtual Private Cloud)に以下の構成を作成します。

 

構成図

F5-BIG-IP-VE_2014-08-21_14_20_44

AWSのアカウントを作成。 http://aws.amazon.com/jp/register-flow/

VPCの作成には以下のこのサイトを参考にしてください。 通信検証用にサーバ2台構築し、apacheでWebサーバを構築しておきます。

ネットワークは3つ作っておきます。

BIG-IPの構築

AWS MarketPlaceから、F5 BIG-IP Amazon Machine Imageを選択します。

F5-BIG-IP-VE_2014-08-21_14_37_06

F5-BIG-IP-VE_2014-08-21_14_38_54

F5-BIG-IP-VE_2014-08-21_14_39_12

F5-BIG-IP-VE_2014-08-21_14_41_05

F5-BIG-IP-VE_2014-08-21_14_41_40

ネットワークとサブネットは、管理用(Management)に割り当てます。

F5-BIG-IP-VE_2014-08-21_15_04_02

Secruty GroupはF5のマニュアルに沿ってすべて許可のものを作成します。

F5-BIG-IP-VE_2014-08-21_15_04_33

F5-BIG-IP-VE_2014-08-21_15_04_40

sshログインするためのKeyを選択します。サーバと同じでも良いですし、必要に応じて分け。

F5-BIG-IP-VE_2014-08-21_15_04_46

構築が完了したら、BIG-IP VEにElastic IPを割り当てて、管理インターフェイスにログインできるように設定します。

F5-BIG-IP-VE_2014-08-21_15_05_10

初期パスワードの設定

 

SSHでログインして初期パスワードを設定します。

 

$ ssh -i <username-aws-keypair>.pem root@<elastic IP address of BIG-IP>

初期パスワードを設定します。

 

% ssh -i <username-aws-keypair>.pem  root@<elastic IP address of BIG-IP>
[root@ip-10-0-21-xx:NO LICENSE:Standalone] config # tmsh
root@(ip-10-0-21-xx)(cfg-sync Standalone)(NO LICENSE)(/Common)(tmos)# modify auth password admin
changing password for admin
new password:
confirm password:
root@(ip-10-0-21-xx)(cfg-sync Standalone)(NO LICENSE)(/Common)(tmos)#
root@(ip-10-0-21-xx)(cfg-sync Standalone)(NO LICENSE)(/Common)(tmos)# save sys config
Saving running configuration...
  /config/bigip.conf
  /config/bigip_base.conf
  /config/bigip_user.conf
Saving Ethernet mapping...failed
root@(ip-10-0-21-xx)(cfg-sync Standalone)(NO LICENSE)(/Common)(tmos)# q
[root@ip-10-0-21-xx:NO LICENSE:Standalone] config # exit

上記で設定したパスワードでWebGUIでアクセスします。

F5-BIG-IP-VE_2014-08-21_15_55_03

ログイン後にライセンス登録を行います。

F5-BIG-IP-VE_2014-08-21_15_55_20

F5-BIG-IP-VE_2014-08-21_15_56_36

F5-BIG-IP-VE_2014-08-21_15_55_30

F5-BIG-IP-VE_2014-08-21_18_48_58

F5-BIG-IP-VE_2014-08-21_18_49_09

F5-BIG-IP-VE_2014-08-21_18_49_43

F5-BIG-IP-VE_2014-08-21_18_50_57

External/Internalの設定

 

AWS Management Consoleから、ネットワークインターフェイスを追加。

 

External側(インターネット側)とInternal(Webサーバ側)のインターフェイスを追加します。

F5-BIG-IP-VE_2014-08-21_18_55_59

External側(インターネット側)にはサブインターフェイスを追加し、負荷分散用の仮想IPアドレスとして設定します。

F5-BIG-IP-VE_2014-08-25_14_14_17

作成したインターフェイスをAttachします。

F5-BIG-IP-VE_2014-08-21_18_59_19

F5-BIG-IP-VE_2014-08-21_18_59_32

Management ConsoleからBIG-IP VEを再起動し、追加したインターフェイスを反映させます。

 

vlanを2つ作成し、それぞれ1つのインターフェイスを割り当てます。

 

vlan10に「1.1」、vlan20に「1.2」を割り当てます。

F5-BIG-IP-VE_2014-08-25_13_32_29

vlan10とvlan20にIPアドレスを設定します。

 

AWS Management Consoleでネットワークインターフェイス作成時に割り当てられたIPアドレスと同じものを設定します。

F5-BIG-IP-VE_2014-08-25_13_33_45

F5-BIG-IP-VE_2014-08-25_13_38_35

F5-BIG-IP-VE_2014-08-25_13_33_45

経路情報の設定

 

default routeを設定します。VPCでは各サブネットの CIDR ブロック内にある IP アドレスのうち、最初の 4 個と最後の 1 個は両方とも AWS によって予約されています。ネットワークのデフォルトゲートウェイは最初の1個目のため、以下の例では10.0.0.1

F5-BIG-IP-VE_2014-08-25_13_45_44

負荷分散の設定

 

Webサーバのノード登録する。

F5-BIG-IP-VE_2014-08-25_13_46_44

F5-BIG-IP-VE_2014-08-25_13_46_57

F5-BIG-IP-VE_2014-08-25_13_47_16

負荷分散プールの設定する。

 

負荷分散方式の設定もここでできます。

F5-BIG-IP-VE_2014-08-25_13_57_08

F5-BIG-IP-VE_2014-08-25_13_58_31

F5-BIG-IP-VE_2014-08-25_13_58_39

仮想Webサーバの設定する。インターネット側からのアクセス先

F5-BIG-IP-VE_2014-08-25_13_59_53

F5-BIG-IP-VE_2014-09-04_15_19_15

F5-BIG-IP-VE_2014-09-04_15_21_21

仮想サーバへEIPを設定します。

F5-BIG-IP-VE_2014-08-25_14_16_38

NATの設定

 

この設定が無いと、通信ができません。ハマってしまいました。

F5-BIG-IP-VE_2014-09-04_15_21_46

動作確認

F5-BIG-IP-VE_2014-09-04_15_26_38

F5-BIG-IP-VE_2014-09-04_15_26_42

今回のConfigファイル

bigip.conf

 

#TMSH-VERSION: 11.5.1

apm client-packaging /Common/client-packaging { }
apm resource remote-desktop citrix-client-bundle /Common/default-citrix-client-bundle { }
ltm default-node-monitor {
    rule none
}
ltm node /Common/Web1 {
    address 10.0.11.84
    monitor /Common/icmp 
}
ltm node /Common/Web2 {
    address 10.0.11.85
    monitor /Common/icmp 
}
ltm pool /Common/http_pool {
    load-balancing-mode least-connections-member
    members {
        /Common/Web1:80 {
            address 10.0.11.84
        }
        /Common/Web2:80 {
            address 10.0.11.85
        }
    }
    monitor /Common/http 
}
ltm snat /Common/vs_snat {
    auto-lasthop enabled
    automap
    origins {
        0.0.0.0/0 { }
    }
}
ltm virtual /Common/vs_http {
    destination /Common/10.0.0.192:80
    ip-protocol tcp
    mask 255.255.255.255
    persist {
        /Common/source_addr {
            default yes
        }
    }
    pool /Common/http_pool
    profiles {
        /Common/tcp { }
    }
    source 0.0.0.0/0
    translate-address enabled
    translate-port enabled
    vlans {
        /Common/external
    }
    vlans-enabled
}
ltm virtual-address /Common/10.0.0.192 {
    address 10.0.0.192
    arp enabled
    mask 255.255.255.255
    traffic-group /Common/traffic-group-1
}
net route /Common/defaultroute {
    gw 10.0.0.1
    network default
}
net ipsec ike-daemon /Common/ikedaemon { }
sys software update {
    auto-check enabled
    frequency weekly
}
wom endpoint-discovery { }

bigip_base.conf

 

#TMSH-VERSION: 11.5.1

cm cert /Common/dtca-bundle.crt {
    cache-path /config/filestore/files_d/Common_d/trust_certificate_d/:Common:dtca-bundle.crt_32408_2
    checksum SHA1:1342:68a09e4a1a31c95b1d82e9c4ee0cfa02c9ea8e63
    revision 2
}
cm cert /Common/dtca.crt {
    cache-path /config/filestore/files_d/Common_d/trust_certificate_d/:Common:dtca.crt_32404_1
    checksum SHA1:1342:68a09e4a1a31c95b1d82e9c4ee0cfa02c9ea8e63
    revision 1
}
cm cert /Common/dtdi.crt {
    cache-path /config/filestore/files_d/Common_d/trust_certificate_d/:Common:dtdi.crt_32400_1
    checksum SHA1:1273:2ece28b6692211d3ff5a191a9f3708f8f8438fb6
    revision 1
}
cm device /Common/ip-10-0-21-15.ap-northeast-1.compute.internal {
    active-modules { "LTM, Lab, AWS|MCGUYSR-UFIUUVO|IPV6 Gateway|Rate Shaping|Ram Cache|50 MBPS COMPRESSION|SSL, 500 TPS Per Core|SSL, Max TPS, AWS|Application Acceleration Manager, Core|Anti-Virus Checks|Base Endpoint Security Checks|Firewall Checks|Network Access|Secure Virtual Keyboard|APM, Web Application|Machine Certificate Checks|Protected Workspace|Remote Desktop|App Tunnel" }
    base-mac 06:55:4f:58:39:8c
    build 3.0.131
    cert /Common/dtdi.crt
    chassis-id ec21d4fc-3be0-00d2-c3ef5e786e8c
    edition "Hotfix HF3"
    hostname ip-10-0-21-15.ap-northeast-1.compute.internal
    key /Common/dtdi.key
    management-ip 10.0.21.15
    marketing-name "BIG-IP Virtual Edition"
    optional-modules { "Acceleration Manager, AWS" "AFM, AWS" "APM, Base, AWS" "APM, Max CCU, AWS" "App Mode (TMSH Only, No Root/Bash)" "ASM, AWS" "DNS Services, AWS" "External Interface and Network HSM" "Global Traffic Manager" "IPI Subscription, 1Yr, VE" "IPI Subscription, 3Yr, VE" "PSM, AWS" "Routing Bundle, AWS" "SDN Services" "SSL, Forward Proxy, AWS" "WBA, AWS" "WOM, AWS" }
    platform-id Z100
    product BIG-IP
    self-device true
    time-zone PDT
    version 11.5.1
}
cm device-group /Common/device_trust_group {
    auto-sync enabled
    devices {
        /Common/ip-10-0-21-15.ap-northeast-1.compute.internal { }
    }
    hidden true
    network-failover disabled
}
cm device-group /Common/gtm {
    devices {
        /Common/ip-10-0-21-15.ap-northeast-1.compute.internal { }
    }
    hidden true
    network-failover disabled
}
cm key /Common/dtca.key {
    cache-path /config/filestore/files_d/Common_d/trust_certificate_key_d/:Common:dtca.key_32406_1
    checksum SHA1:1704:732fae93915a001b69b96795bd03c96c9fc76812
    revision 1
}
cm key /Common/dtdi.key {
    cache-path /config/filestore/files_d/Common_d/trust_certificate_key_d/:Common:dtdi.key_32402_1
    checksum SHA1:1704:09991a1230cd126d500b257136486e42eac96239
    revision 1
}
cm traffic-group /Common/traffic-group-1 {
    unit-id 1
}
cm traffic-group /Common/traffic-group-local-only { }
cm trust-domain /Common/Root {
    ca-cert /Common/dtca.crt
    ca-cert-bundle /Common/dtca-bundle.crt
    ca-devices { /Common/ip-10-0-21-15.ap-northeast-1.compute.internal }
    ca-key /Common/dtca.key
    guid 4876bd74-d1b9-4e23-9acd06554f58398c
    status standalone
    trust-group /Common/device_trust_group
}
net interface 1.1 {
    media-fixed 10000T-FD
}
net interface 1.2 {
    media-fixed 10000T-FD
}
net route-domain /Common/0 {
    id 0
    vlans {
        /Common/http-tunnel
        /Common/socks-tunnel
        /Common/internal
        /Common/external
    }
}
net self /Common/external {
    address 10.0.0.191/24
    traffic-group /Common/traffic-group-local-only
    vlan /Common/external
}
net self /Common/internal {
    address 10.0.11.138/24
    allow-service {
        default
    }
    traffic-group /Common/traffic-group-local-only
    vlan /Common/internal
}
net self-allow {
    defaults {
        ospf:0
        tcp:161
        tcp:22
        tcp:4353
        tcp:443
        tcp:53
        udp:1026
        udp:161
        udp:4353
        udp:520
        udp:53
    }
}
net stp /Common/cist {
    interfaces {
        1.1 {
            external-path-cost 2000
            internal-path-cost 2000
        }
        1.2 {
            external-path-cost 2000
            internal-path-cost 2000
        }
    }
    vlans {
        /Common/external
        /Common/internal
    }
}
net vlan /Common/external {
    description external
    interfaces {
        1.1 { }
    }
    tag 4094
}
net vlan /Common/internal {
    description internal
    interfaces {
        1.2 { }
    }
    tag 4093
}
net fdb tunnel /Common/http-tunnel { }
net fdb tunnel /Common/socks-tunnel { }
net fdb vlan /Common/external { }
net fdb vlan /Common/internal { }
net tunnels tunnel /Common/http-tunnel {
    description "Tunnel for http-explicit profile"
    profile /Common/tcp-forward
}
net tunnels tunnel /Common/socks-tunnel {
    description "Tunnel for socks profile"
    profile /Common/tcp-forward
}
security firewall port-list /Common/_sys_self_allow_tcp_defaults {
    ports {
        22 { }
        53 { }
        161 { }
        443 { }
        1029-1043 { }
        4353 { }
    }
}
security firewall port-list /Common/_sys_self_allow_udp_defaults {
    ports {
        53 { }
        161 { }
        520 { }
        1026 { }
        4353 { }
    }
}
security firewall rule-list /Common/_sys_self_allow_all {
    rules {
        _sys_allow_all {
            action accept
        }
    }
}
security firewall rule-list /Common/_sys_self_allow_defaults {
    rules {
        _sys_allow_tcp_defaults {
            action accept
            ip-protocol tcp
            destination {
                port-lists {
                    /Common/_sys_self_allow_tcp_defaults
                }
            }
        }
        _sys_allow_udp_defaults {
            action accept
            ip-protocol udp
            destination {
                port-lists {
                    /Common/_sys_self_allow_udp_defaults
                }
            }
        }
        _sys_allow_ospf_defaults {
            action accept
            ip-protocol ospf
        }
    }
}
security firewall rule-list /Common/_sys_self_allow_management {
    rules {
        _sys_allow_ssh {
            action accept
            ip-protocol tcp
            destination {
                ports {
                    22 { }
                }
            }
        }
        _sys_allow_web {
            action accept
            ip-protocol tcp
            destination {
                ports {
                    443 { }
                }
            }
        }
    }
}
security ip-intelligence policy /Common/ip-intelligence { }
sys feature-module cgnat {
    disabled
}
sys folder / {
    device-group none
    hidden false
    inherited-devicegroup false
    inherited-traffic-group false
    traffic-group /Common/traffic-group-1
}
sys folder /Common {
    device-group none
    hidden false
    inherited-devicegroup true
    inherited-traffic-group true
    traffic-group /Common/traffic-group-1
}
sys global-settings {
    gui-setup disabled
    hostname ip-10-0-21-15.ap-northeast-1.compute.internal
}
sys management-dhcp /Common/sys-mgmt-dhcp-config {
    request-options { subnet-mask broadcast-address routers domain-name domain-name-servers host-name ntp-servers }
}
sys management-route /Common/default {
    description configured-by-dhcp
    gateway 10.0.21.1
    network default
}
sys provision ltm {
    level nominal
}
sys snmp {
    agent-addresses { tcp6:161 udp6:161 }
    communities {
        /Common/comm-public {
            community-name public
            source default
        }
    }
    disk-monitors {
        /Common/root {
            minspace 2000
            path /
        }
        /Common/var {
            minspace 10000
            path /var
        }
    }
    process-monitors {
        /Common/bigd {
            process bigd
        }
        /Common/chmand {
            process chmand
        }
        /Common/httpd {
            max-processes infinity
            process httpd
        }
        /Common/mcpd {
            process mcpd
        }
        /Common/sod {
            process sod
        }
        /Common/tmm {
            max-processes infinity
            process tmm
        }
    }
}
sys sflow global-settings http { }
sys sflow global-settings vlan { }