概要
今回はこのような構成を試してみたいと思います。
VPC から ICOS へのアクセスをログを見ながら確認します。
ちなみにですが IBM Cloud の場合、VPC - ICOS 間のデータ通信量に関する課金はないので、安心して使えます。
(以下のように Direct Endpoint を使った場合。)
https://cloud.ibm.com/docs/vpc?topic=vpc-connecting-vpc-cos
Direct endpoints provide your servers with high-speed, direct connections to IBM Cloud services, which incur no added bandwidth costs.
There is no charge for traffic from your VPCs to all COS endpoints listed on this page.
https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-endpoints#advanced-endpoint-types
Direct endpoints are used in Bring-Your-Own-IP scenarios, generally for requests originating from resources within VPCs. Like Private endpoints, Direct endpoints provide better performance over Public endpoints and do not incur charges for any outgoing or incoming bandwidth even if the traffic is cross regions or across data centers.
ICOS IP Firewall 設定
$(curl http://checkip.amazonaws.com)
を使って現在のアクセス元グローバルIPを入れておき、 自らのアクセス時に拒否されない設定にします。
また、それ以外の IP アドレスからのアクセスは全て拒否する設定にします。
export BUCKET_NAME=content-library
export ACCESS_TOKEN=$(ibmcloud iam oauth-tokens --output JSON | jq -r '.iam_token')
echo $ACCESS_TOKEN
curl -X PATCH https://config.cloud-object-storage.cloud.ibm.com/v1/b/$BUCKET_NAME -H "authorization: $ACCESS_TOKEN" -d @- << EOF
{
"firewall": {
"allowed_ip": [
"$(curl http://checkip.amazonaws.com)"
]
}
}
EOF
curl https://config.cloud-object-storage.cloud.ibm.com/v1/b/$BUCKET_NAME -H "authorization: $ACCESS_TOKEN" | jq -r
IBM Cloud Activity Tracker with LogDNA 注文
以下の URL から IBM Cloud Activity Tracker with LogDNA を注文します。
ICOS と同じリージョンになるように構成します。
https://cloud.ibm.com/catalog/services/ibm-cloud-activity-tracker-with-logdna
ICOS の Activity Tracker 連携設定
ICOS IP Firewall のアクセスログが確認するために、以下のように Activity Tracker 連携設定をします。
- 「Track data events」にチェック
- 「read & write」を選択
- VPC 用の Direct Endpoint を確認
s3.direct.jp-tok.cloud-object-storage.appdomain.cloud
- Connecting to IBM Cloud Object Storage from VPC
VPC から ICOS へのアクセスが拒否されることを確認
VPC の Windows Server から S3 Browser を使ってアクセス確認します。
ICOS で発行した HMAC のサービス認証情報を元に以下のように設定します。
その後に対象バケットに対して、VPC の Windows Server から ICOS へのアクセスが拒否されることを確認します。
IBM Cloud Activity Tracker with LogDNA でアクセス拒否のログを確認
IBM Cloud Activity Tracker with LogDNA の画面から以下のようなアクセスログが確認できます。
ソース IP が 10.223.220.45
となっていますね。
VPC から ICOS へのアクセス時に許可すべき IP アドレス
先ほどの 10.223.220.45
は、VPC を作成するとゾーンごとに払い出される「Cloud Service Endpoint source address」のことです。
Cloud Service Endpoint source addresses are the IP addresses that identify a VPC and zone combination outside of the VPC. For example, a source address is used when a service outside of the VPC is called through a cloud service endpoint. The IP address of the virtual server instance is replaced with an IPv4 address, the source address, that identifies the VPC to the cloud service endpoint.
VPC から ICOS へのアクセス時にソース IP は「Cloud Service Endpoint source address」に置き換わるので、10.223.220.45
を ICOS IP Firewall で許可します。
export BUCKET_NAME=content-library
export ACCESS_TOKEN=$(ibmcloud iam oauth-tokens --output JSON | jq -r '.iam_token')
echo $ACCESS_TOKEN
curl -X PATCH https://config.cloud-object-storage.cloud.ibm.com/v1/b/$BUCKET_NAME -H "authorization: $ACCESS_TOKEN" -d @- << EOF
{
"firewall": {
"allowed_ip": [
"$(curl http://checkip.amazonaws.com)",
"10.223.220.45"
]
}
}
EOF
curl https://config.cloud-object-storage.cloud.ibm.com/v1/b/$BUCKET_NAME -H "authorization: $ACCESS_TOKEN" | jq -r
VPC から ICOS へのアクセスが許可されることを確認
VPC の Windows Server から S3 Browser を使ってアクセス確認します。
以下のように対象バケットに対して、VPC の Windows Server から ICOS へのアクセスが許可されることを確認します。
IBM Cloud Activity Tracker with LogDNA でアクセス許可のログを確認
IBM Cloud Activity Tracker with LogDNA の画面から以下のようなアクセスログが確認できます。
ICOS IP Firewall の設定変更が適用された後に、アクセス OK
となっていることが確認できます。
さいごに
ICOS IP Firewall のログが IBM Cloud Activity Tracker with LogDNA で確認できることがわかりました。
また、VPC からのアクセス時のソース IP を許可すれば、アクセスできることが確認できました。
IBM Cloud VPC でキャンペーンも実施しているので、ぜひ使ってみてください。
参考 : Flow logs for VPC で確認できる情報
{
"version": "0.0.1",
"collector_crn": "crn:v1:bluemix:public:is:jp-tok:a/xxx::flow-log-collector:rxxx",
"attached_endpoint_type": "vnic",
"network_interface_id": "xxx",
"instance_crn": "crn:v1:bluemix:public:is:jp-tok-3:a/xxx::instance:xxx",
"vpc_crn": "crn:v1:bluemix:public:is:jp-tok:a/xxx::vpc:xxx",
"capture_start_time": "2020-10-08T05:50:58Z",
"capture_end_time": "2020-10-08T05:55:58Z",
"state": "ok",
"number_of_flow_logs": 25,
"flow_logs": [
{
"start_time": "2020-10-08T05:50:56Z",
"end_time": "2020-10-08T05:51:11Z",
"connection_start_time": "2020-10-08T05:50:56Z",
"direction": "O",
"action": "accepted",
"initiator_ip": "192.168.250.9",
"target_ip": "161.26.0.22",
"initiator_port": 51450,
"target_port": 443,
"transport_protocol": 6,
"ether_type": "IPv4",
"was_initiated": true,
"was_terminated": true,
"bytes_from_initiator": 1591,
"packets_from_initiator": 11,
"bytes_from_target": 7095,
"packets_from_target": 11,
"cumulative_bytes_from_initiator": 1591,
"cumulative_packets_from_initiator": 11,
"cumulative_bytes_from_target": 7095,
"cumulative_packets_from_target": 11
},
...