
AWS Network Firewall の automated Internet firewall を試してみた
はじめに
2026年11月20日に、AWS Network Firewall の automated Internet firewall がパブリックプレビューとして発表されました。
automated Internet firewall は、VPC の internet gateway(IGW)で Network Firewall による検査と NAT を行う機能です。発表では、ルーティングの変更なしに多数の VPC へ適用できるとされています。
この記事では、AWS CLI で automated Internet firewall を1つの VPC に適用し、IGW での検査と NAT の動作を確かめました。
検証環境
- リージョン: 東京(ap-northeast-1)
- AWS CLI: 2.42.1
- VPC: 新規作成(10.99.0.0/24)
- AZ: ap-northeast-1a のみ
- EC2: t4g.micro、パブリック IP なし、SSM で操作
サブネットは次の3つです。
| サブネット | 0.0.0.0/0 の向き先 | 配置するもの |
|---|---|---|
| NAT gateway 用 | IGW | NAT gateway |
| EC2 用(NAT gateway 向け) | NAT gateway | EC2 1台 |
| EC2 用(IGW 向け) | IGW | EC2 1台 |
設定
automated Internet firewall は、Network Security Manager(NSM)の rule、policy、scope、deployment で設定します。コンソールで同じ操作をする場合は、公式ドキュメントの Quick create and deploy の手順に従います。
NSM rule
rule は3つ作りました。モードの指定(monitor)、example.org の遮断、ログの出力先の指定(CloudWatch Logs への alert と flow)です。ログの rule が指す2つのロググループは、先に作っておきました。
aws logs create-log-group --log-group-name /igwfw-verify/nfw-alert
aws logs create-log-group --log-group-name /igwfw-verify/nfw-flow
モードの rule は artifacts/rule-mode-monitor.json に保存しました。
{"PolicyMode":"MONITOR"}
example.org の遮断は artifacts/rule-deny-domain.json に、文字列形式(RulesString)で書きました。TLS の SNI または HTTP の Host が example.org かそのサブドメインである通信を drop します。
{
"FirewallRuleGroupEntry": {
"Priority": 1,
"InlineRuleGroup": {
"RulesSource": {
"RulesString": "drop:flow tls:client_hello $HOME_NET any -> $EXTERNAL_NET any (tls.sni; dotprefix; content:\".example.org\"; nocase; endswith; msg:\"igwfw-verify deny example.org\"; flow:to_server; sid:1000001; rev:1;)\ndrop:flow http1:request_headers $HOME_NET any -> $EXTERNAL_NET any (http.host; dotprefix; content:\".example.org\"; endswith; msg:\"igwfw-verify deny example.org http\"; flow:to_server; sid:1000002; rev:1;)"
}
}
}
}
ログの出力先は artifacts/rule-logging.json に書きました。
{"LoggingConfiguration":{"LogDestinationConfigs":[{"LogType":"ALERT","LogDestinationType":"CloudWatchLogs","LogDestination":{"logGroup":"/igwfw-verify/nfw-alert"}},{"LogType":"FLOW","LogDestinationType":"CloudWatchLogs","LogDestination":{"logGroup":"/igwfw-verify/nfw-flow"}}]}}
ログの rule だけ --rule-type CONFIGURATION で、ほかの2つは INSPECTION で作成しました。
aws network-security-manager create-rule --rule-name igwfw-verify-mode --firewall-type IGW_FIREWALL --rule-type INSPECTION --configuration file://artifacts/rule-mode-monitor.json --output json
aws network-security-manager create-rule --rule-name igwfw-verify-logging --firewall-type IGW_FIREWALL --rule-type CONFIGURATION --configuration file://artifacts/rule-logging.json --output json
aws network-security-manager create-rule --rule-name igwfw-verify-deny-example-org --firewall-type IGW_FIREWALL --rule-type INSPECTION --configuration file://artifacts/rule-deny-domain.json --output json
policy には、AWS 管理のテンプレート AWSManagedTemplateIGWFirewallBaseline も入れました。ARN は list-templates で取得できます。
aws network-security-manager list-templates --template-owner AWS --output json
policy と scope
policy は、テンプレートと3つの rule を並べた artifacts/policy-rules.json で定義しました。
[{"templateIdentifier":"arn:aws:network-security-manager:ap-northeast-1:aws:template:AWSManagedTemplateIGWFirewallBaseline"},{"ruleIdentifier":"arn:aws:network-security-manager:ap-northeast-1:111122223333:rule:<deny-rule-id>"},{"ruleIdentifier":"arn:aws:network-security-manager:ap-northeast-1:111122223333:rule:<mode-rule-id>"},{"ruleIdentifier":"arn:aws:network-security-manager:ap-northeast-1:111122223333:rule:<logging-rule-id>"}]
サブネットの接続タイプは artifacts/policy-config.json で flexible にしました。
{"remediationEnabled":true,"resourcesCleanUp":true,"igwFirewallConfig":{"defaultSubnetConnectivity":"flexible"}}
scope は artifacts/scope-config.json で、検証 VPC の ARN だけを explicitArns に指定しました。
{"resourceScopes":{"AWS::EC2::VPC":{"include":{"explicitArns":["arn:aws:ec2:ap-northeast-1:111122223333:vpc/vpc-0123456789abcdef0"]}}}}
aws network-security-manager create-scope --scope-name igwfw-verify-scope --scope-configuration file://artifacts/scope-config.json --output json
aws network-security-manager create-policy --policy-name igwfw-verify-policy --priority 1 --firewall-type IGW_FIREWALL --associated-template-and-rule-list file://artifacts/policy-rules.json --policy-configuration file://artifacts/policy-config.json --output json
deployment
policy と scope の ARN を渡して、deployment を作成しました。
aws network-security-manager create-deployment --deployment-name igwfw-verify-deployment --deployment-configuration enableCrossAccountVisibility=false --associated-policy-list policyIdentifier=<policy-arn> --associated-scope-list scopeIdentifier=<scope-arn> --output json
デプロイ後の状態
firewall の作成
deployment を作成した直後は、NSM の同期状態が OUT_OF_SYNC でした。理由は、VPC が IGW firewall に未登録であることでした。
aws network-security-manager list-resource-synchronization-statuses --deployment-identifier <deployment-arn> --output json
aws network-firewall list-firewalls --firewall-type IGW_FIREWALL --output json
aws network-firewall describe-firewall --firewall-arn arn:aws:network-firewall:ap-northeast-1:111122223333:igw-firewall/vpc-0123456789abcdef0 --output json
deployment の作成から約1分半後の確認で、igw-firewall が PROVISIONING の状態で一覧に現れていました。約9分後の確認では READY になっていました。ap-northeast-1a の firewall には NAT IP が1つ割り当てられていました。IGW firewall の一覧に表示されたのは、検証 VPC の firewall だけでした。
ルートテーブル
デプロイ後、IGW 向けの2つのサブネットが共有するルートテーブルで、IGW 向けルートに IgwFirewall の項目が付きました。デプロイの前後で describe-route-tables の出力全体を比べると、差分はこの1か所だけで、ルートの宛先と関連付けは変わりませんでした。
aws ec2 describe-route-tables --filters Name=vpc-id,Values=vpc-0123456789abcdef0 --query 'RouteTables[].{Id:RouteTableId,Name:Tags[?Key==`Name`]|[0].Value,Routes:Routes,Subnets:Associations[].SubnetId}' --output json
{
"DestinationCidrBlock": "0.0.0.0/0",
"GatewayId": "igw-0123456789abcdef0",
"Origin": "CreateRoute",
"State": "active",
"IgwFirewall": {
"FirewallArn": "arn:aws:network-firewall:ap-northeast-1:111122223333:igw-firewall/vpc-0123456789abcdef0",
"Status": "active"
}
}
NAT と送信元 IP
IGW 向けサブネットにある、パブリック IP のない EC2 は、デプロイ前はインターネットへ出られず、SSM に登録されませんでした。デプロイ後は SSM に Online として登録されたので、checkip.amazonaws.com で送信元 IP を確認しました。
| EC2 | 0.0.0.0/0 の向き先 | デプロイ後の checkip.amazonaws.com の結果 | IP の種類 |
|---|---|---|---|
| IGW 向けサブネット | IGW | 203.0.113.10 | firewall の NAT IP |
| NAT gateway 向けサブネット | NAT gateway | 198.51.100.20 | NAT gateway の Elastic IP |
firewall の NAT IP は、ServiceManaged が igw-firewall になっている自アカウントの Elastic IP でした。
接続タイプが flexible の場合、IGW へのルートがあるサブネットでは、パブリック IP を持たないリソースもインターネットへ接続できるようになります。
monitor モードでの確認
alert ログ
monitor モードで、IGW 向けサブネットの EC2 から example.org、www.example.org、example.com へ HTTPS でアクセスしました。結果はすべて HTTP 200 でした。
alert ログは CloudWatch Logs の /igwfw-verify/nfw-alert で確認しました。
aws logs filter-log-events --log-group-name /igwfw-verify/nfw-alert --filter-pattern '"example"' --query 'events[].message' --output json
alert ログには、既定のパケットポリシーとアプリポリシーによる allowed のレコードが多数記録されました。署名は SURICATA FW default packet policy と SURICATA FW default app policy で、SSM の通信も含まれていました。遮断の rule(署名 igwfw-verify deny example.org)でも、SNI が example.org の通信が allowed として記録されていました。
alert ログのレコードは、通信の約4分半後に確認できました。
alert ログには、インターネット側の送信元から NAT gateway のプライベート IP 宛てに入る通信も allowed で記録されていました。
VPC フローログ
VPC フローログは、READY の前後を比べるため、deployment の作成前に作成しました。カスタム形式には traffic-path を含めました。IAM ロールとロググループは、あらかじめ作成しておきました。
aws ec2 create-flow-logs --resource-type VPC --resource-ids vpc-0123456789abcdef0 --traffic-type ALL --log-destination-type cloud-watch-logs --log-group-name /igwfw-verify/vpc-flow --deliver-logs-permission-arn arn:aws:iam::111122223333:role/igwfw-verify-flowlog --max-aggregation-interval 60 --log-format '${version} ${interface-id} ${srcaddr} ${dstaddr} ${srcport} ${dstport} ${protocol} ${pkt-srcaddr} ${pkt-dstaddr} ${action} ${traffic-path} ${tcp-flags}'
firewall が READY になったことを確認した時刻を境に、フローログのレコードを traffic-path ごとに数えました。
== igw-instance eni-0123456789abcdef0
after-ready ACCEPT traffic-path=- 24
after-ready ACCEPT traffic-path=8 1
after-ready ACCEPT traffic-path=9 25
before-ready - traffic-path=- 1
before-ready ACCEPT traffic-path=8 67
== natgw eni-0123456789abcdef1
after-ready - traffic-path=- 8
after-ready ACCEPT traffic-path=- 239
after-ready ACCEPT traffic-path=1 8
after-ready ACCEPT traffic-path=8 3
after-ready ACCEPT traffic-path=9 16
before-ready - traffic-path=- 28
before-ready ACCEPT traffic-path=- 1213
before-ready ACCEPT traffic-path=1 56
before-ready ACCEPT traffic-path=8 57
before-ready ACCEPT traffic-path=9 1
IGW 向けサブネットの EC2 の egress の traffic-path は、READY の前は 8 でしたが、後は主に 9 になりました。9 は、公式ドキュメントによると firewall の egress で処理されたことを示します。NAT gateway の ENI では、9 が READY の前に1件、後に16件記録されました。
enforce モードへの切り替え
update-rule の実行
モードの rule を ENFORCE に更新しました。artifacts/rule-mode-enforce.json は次の内容です。
{"PolicyMode":"ENFORCE"}
--update-token には、create-rule の応答に含まれる値を指定しました。
aws network-security-manager update-rule --rule-identifier arn:aws:network-security-manager:ap-northeast-1:111122223333:rule:<mode-rule-id> --update-token <update-token> --rule-type INSPECTION --configuration file://artifacts/rule-mode-enforce.json --is-published --output json
更新の約2分後に、IGW 向けサブネットの EC2 から次のコマンドで通信を確かめました。
for h in example.org www.example.org; do
curl -s -m 10 -o /dev/null -w "$h http=%{http_code}\n" https://$h
echo "$h curl-exit=$?"
done
curl -s -m 10 -o /dev/null -w "http://example.org http=%{http_code}\n" http://example.org
echo "http://example.org curl-exit=$?"
| 通信先 | HTTP ステータス | curl の終了コード |
|---|---|---|
| https://example.org | 000 | 28 |
| https://www.example.org | 000 | 28 |
| http://example.org | 000 | 28 |
rule-deny-domain.json の rule に一致する3つの通信先すべてが、curl の終了コード 28(タイムアウト)になりました。
遮断の記録
RulesString 形式の rule では、署名 igwfw-verify で検索した alert ログに blocked の記録は出ませんでした。
そこで、遮断の rule を FirewallRules 形式で書き直しました。各ルールに "AlertEnabled": true を付けました(artifacts/rule-deny-domain-alert.json)。
rule-deny-domain-alert.json
{
"FirewallRuleGroupEntry": {
"Priority": 1,
"InlineRuleGroup": {
"RulesSource": {
"FirewallRules": [
{
"Action": "DROP",
"ActionScope": "FLOW",
"Hook": "TLS_CLIENT_HELLO",
"Protocol": "TLS",
"SourceIPs": "$HOME_NET",
"DestIPs": "$EXTERNAL_NET",
"SourcePorts": "any",
"DestPorts": "any",
"RuleOptions": [
{
"Keyword": "tls.sni"
},
{
"Keyword": "dotprefix"
},
{
"Keyword": "content",
"Settings": [
"\".example.org\""
]
},
{
"Keyword": "nocase"
},
{
"Keyword": "endswith"
},
{
"Keyword": "msg",
"Settings": [
"\"igwfw-verify deny example.org TLS\""
]
},
{
"Keyword": "sid",
"Settings": [
"1000001"
]
},
{
"Keyword": "rev",
"Settings": [
"1"
]
}
],
"AlertEnabled": true
},
{
"Action": "DROP",
"ActionScope": "FLOW",
"Hook": "HTTP1_REQUEST_HEADERS",
"Protocol": "HTTP",
"SourceIPs": "$HOME_NET",
"DestIPs": "$EXTERNAL_NET",
"SourcePorts": "any",
"DestPorts": "any",
"RuleOptions": [
{
"Keyword": "http.host"
},
{
"Keyword": "dotprefix"
},
{
"Keyword": "content",
"Settings": [
"\".example.org\""
]
},
{
"Keyword": "endswith"
},
{
"Keyword": "msg",
"Settings": [
"\"igwfw-verify deny example.org HTTP\""
]
},
{
"Keyword": "sid",
"Settings": [
"1000002"
]
},
{
"Keyword": "rev",
"Settings": [
"1"
]
}
],
"AlertEnabled": true
}
]
}
}
}
}
更新は、モードの rule と同じ形で実行しました。対象には遮断の rule の ARN を、--update-token には create-rule の応答に含まれる値を指定しました。
aws network-security-manager update-rule --rule-identifier arn:aws:network-security-manager:ap-northeast-1:111122223333:rule:<deny-rule-id> --update-token <update-token> --rule-type INSPECTION --configuration file://artifacts/rule-deny-domain-alert.json --is-published --output json
更新後は、alert ログに blocked のレコードが出ました。署名は igwfw-verify deny example.org TLS、hook は tls:client_hello、SNI は example.org でした。
まとめ
パブリックプレビューの提供が始まった AWS Network Firewall の automated Internet firewall の動作を確認しました。
従来の Network Firewall では、エンドポイント用の専用サブネットを用意し、保護対象のサブネットごとにルートテーブルを調整する必要がありました。automated Internet firewall では、どちらも不要なことを確認できました。
NAT gateway を利用中で Network Firewall を導入したいものの、既存の VPC への専用サブネットの追加やルーティング設定の変更が障壁になっている場合は、automated Internet firewall をお試しください。








