> For the complete documentation index, see [llms.txt](https://docs.panther.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.panther.com/ko/search/data-explorer/example-queries/vpc-flow-logs-queries.md).

# VPC 로그 쿼리

이 페이지에는 VPC Flow 로그와 VPC DNS 로그에 대한 예제가 포함되어 있습니다.

## VPC Flow Logs 쿼리

### SSH 및 RDP에 대한 VPC Flowlog 활동 표시

원격 셸은 일반적으로 한쪽 끝에 사람이 있습니다. 조사 중에는 특정 행위자의 활동을 식별하기 위해 SSH 및 RDP 세션을 분리하는 것이 흔한 절차입니다.

```sql
SELECT
 *
FROM panther_logs.public.aws_vpcflow
WHERE
  p_occurs_between('2021-01-01', '2021-01-02')
  AND
  (srcport IN (22, 3389) OR dstport IN (22, 3389))
ORDER BY p_event_time ASC
LIMIT 100
```

### IP 주소에 대한 VPC Flowlog 활동 표시

조사 중에는 특정 IP 주소가 관심 대상로 식별되곤 합니다(예: 알려진 명령 및 제어 노드). IP 주소의 역할이 식별되면 해당 활동을 분리하고 설명하는 것이 중요합니다. 이는 어떤 리소스가 침해되었을 가능성이 있는지 나타낼 수 있습니다.

```sql
SELECT
 *
FROM panther_logs.public.aws_vpcflow
WHERE p_occurs_between('2021-01-01', '2021-01-02')
     AND array_contains('1.2.3.4'::variant, p_any_ip_addresses)
ORDER BY p_event_time ASC
LIMIT 100
```

### 콘솔 로그인과 관련된 CloudTrail sourceIPAddresses의 VPC Flowlog 활동 표시

자격 증명 유출이 우려된다면 모든 AWS 콘솔 활동을 파악하는 것이 매우 중요합니다. 이 쿼리는 콘솔 로그인에 관여한 모든 CloudTrail sourceIPaddresses를 찾아낸 다음 관련된 모든 VPC Flow 활동을 반환합니다. 이를 통해 공통 IP 주소가 있는지 확인할 수 있습니다. 특히 관심 있는 것은 IP 주소입니다 **조직 외부의** 인스턴스와 통신하고 콘솔에 로그인하는 IP 주소입니다. 이는 권한 없는 행위자가 계정 리소스에 접근하는 침해를 나타낼 수 있습니다.

```sql
WITH cloudTrailIPs as
(SELECT
  DISTINCT sourceIPAddress AS ip
 FROM panther_logs.public.aws_cloudtrail
 WHERE
    p_occurs_between('2021-01-01', '2021-01-02')
    AND
    eventtype = 'AwsConsoleSignIn'
)
SELECT
 *
FROM  cloudTrailIPs ips JOIN panther_logs.public.aws_vpcflow flow ON (ips.ip = flow.srcaddr OR ips.ip = flow.dstaddr)
WHERE
  p_occurs_between('2021-01-01', '2021-01-02')
ORDER BY p_event_time ASC
LIMIT 100
```

## **VPC DNS 쿼리 예제**

{% hint style="info" %}
아래 쿼리는 [VPC DNS 로그](/ko/data-onboarding/supported-logs/aws/vpc.md#vpc-dns-logging), 하지만 다른 DNS 로그에도 적용할 수 있습니다.
{% endhint %}

### **지난 1주일 동안 쿼리가 가장 많은 소스**

{% code overflow="wrap" %}

```sql
SELECT 
    srcids:instance, COUNT(*) 
FROM 
    panther_logs.public.aws_vpcdns 
WHERE 
    p_occurs_since(1w) 
GROUP BY 1 
LIMIT 100
```

{% endcode %}

### **지난 4주 동안 드문 쿼리**

{% code overflow="wrap" %}

```sql
-- 지난 4주 동안 드문 쿼리
SELECT 
    query_name, COUNT(*) as total
FROM  
    panther_logs.public.aws_vpcdns
WHERE 
    p_occurs_since(4w)
GROUP BY 1
ORDER BY 2
LIMIT 100
```

{% endcode %}

### **쿼리 목록 표시, AWS 내부 쿼리 제거**

```sql
-- 쿼리 목록
SELECT
    p_event_time, srcids, query_name, query_type, rcode
FROM
    panther_logs.public.aws_vpcdns
WHERE 
    -- AWS 내부 쿼리 제거
    not query_name LIKE ANY ('%amazonaws.com.', '%.compute.internal.')
LIMIT 10

```

### **상위 10개 TLD 분리 및 목록 표시**

```sql
-- 상위 10개 최상위 도메인 개수 세기
SELECT
    split_part(query_name, '.', -2) as TLD, count(*) as total
FROM
    panther_logs.public.aws_vpcdns
GROUP by 1
ORDER BY 2 desc
LIMIT 10
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.panther.com/ko/search/data-explorer/example-queries/vpc-flow-logs-queries.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
