0%

๐Ÿ‘ฎ๐Ÿป Security Group & Network ACL

์ž‘์„ฑ์ž : gasida.cloudnet@


AWS Document
  • AWS Security Group (๋ณด์•ˆ ๊ทธ๋ฃน)
  • AWS Network Access Control List (๋„คํŠธ์›Œํฌ ACL)
  • ๋ณด์•ˆ ๊ทธ๋ฃน๊ณผ ๋„คํŠธ์›Œํฌ ACL ๋น„๊ต
  • VPC ๋ณด์•ˆ ๋ชจ๋ฒ” ์‚ฌ๋ก€
  • VPC ๋ณด์•ˆ ์˜ˆ์‹œ


0. AWS Network Security

  • VPC ์˜ ๋ณด์•ˆ์„ ๊ฐ•ํ™”ํ•˜๊ณ  ๋ชจ๋‹ˆํ„ฐ๋ง ํ•˜๊ธฐ ์œ„ํ•œ ์—ฌ๋Ÿฌ ๊ธฐ๋Šฅ์ด ์ œ๊ณต
    • Security Group
    • Network ACL
    • Network Security Check (Source Destination Check , Uncheck)
    • VPC Flow Logs
    • Traffic Mirroring


1. Security Group

1.1 Security Group (=๋ณด์•ˆ ๊ทธ๋ฃน) ์†Œ๊ฐœ

  • ์ธ์Šคํ„ด์Šค(Instance) ์— ๋Œ€ํ•œ ์ธ๋ฐ”์šด๋“œ(Inbound) ๋ฐ ์•„์›ƒ๋ฐ”์šด๋“œ(Outbound) ํŠธ๋ž˜ํ”ฝ์„ ์ œ์–ดํ•˜๋Š” ๊ฐ€์ƒ ๋ฐฉํ™”๋ฒฝ ์—ญํ• 

  • ์ธ๋ฐ”์šด๋“œ(Inbound) ํŠธ๋ž˜ํ”ฝ์„ ์ œ์–ดํ•˜๋Š” ๊ทœ์น™๊ณผ ์•„์›ƒ๋ฐ”์šด๋“œ(Outbound) ํŠธ๋ž˜ํ”ฝ์„ ์ œ์–ดํ•˜๋Š” ๊ทœ์น™์€ ๊ฐ๊ฐ ๋™์ž‘

    • ์•„์›ƒ๋ฐ”์šด๋“œ(Outbound) ๋Š” ๋ณ„๋กœ ์“ธ๋ชจ ์—†๋‹ค

      โ†’ ๐Ÿ™…๐Ÿปโ€โ™€๏ธ ์™ธ๋ถ€ ์ ‘์† ์ œํ•œ ์ด๋‚˜ Security Group ID๋ฅผ ํ†ตํ•˜์—ฌ ํŠน์ • EC2 ๋งŒ ์ ‘์† ์ œํ•œ ํ™œ์šฉ ๊ฐ€๋Šฅ

  • ๐Ÿ™‹๐Ÿปโ€โ™€๏ธ ์ƒํƒœ๋ฅผ ์ €์žฅ(Stateful) โ† ๋งค์šฐ ์ค‘์š”ํ•œ ๊ฐœ๋… โ‡’ ์•„๋ž˜ 1.4 ์—์„œ ํ™•์ธ

    • ์ธ์Šคํ„ด์Šค์—์„œ ์š”์ฒญ์„ ์‹œ์ž‘ํ•˜๋ฉด ํ•ด๋‹น ์š”์ฒญ์˜ ์‘๋‹ต ํŠธ๋ž˜ํ”ฝ์€ ์ธ๋ฐ”์šด๋“œ ๋ณด์•ˆ ๊ทธ๋ฃน ๊ทœ์น™์— ๋งค์นญ๋˜์ง€ ์•Š์•„๋„ ์ธ๋ฐ”์šด๋“œ๊ฐ€ ํ—ˆ์šฉ๋จ (Allow Return Traffic)
      • Stateful ๊ธฐ๋Šฅ์ด ์—†์„ ๊ฒฝ์šฐ Stateless ๋ผ๊ณ  ๋ถ€๋ฅด๋ฉฐ Network ACL์ด ๋Œ€ํ‘œ์ ์ด๋‹ค.
        • Network ACL ๊ทœ์น™์€ ์š”์ฒญ ํŠธ๋ž˜ํ”ฝ์„ ์ธ๋ฐ”์šด๋“œ ๊ทœ์น™์— ํ—ˆ์šฉ๊ณผ ๋ฆฌํ„ด ํŠธ๋ž˜ํ”ฝ์„ ์•„์›ƒ๋ฐ”์šด๋“œ ๊ทœ์น™์— ๋ฐ˜๋“œ์‹œ ์ง€์ • ํ•„์š”.
  • ํ—ˆ์šฉ(Allow) ๊ทœ์น™์„ ์ง€์ •ํ•  ์ˆ˜ ์žˆ์ง€๋งŒ ๊ฑฐ๋ถ€(Deny, Block) ๊ทœ์น™์€ ์ง€์ •ํ•  ์ˆ˜ ์—†์Œ

  • ๊ตฌ์„ฑ ์š”์†Œ

    • Inbound Rule : source address + destination port (range)
    • Outbound Rule : destination address + destination port (range)
    • IP Protocol : TCP, UDPโ€ฆ
    • ICMP types and codes
  • ๐Ÿ™‹๐Ÿปโ€โ™€๏ธ EC2 ์˜ Linux OS ์—์„œ ๋™์ž‘ํ•˜๋Š” iptables ์™€๋Š” ์ „ํ˜€ ๋ณ„๊ฐœ์ด๋‹ค. โ‡’ ์•„๋ž˜ 1.4.5) ์—์„œ ํ™•์ธ

    • Security Group๋Š” ๋ณดํ†ต Hypervisor ๋‹จ์—์„œ ์ œ๊ณต๋˜์–ด ์ง€๋Š” ๊ธฐ๋Šฅ์ด๋‹ค. โ†’ ์•„๋ž˜ ๊ทธ๋ฆผ 1-1-1 ํ™•์ธ
  • ์ธ์Šคํ„ด์Šค์— ์ตœ๋Œ€ 5๊ฐœ์˜ Security Group(=๋ณด์•ˆ ๊ทธ๋ฃน)์„ ํ• ๋‹นํ•  ์ˆ˜ ์žˆ์Œ

  • VPC๋Š” ์ž๋™์œผ๋กœ ๊ธฐ๋ณธ ๋ณด์•ˆ ๊ทธ๋ฃน์„ ์ œ๊ณต. ๊ธฐ๋ณธ ๋ณด์•ˆ ๊ทธ๋ฃน์€ ์‚ญ์ œํ•  ์ˆ˜ ์—†์Œ

    Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/security-diagram.png

    ๊ทธ๋ฆผ 1-1-1 ๋ณด์•ˆ๊ทธ๋ฃน์€ ํ•˜์ด๋ฒ„๋ฐ”์ด์ €๋ ˆ๋ฒจ์—์„œ ์ œ๊ณต๋จ


1.2 Network ACL ์†Œ๊ฐœ

  • ์„œ๋ธŒ๋„ท(Subnet) ๊ธฐ๋ฐ˜์˜ ์ธ๋ฐ”์šด๋“œ(Inbound) ๋ฐ ์•„์›ƒ๋ฐ”์šด๋“œ(Outbound) ํŠธ๋ž˜ํ”ฝ์„ ์ œ์–ดํ•˜๋Š” Second Level ๋ณด์•ˆ ๊ธฐ๋Šฅ์„ ์ œ๊ณต

  • ์ธ๋ฐ”์šด๋“œ(Inbound) ํŠธ๋ž˜ํ”ฝ์„ ์ œ์–ดํ•˜๋Š” ๊ทœ์น™๊ณผ ์•„์›ƒ๋ฐ”์šด๋“œ(Outbound) ํŠธ๋ž˜ํ”ฝ์„ ์ œ์–ดํ•˜๋Š” ๊ทœ์น™์€ ๊ฐ๊ฐ ๋™์ž‘ํ•˜๋‚˜ ๋ฐ€์ ‘ํ•œ ์—ฐ๊ด€์ด ์žˆ์Œ

  • ๋ณด์•ˆ ๊ทธ๋ฃน(Security Group)๊ณผ๋Š” ๋‹ค๋ฅด๊ฒŒ ์ƒํƒœ๋ฅผ ์ €์žฅ ํ•˜์ง€ ์•Š์Œ(Stateless)

    • Network ACL ๊ทœ์น™์€ ์š”์ฒญ ํŠธ๋ž˜ํ”ฝ์„ ์ธ๋ฐ”์šด๋“œ ๊ทœ์น™์— ํ—ˆ์šฉ๊ณผ ๋ฆฌํ„ด ํŠธ๋ž˜ํ”ฝ์„ ์•„์›ƒ๋ฐ”์šด๋“œ ๊ทœ์น™์— ๋ฐ˜๋“œ์‹œ ์ง€์ • ํ•„์š”

    • ๋ฆฌํ„ด ํŠธ๋ž˜ํ”ฝ์— ๋Œ€ํ•œ ์ œ์–ด๋ฅผ ์œ„ํ•ด์„œ ํœ˜๋ฐœ์„ฑ ํฌํŠธ(Ephemeral port)์— ๋Œ€ํ•œ ์ดํ•ด๊ฐ€ ํ•„์š”ํ•จ โ†’ ํœ˜๋ฐœ์„ฑ ํฌํŠธ ๋ฒ”์œ„๋กœ ํ—ˆ์šฉ ํ•„์š”

    • ํœ˜๋ฐœ์„ฑ ํฌํŠธ(Ephemeral port, ํ˜น์€ โ€˜์ž„์‹œ ํฌํŠธโ€™)

      • ์˜ˆ๋ฅผ ๋“ค๋ฉด ์›นํด๋ผ์ด์–ธํŠธ๊ฐ€ ์›น์„œ๋ฒ„์— ์ ‘์† ์‹œ ์›น์„œ๋ฒ„๋Š” TCP 80์„ ํ†ตํ•˜์—ฌ ์—ฐ๊ฒฐ๋˜๊ณ  ์›นํด๋ผ์ด์–ธํŠธ๊ฐ€ ์—ด๊ฒŒ๋˜๋Š” ์ž„์‹œ ํฌํŠธ(์˜ˆ. TCP 52345) ๋ฅผ Ephemeral port โ€˜์ž ์‹œ์‚ด์•„์žˆ๋Š” ํฌํŠธโ€™ ๋‹ค.

      • ํด๋ผ์ด์–ธํŠธ์—์„œ ์‚ฌ์šฉ๋˜๋Š” ์ž„์‹œ ํฌํŠธ๋Š” OS ๋ณ„ ๋ฒ”์œ„๊ฐ€ ๋‹ค๋ฅด๋‹ค

      • ์ผ๋ฐ˜์ ์œผ๋กœ IANA๊ถŒ๊ณ  ๋ฐ ๋งฅ๊ณผ ์œˆ๋„์šฐ(49152~65535), Linux(32768~61000) โ†’ ์•„๋ž˜ Code ์ฐฝ ํ™•์ธ

      • ์ž„์‹œ ํฌํŠธ ๊ด€๋ จ ์ฐธ๊ณ  ๋งํฌ

        • https://en.wikipedia.org/wiki/Ephemeral_port
        • https://www.cymru.com/jtk/misc/ephemeralports.html
        • https://www.cyberciti.biz/tips/linux-increase-outgoing-network-sockets-range.html
        1
        2
        3
        # ๋ฆฌ๋ˆ…์Šค์—์„œ ์‚ฌ์šฉ๋˜๋Š” ์ž„์‹œ ํฌํŠธ(Ephemeral port) ๋ฒ”์œ„ ํ™•์ธ
        $ cat /proc/sys/net/ipv4/ip_local_port_range
        32768 60999
  • ๋ณด์•ˆ ๊ทธ๋ฃน(Security Group)๊ณผ๋Š” ๋‹ค๋ฅด๊ฒŒ ํ—ˆ์šฉ ๋ฐ ๊ฑฐ๋ถ€(์ฐจ๋‹จ) ๊ทœ์น™์„ ์ง€์ • ๊ฐ€๋Šฅ

  • ๋ณด์•ˆ ๊ทธ๋ฃน(Security Group)๊ณผ๋Š” ๋‹ค๋ฅด๊ฒŒ Network ACL์ด ์ ์šฉ๋œ ๋ชจ๋“  ์„œ๋ธŒ๋„ท ๋‚ด๋ถ€์— ์ธ์Šคํ„ด์Šค(EC2)์— ์˜ํ–ฅ์„ ๋ฏธ์นจ

    • Network ACL์€ ์—ฌ๋Ÿฌ ๊ฐœ์˜ ์„œ๋ธŒ๋„ท์— ์—ฐ๊ฒฐ๋  ์ˆ˜ ์žˆ์Œ
  • ๊ตฌ์„ฑ์š”์†Œ

    • source (inbound) or destination (outbound) addresses (CIDR block)
    • IP protocols (TCP, UDPโ€ฆ)
    • destination port numbers
  • ํŠธ๋ž˜ํ”ฝ ํ—ˆ์šฉ ์—ฌ๋ถ€ ํŒ๋‹จ ์‹œ ๋ฒˆํ˜ธ์ˆœ๋ฒˆ ๋Œ€๋กœ์˜ ๊ทœ์น™์œผ๋กœ ์ฒ˜๋ฆฌํ•จ

    Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/security-diagram%201.png

    ๊ทธ๋ฆผ 1-2 ๋„คํŠธ์›ŒํฌACL์€ ์„œ๋ธŒ๋„ท(Subnet) ๊ธฐ๋ฐ˜์—์„œ ๋™์ž‘

๋ณด์•ˆ ๊ทธ๋ฃน(Security Group) ๊ณผ ๋„คํŠธ์›Œํฌ ACL ๊ฐ„ ์ฐจ์ด

Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/Untitled.png


1.3 ์‹ค์Šต์„ ์œ„ํ•œ ๊ตฌ์„ฑ

1.3.1) Lab Topology

  • ์„œ์šธ Region ์— ์‹ ๊ทœ VPC์— ์‹ ๊ทœ EC2 Instance (์›น ์„œ๋ฒ„) ๊ฐ€ ๋ฐฐ์น˜๋˜์–ด ์žˆ๊ณ  ๊ฐ์ž ์ž์‹ ์˜ ์ง‘PC(HomePC)์—์„œ EC2(์›น ์„œ๋ฒ„)๋ฅผ ์ ‘์†ํ•œ๋‹ค

    Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/Untitled%201.png

1.3.2) ๊ตฌ์„ฑ์„ ์œ„ํ•œ ๊ธฐ๋ณธ ์„ค์ •

  • ๋ณธ ์‹ค์Šต์—์„œ ํ™œ์šฉํ•  AWS Region์€ ์„œ์šธ ์ž…๋‹ˆ๋‹ค. ํ•ด๋‹น Region์— ๋Œ€ํ•œ EC2-Key Pair๋ฅผ ์ƒ์„ฑ
  • ์„œ์šธ Region ์— ๋ฆฌ์†Œ์Šค๋Š” CloudFormation์— ์˜ํ•ด ์ธํ”„๋ผ๋ฅผ ์ž๋™ ๊ตฌ์ถ• (1.3.3ํ•ญ์—์„œ ์ง„ํ–‰)

1.3.3) CloudFormation

์„œ์šธ Region์—์„œ CloudFormation ์Šคํƒ์„ ์ƒ์„ฑํ•œ๋‹ค.
  • 1๋‹จ๊ณ„ ํ…œํ”Œ๋ฆฟ ์ง€์ •
    • ํ…œํ”Œ๋ฆฟ ์ค€๋น„ : ์ค€๋น„๋œ ํ…œํ”Œ๋ฆฟ
    • ํ…œํ”Œ๋ฆฟ ์†Œ์Šค : Amazon S3 URL
    • Amazon S3 URL : https://s3.ap-northeast-2.amazonaws.com/cloudformation.cloudneta.net/NetworkSecurity/Network-Security_SecurityGroup.yaml
      • ์šฐ์ธก ํ•˜๋‹จ ๋‹ค์Œ ํด๋ฆญ
  • 2๋‹จ๊ณ„ ์Šคํƒ ์„ธ๋ถ€ ์ •๋ณด ์ง€์ •
    • ์Šคํƒ ์ด๋ฆ„ : SG
    • KeyName : ์ž์‹ ์˜ EC2-Key Pair ๋ฅผ ์ง€์ •
  • 3๋‹จ๊ณ„ ์Šคํƒ ์˜ต์…˜ ๊ตฌ์„ฑ
    • ์šฐ์ธก ํ•˜๋‹จ ๋‹ค์Œ ํด๋ฆญ
  • 4๋‹จ๊ณ„ ๊ฒ€ํ† 
    • ์šฐ์ธก ํ•˜๋‹จ ์Šคํƒ ์ƒ์„ฑ ํด๋ฆญ
์„œ์šธ CloudFormation ์ƒ์„ฑ ์ธํ”„๋ผ
- VPC, 1 Subnet, 1 IGW, 1 Route table
- Amazon Linux 2 EC2 Instance(Public IP, User data ์‚ฌ์šฉ)

1.3.4) ๊ฒ€์ฆ

  • ์‚ฌ์šฉ์ž PC์—์„œ ์„œ์šธ EC2 Instance Public IP ์ฃผ์†Œ๋กœ SSH ์ ‘๊ทผํ•œ๋‹ค. ์ ‘์† ๊ณ„์ • root / qwe123

    1
    2
    $ ssh root@13.209.10.34
    root@13.209.10.34's password: qwe123

1.3.5) ์‹ค์Šต ์ „ ์‚ฌ์ „ ์„ค์ •

๋ณด์•ˆ ๊ทธ๋ฃน '์•„์›ƒ๋ฐ”์šด๋“œ ๊ทœ์น™' ์—์„œ ๊ธฐ๋ณธ ๊ทœ์น™์„ ์‚ญ์ œํ•œ๋‹ค
  • ๋ณด์•ˆ ๊ทธ๋ฃน ์ค‘ ์„ค๋ช… โ€˜EC2-Instance-SGโ€™ ํด๋ฆญํ•˜์—ฌ ์„ ํƒ ํ›„ โ€˜์•„์›ƒ๋ฐ”์šด๋“œ ๊ทœ์น™โ€™ ์„ ํƒ ํ›„ โ€˜์•„์›ƒ๋ฐ”์šด๋“œ ๊ทœ์น™ ํŽธ์ง‘โ€™ ์„ ํƒ

    Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/_2020-05-12__9.06.41.png

    • ๊ธฐ๋ณธ ๊ทœ์น™์„ ์‚ญ์ œ - ์œ ํ˜•(๋ชจ๋“  ํŠธ๋ž˜ํ”ฝ) ๋Œ€์ƒ(0.0.0.0) โ‡’ ํ•˜๋‹จ ๊ทœ์น™ ์ €์žฅ

      Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/_2020-05-12__9.08.43.png

  • (์˜ต์…˜) VPC Flow Logs ๋ฅผ ์„ค์ •ํ•œ๋‹ค โ† ์ด ๋ถ€๋ถ„์€ IAM , CloudWatch ๊ธฐ๋ณธ ์ง€์‹์ด ํ•„์š”ํ•จ์œผ๋กœ ํ•„์ž๋งŒ ์„ค์ •ํ•˜๊ฒŒ๋˜๋‹ˆ Skip ํ•˜๋ฉด ๋œ๋‹ค
์ •๋ณด ์ˆจ๊น€
  • EC2 ENI ์— VPC Flow Logs ์„ค์ •
    • Filter: Reject
    • Interval : 1๋ถ„
    • Format : Custom format
    • ${srcaddr} ${srcport} ${dstaddr} ${dstport} ${tcp-flags} ${protocol} ${action}
      • tcp-flags ์ฐธ๊ณ 
        • SYN : 2
        • SYN-ACK : 18
        • FIN : 1
        • RST : 4
    • EC2 ENI ๋กœ๊ทธ ๋ฐœ์ƒ โ†’ ์ฐจ๋‹จ ๋ฐœ์ƒ ํ›„ 1๋ถ„30์ดˆ ํ›„์— ๋กœ๊ทธ์— ์Œ“์ž„
  • CloudWatch Log ํ•„ํ„ฐ ์ฐธ๊ณ 
    • โ€œ220.117.X.Xโ€ โ€œ10.40.1.100โ€ โ† 2๊ฐœ์˜ IP๊ฐ€ ๋™์‹œ ์ผ์น˜ ํ•„ํ„ฐ(AND)
    • ?โ€220.117.X.Xโ€ ?โ€10.40.1.100โ€ โ† 2๊ฐœ์˜ IP์ค‘ ํ•˜๋‚˜๋งŒ ์ผ์น˜ ํ•„ํ„ฐ(OR)
    • ?โ€80 2 6โ€ ?โ€22 2 6โ€ โ† TCP 80 SYN ํ˜น์€ TCP 22 SYN ์˜ OR ํ•„ํ„ฐ
    • โ€œ80 2 6โ€ -โ€œ443โ€ -โ€œ805โ€ -โ€œ808โ€ -โ€œ809โ€ -โ€œ123โ€ โ† TCP 80 SYN ํ•„ํ„ฐ
    • โ€œ22 2 6โ€ -โ€œ443โ€ -โ€œ805โ€ -โ€œ808โ€ -โ€œ809โ€ -โ€œ123โ€ โ† TCP 22 SYN ํ•„ํ„ฐ
    • โ€œ10.40.1.100โ€ โ€œ80 2 6โ€ -โ€œ443โ€ -โ€œ805โ€ -โ€œ808โ€ -โ€œ809โ€ -โ€œ123โ€ โ† EC2๋กœ Web ์‹œ๋„ ํ•„ํ„ฐ
    • โ€œ10.40.1.100โ€ โ€œ22 2 6โ€ -โ€œ443โ€ -โ€œ805โ€ -โ€œ808โ€ -โ€œ809โ€ -โ€œ123โ€ โ† EC2๋กœ SSH ์‹œ๋„ ํ•„ํ„ฐ

1.4 Security Group ์„ค์ • ๋ฐ ํ™•์ธ

1.4.1) ํ˜„์žฌ EC2 ์— ์ ์šฉ๋œ Security Group ํ™•์ธ

  • ์ธ๋ฐ”์šด๋“œ ๊ทœ์น™ : ํ•ด๋‹น EC2์— SSH๋กœ ์–ด๋Š ์‚ฌ์šฉ์ž(0.0.0.0/0)๋“  ์ ‘์† ๊ฐ€๋Šฅ

    Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/_2020-05-12__10.15.45.png

  • ์•„์›ƒ๋ฐ”์šด๋“œ ๊ทœ์น™ : ์•„๋ฌด ์ •์ฑ…์ด ์—†์œผ๋ฏ€๋กœ ๋ชจ๋“  ํŠธ๋ž˜ํ”ฝ์„ ์ฐจ๋‹จ

    Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/_2020-05-12__10.18.04.png

1.4.2) ์™ธ๋ถ€์—์„œ EC2๋กœ SSH ์ ‘์† ๋ฐ ํ™•์ธ

  • (1) ์™ธ๋ถ€(HomePC)์—์„œ ๋ชฉ์ ์ง€IP๋ฅผ EC2์˜ EIP(13.209.10.34)๋กœ ์ ‘์†์„ ํ•˜๋ฉด, ์•„๋ž˜ ๊ทธ๋ฆผ ์ฒ˜๋Ÿผ NAT ๊ธฐ๋Šฅ์— ์˜ํ•ด์„œ EC2 Private IP(10.40.1.100)์œผ๋กœ ๋ณ€ํ™˜ํ•˜๊ฒŒ ๋จ

  • (2) ์ธ๋ฐ”์šด๋“œ ๊ทœ์น™์— ๋ชฉ์ ์ง€Port 22์™€ ์ถœ๋ฐœ์ง€IP๋Š” 0.0.0.0/0 ์œผ๋กœ ํ—ˆ์šฉ์ด๋ฏ€๋กœ EC2 ๋‚ด๋ถ€๋กœ ์ „๋‹ฌํ•จ

  • (3) EC2 ๋‚ด๋ถ€ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜(SSH)์—์„œ ์ฒ˜๋ฆฌ ํ›„ ๋ฆฌํ„ด ํŠธ๋ž˜ํ”ฝ(Return Traffic)๋Š” IP์™€ Port๋ฅผ ์ถœ๋ฐœ์ง€์™€ ๋ชฉ์ ์ง€๋ฅผ ๋ฐ”๊พผ ํ›„ ๋˜๋Œ์•„๊ฐ„๋‹ค

  • (4) ์•„์›ƒ๋ฐ”์šด๋“œ ๊ทœ์น™์— ์•„๋ฌด ๊ทœ์น™์ด ์—†์œผ๋ฏ€๋กœ ์›์น™์ ์œผ๋กœ๋Š” ๋ชจ๋“  ํŠธ๋ž˜ํ”ฝ์ด EC2์—์„œ ์™ธ๋ถ€๋กœ ๋น ์ €๋‚˜๊ฐ€์ง€ ๋ชปํ•ด์•ผ ํ•˜์ง€๋งŒ ๋น ์ ธ๋‚˜๊ฐ„๋‹ค ๐Ÿคท๐Ÿปโ€โ™€๏ธ

    • ์ด์œ ๋Š” Stateful ๋™์ž‘์— ์˜ํ•ด EC2๋กœ ์ธ์ž… ์‹œ ์ƒํƒœ๋ฅผ ๊ธฐ์–ตํ•˜๊ณ , ํ•ด๋‹น ํŠธ๋ž˜ํ”ฝ์ด ๋ฆฌํ„ด(Return) ์‹œ ํ•ด๋‹น ํŠธ๋ž˜ํ”ฝ์€ ์•„์›ƒ๋ฐ”์šด๋“œ ๊ทœ์น™๊ณผ ์ƒ๊ด€์—†์ด ํ—ˆ์šฉ๋จ
  • ๋ฆฌํ„ด ํŠธ๋ž˜ํ”ฝ(Return Traffic)๋Š” IP์™€ Port๋ฅผ ์ถœ๋ฐœ์ง€์™€ ๋ชฉ์ ์ง€๋ฅผ ๋ฐ”๊พผ ํ›„ ๋˜๋Œ์•„๊ฐ„๋‹ค

    1
    2
    3
    4
    $ ssh root@13.209.10.34
    root@13.209.10.34's password:
    [root@SGLAB-EC2 ~]# netstat -nap | grep ESTABLISHED
    tcp 0 0 10.40.1.100:22 220.117.X.X:54812 ESTABLISHED 338/sshd: root@pts/

    Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/Untitled%202.png

1.4.3) ๋‚ด๋ถ€ EC2์—์„œ ์™ธ๋ถ€๋กœ HTTP ์ ‘์† ๋ฐ ํ™•์ธ

  • ๋‚ด๋ถ€ EC2์—์„œ ์™ธ๋ถ€๋กœ ์ ‘์† ์‹œ ์•„์›ƒ๋ฐ”์šด๋“œ ๊ทœ์น™์— ์˜ํ•ด์„œ ์ฐจ๋‹จ๋จ

    1
    2
    3
    4
    5
    # curl ifconfig.me
    curl: (7) Failed to connect to ifconfig.me port 80: Connection timed out

    # netstat -nap |grep curl
    tcp 0 1 10.40.1.100:34972 216.239.36.21:80 SYN_SENT 418/curl
  • ํ˜„์žฌ ์•„์›ƒ๋ฐ”์šด๋“œ ๊ทœ์น™์€ ์•„๋ฌด ๊ทœ์น™๋„ ์—†์Œ

    Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/Untitled%203.png

  • (์˜ต์…˜) VPC Flow-logs ์—๋„ ๋‚ด๋ถ€EC2(10.40.1.100)์ด ์™ธ๋ถ€(216.239.36.21)๋กœ TCP 80 ์œผ๋กœ ์ ‘์† ์‹œ๋„์—์„œ ์ฐจ๋‹จ(REJECT) ๋จ์„ ํ™•์ธ

    Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/_2020-05-12__10.45.18.png

  • ์œ„๋ฅผ ํ†ตํ•˜์—ฌ ์ธ๋ฐ”์šด๋“œ์™€ ์•„์›ƒ๋ฐ”์šด๋“œ ๊ทœ์น™์ด ๊ฐ๊ธฐ ๊ฐœ๋ณ„๋กœ ๋™์ž‘ํ•˜๋Š” ๊ฒƒ์„ ์•Œ ์ˆ˜ ์žˆ๊ณ , Stateful ๋™์ž‘์„ ์•Œ ์ˆ˜ ์žˆ๋‹ค

1.4.4) ๋‚ด๋ถ€ EC2์—์„œ ์™ธ๋ถ€๋กœ HTTP ์ ‘์† ์„ค์ •์„ ์œ„ํ•œ ์•„์›ƒ๋ฐ”์šด๋“œ ๊ทœ์น™ ์ถ”๊ฐ€ ๋ฐ ํ™•์ธ

  • ์•„์›ƒ๋ฐ”์šด๋“œ ๊ทœ์น™์— HTTP ์ ‘์†์„ ์ถ”๊ฐ€ํ•œ๋‹ค

    Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/_2020-05-12__10.52.28.png

  • ๋‹ค์‹œ ๋‚ด๋ถ€์—์„œ ์™ธ๋ถ€๋กœ HTTP ์ ‘์†์„ ์‹œ๋„ํ•œ๋‹ค โ†’ ์•„๋ž˜ ์ฒ˜๋Ÿผ ์ •์ƒ์ ์œผ๋กœ ์‘๋‹ต์ด ๋Œ์•„์˜จ๋‹ค

    1
    2
    3
    # ifconfig.me ๋กœ curl ์‹œ ์ž์‹ ์˜ PC๊ฐ€ ์ธํ„ฐ๋„ท ์ ‘์† ์‹œ ์ž์‹ ์˜ ๊ณต์ธIP๋ฅผ ์•Œ๋ ค์คŒ
    # curl ifconfig.me
    13.209.10.34
  • ์•„๋ž˜ ์ฒ˜๋Ÿผ ์•„์›ƒ๋ฐ”์šด๋“œ๋กœ ํŠธ๋ž˜ํ”ฝ์ด ์™ธ๋ถ€๋กœ ๋‚˜๊ฐ”๋‹ค๊ฐ€ ๋˜๋Œ์•„์˜ค๋Š”(Return) ํŠธ๋ž˜ํ”ฝ์€ ์ธ๋ฐ”์šด๋“œ ๊ทœ์น™์— ์—†์ง€๋งŒ, Stateful ๋™์ž‘์— ์˜ํ•ด์„œ ํ—ˆ์šฉ๋จ

    Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/Untitled%204.png

๐Ÿ’ก ์ผ๋ฐ˜์ ์œผ๋กœ ์•„์›ƒ๋ฐ”์šด๋“œ์— ๊ทœ์น™์„ ์ž˜ ์‚ฌ์šฉํ•˜์ง€๋Š” ์•Š์ง€๋งŒ, ๋ณด์•ˆ ๊ฐ•ํ™”๊ฐ€ ํ•„์š” ์‹œ(์˜ˆ, ๋ฏผ๊ฐํ•œ ์ •๋ณด๊ฐ€ ์ „๋‹ฌ ๋“ฑ) ์‹ค์ œ ํ•ด๋‹น EC2์—์„œ ์™ธ๋ถ€์— ์ ‘์†์„ ์‹œ๋„ํ•˜๋Š” TCP UDP ์„œ๋น„์Šค ํฌํŠธ ํ˜น์€ ์™ธ๋ถ€ ์ ‘์† ์ง€ IP ์ •๋ณด๋งŒ ์ ‘์† ํ•  ์ˆ˜ ์žˆ๊ฒŒ ์ œํ•œ์„ ํ•  ์ˆ˜ ์žˆ๋‹ค.


1.4.5) ์™ธ๋ถ€์—์„œ ๋‚ด๋ถ€ EC2๋กœ HTTP ์ ‘์†์„ ์œ„ํ•œ ์„ค์ • ๋ฐ ํ™•์ธ

  • ํ˜„์žฌ ์ƒํƒœ์—์„œ ํ™•์ธ

    • ๋‚ด๋ถ€ EC2 ์—์„œ ์›น์„œ๋น„์Šค ์ƒํƒœ ํ™•์ธ โ†’ ์ •์ƒ ์ ‘์† ๋˜๋ฉฐ, iptables ์— ์•„๋ฌด๋Ÿฐ ์ •์ฑ…์ด ์—†์Œ(์ฆ‰ ๋ชจ๋‘ ํ—ˆ์šฉ)

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      # curl localhost
      <html><h1>Hello from Security Group Test Web Server</h1></html>

      # netstat -anp |grep http
      tcp6 0 0 :::80 :::* LISTEN 3563/httpd

      # iptables -L -n -v
      Chain INPUT (policy ACCEPT 208 packets, 14524 bytes)
      pkts bytes target prot opt in out source destination

      Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
      pkts bytes target prot opt in out source destination

      Chain OUTPUT (policy ACCEPT 122 packets, 12192 bytes)
      pkts bytes target prot opt in out source destination
    • ์™ธ๋ถ€์—์„œ EC2๋กœ ์›น ์ ‘์† โ†’ ์ธ๋ฐ”์šด๋“œ ๊ทœ์น™์— ํ˜„์žฌ TCP 22(SSH)๋งŒ ํ—ˆ์šฉ๋˜๋ฏ€๋กœ ์ฐจ๋‹จ๋จ

      โ‡’ ์ฆ‰, ํ˜„์žฌ ์ฐจ๋‹จ์€ Linux OS์˜ iptables ์™€๋Š” ์ƒ๊ด€ ์—†๋‹ค๋Š” ๊ฒƒ์ด๋‹ค! , ๋ฌผ๋ก  iptables ์„ค์ •์œผ๋กœ ์ฐจ๋‹จํ•  ์ˆ˜ ์žˆ์œผ๋‚˜ ์šด์˜ ๊ด€๋ฆฌ์˜ ๋ณต์žก์„ฑ์œผ๋กœ ๋น„๊ถŒ์žฅํ•œ๋‹ค

      1
      2
      $ curl 13.209.10.34
      curl: (7) Failed to connect to 13.209.10.34 port 80: Operation timed out
    • (์˜ต์…˜) VPC Flow-logs ์—๋„ ์ฐจ๋‹จ(REJECT) ๋จ์„ ํ™•์ธ

      Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/_2020-05-12__11.17.57.png

  • ์ธ๋ฐ”์šด๋“œ ๊ทœ์น™์— HTTP ์ถ”๊ฐ€

    Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/_2020-05-12__11.19.33.png

  • ์™ธ๋ถ€์—์„œ EC2๋กœ ์›น ์ ‘์† โ†’ ์„ฑ๊ณต!

    1
    2
    $ curl 13.209.10.34
    <html><h1>Hello from Security Group Test Web Server</h1></html>
  • ์•„๋ž˜ ๊ทธ๋ฆผ ์ฒ˜๋Ÿผ (1) ์™ธ๋ถ€์—์„œ EIP๋กœ HTTP๋กœ ์ ‘์†๋˜๊ณ  NAT ํ›„ (2) ์ธ๋ฐ”์šด๋“œ ๊ทœ์น™(TCP 80)์— ํ—ˆ์šฉ๋˜์–ด (3) EC2 ๋‚ด๋ถ€๋กœ ์ธ์ž…๋˜์–ด ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ ์ฒ˜๋ฆฌ ํ›„ (4) ํŠธ๋ž˜ํ”ฝ์ด ๋ฆฌํ„ด ๋œ๋‹ค.

    Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/Untitled%205.png


1.5 ์ƒ์„ฑํ•œ ์ž์› ์‚ญ์ œ

  • ์„œ์šธ Region์—์„œ CloudFormation ์Šคํƒ์„ ์‚ญ์ œํ•œ๋‹ค


2. Network Access Control List

2.1 ์‹ค์Šต์„ ์œ„ํ•œ ๊ตฌ์„ฑ

2.1.1) Lab Topology

  • ์„œ์šธ Region ์— ์‹ ๊ทœ VPC์— ์‹ ๊ทœ EC2 Instance (์›น ์„œ๋ฒ„) 2๋Œ€๊ฐ€ ๋ฐฐ์น˜๋˜์–ด ์žˆ๊ณ  ๊ฐ์ž ์ž์‹ ์˜ ์ง‘PC(HomePC)์—์„œ EC2(์›น ์„œ๋ฒ„)๋ฅผ ์ ‘์†ํ•œ๋‹ค

    Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/Untitled%206.png

2.1.2) ๊ตฌ์„ฑ์„ ์œ„ํ•œ ๊ธฐ๋ณธ ์„ค์ •

  • ๋ณธ ์‹ค์Šต์—์„œ ํ™œ์šฉํ•  AWS Region์€ ์„œ์šธ ์ž…๋‹ˆ๋‹ค. ํ•ด๋‹น Region์— ๋Œ€ํ•œ EC2-Key Pair๋ฅผ ์ƒ์„ฑ
  • ์„œ์šธ Region ์— ๋ฆฌ์†Œ์Šค๋Š” CloudFormation์— ์˜ํ•ด ์ธํ”„๋ผ๋ฅผ ์ž๋™ ๊ตฌ์ถ• (2.1.3ํ•ญ์—์„œ ์ง„ํ–‰)

2.1.3) CloudFormation

์„œ์šธ Region์—์„œ CloudFormation ์Šคํƒ์„ ์ƒ์„ฑํ•œ๋‹ค.
  • 1๋‹จ๊ณ„ ํ…œํ”Œ๋ฆฟ ์ง€์ •
    • ํ…œํ”Œ๋ฆฟ ์ค€๋น„ : ์ค€๋น„๋œ ํ…œํ”Œ๋ฆฟ
    • ํ…œํ”Œ๋ฆฟ ์†Œ์Šค : Amazon S3 URL
    • Amazon S3 URL : https://s3.ap-northeast-2.amazonaws.com/cloudformation.cloudneta.net/NetworkSecurity/Network-NetworkACL.yaml
      • ์šฐ์ธก ํ•˜๋‹จ ๋‹ค์Œ ํด๋ฆญ
  • 2๋‹จ๊ณ„ ์Šคํƒ ์„ธ๋ถ€ ์ •๋ณด ์ง€์ •
    • ์Šคํƒ ์ด๋ฆ„ : NACL
    • KeyName : ์ž์‹ ์˜ EC2-Key Pair ๋ฅผ ์ง€์ •
  • 3๋‹จ๊ณ„ ์Šคํƒ ์˜ต์…˜ ๊ตฌ์„ฑ
    • ์šฐ์ธก ํ•˜๋‹จ ๋‹ค์Œ ํด๋ฆญ
  • 4๋‹จ๊ณ„ ๊ฒ€ํ† 
    • ์šฐ์ธก ํ•˜๋‹จ ์Šคํƒ ์ƒ์„ฑ ํด๋ฆญ
์„œ์šธ CloudFormation ์ƒ์„ฑ ์ธํ”„๋ผ
- VPC, 1 Subnet, 1 IGW, 1 Route table
- Amazon Linux 2 EC2 Instance(User data ์‚ฌ์šฉ) - 2๋Œ€

2.1.4) ๊ฒ€์ฆ

  • ์‚ฌ์šฉ์ž PC์—์„œ ์„œ์šธ EC2(2๋Œ€)์˜ Public IP ์ฃผ์†Œ๋กœ ๊ฐ๊ฐ SSH ์ ‘๊ทผํ•œ๋‹ค. ์ ‘์† ๊ณ„์ • root / qwe123

    1
    2
    $ ssh root@*'EC2 Public IP'*
    root@*'EC2 Public IP'*s password: qwe123

2.1.5) ์‹ค์Šต ์ „ ์‚ฌ์ „ ์„ค์ •

๋ณด์•ˆ ๊ทธ๋ฃน '์ธ๋ฐ”์šด๋“œ ๊ทœ์น™' ๊ณผ '์•„์›ƒ๋ฐ”์šด๋“œ ๊ทœ์น™' ์€ '๋ชจ๋‘ ํ—ˆ์šฉ' ๋˜๊ณ  ์žˆ์Œ์„ ํ™•์ธ โ†’ Network ACL ์‹ค์Šต์— ์˜ํ–ฅ๋„๋ฅผ ์ œ๊ฑฐํ•˜๊ธฐ ์œ„ํ•จ

Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/Untitled%207.png

Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/Untitled%208.png

  • (์˜ต์…˜) VPC Flow Logs ๋ฅผ ์„ค์ •ํ•œ๋‹ค โ† ์ด ๋ถ€๋ถ„์€ IAM , CloudWatch ๊ธฐ๋ณธ ์ง€์‹์ด ํ•„์š”ํ•จ์œผ๋กœ ํ•„์ž๋งŒ ์„ค์ •ํ•˜๊ฒŒ๋˜๋‹ˆ Skip ํ•˜์‹œ๋ฉด ๋œ๋‹ค
์ •๋ณด ์ˆจ๊น€
  • Subnet(SGLAB2-Subnet0101) ์— VPC Flow Logs ์„ค์ •
    • Filter: Reject
    • Interval : 1๋ถ„
    • Format : Custom format
    • ${srcaddr} ${srcport} ${dstaddr} ${dstport} ${tcp-flags} ${protocol} ${action}
      • tcp-flags ์ฐธ๊ณ 
        • SYN : 2
        • SYN-ACK : 18
        • FIN : 1
        • RST : 4
    • EC2 ENI ๋กœ๊ทธ ๋ฐœ์ƒ โ†’ ์ฐจ๋‹จ ๋ฐœ์ƒ ํ›„ 1๋ถ„30์ดˆ ํ›„์— ๋กœ๊ทธ์— ์Œ“์ž„
  • CloudWatch Log ํ•„ํ„ฐ ์ฐธ๊ณ 
    • โ€œ220.117.X.Xโ€ โ€œ10.40.1.100โ€ โ† 2๊ฐœ์˜ IP๊ฐ€ ๋™์‹œ ์ผ์น˜ ํ•„ํ„ฐ(AND)
    • ?โ€220.117.X.Xโ€ ?โ€10.40.1.100โ€ โ† 2๊ฐœ์˜ IP์ค‘ ํ•˜๋‚˜๋งŒ ์ผ์น˜ ํ•„ํ„ฐ(OR)
    • ?โ€80 2 6โ€ ?โ€22 2 6โ€ โ† TCP 80 SYN ํ˜น์€ TCP 22 SYN ์˜ OR ํ•„ํ„ฐ
    • โ€œ80 2 6โ€ -โ€œ443โ€ -โ€œ805โ€ -โ€œ808โ€ -โ€œ809โ€ -โ€œ123โ€ โ† TCP 80 SYN ํ•„ํ„ฐ
    • โ€œ22 2 6โ€ -โ€œ443โ€ -โ€œ805โ€ -โ€œ808โ€ -โ€œ809โ€ -โ€œ123โ€ โ† TCP 22 SYN ํ•„ํ„ฐ
    • โ€œ10.40.1.100โ€ โ€œ80 2 6โ€ -โ€œ443โ€ -โ€œ805โ€ -โ€œ808โ€ -โ€œ809โ€ -โ€œ123โ€ โ† EC2๋กœ Web ์‹œ๋„ ํ•„ํ„ฐ
    • โ€œ10.40.1.100โ€ โ€œ22 2 6โ€ -โ€œ443โ€ -โ€œ805โ€ -โ€œ808โ€ -โ€œ809โ€ -โ€œ123โ€ โ† EC2๋กœ SSH ์‹œ๋„ ํ•„ํ„ฐ

2.2 Network ACL ์„ค์ • ๋ฐ ํ™•์ธ

2.2.1) ํ˜„์žฌ Subnet(SGLAB2-Subnet0101) ์— ์ ์šฉ๋œ Network ACL ํ™•์ธ

  • (default) Network ACL ์ธ๋ฐ”์šด๋“œ ๊ทœ์น™ : ๊ธฐ๋ณธ์ ์œผ๋กœ โ€˜rule #100 ๋ชจ๋“  ํŠธ๋ž˜ํ”ฝ์„ ํ—ˆ์šฉโ€™ ํ•จ, ๋งจ ํ•˜๋‹จ์€ ๋ชจ๋‘ ์ฐจ๋‹จ์œผ๋กœ ์šฐ์„  ์ˆœ์„œ๊ฐ€ ๋‚ฎ์•„์„œ ํ˜„์žฌ ์ ์šฉ๋˜์ง€ ์•Š์Œ

    Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/_2020-05-13__9.38.44.png

  • (default) Network ACL ์•„์›ƒ๋ฐ”์šด๋“œ ๊ทœ์น™ : ์œ„ ์ธ๋ฐ”์šด๋“œ ๊ทœ์น™๊ณผ ๋™์ผ, ๋ชจ๋“  ํŠธ๋ž˜ํ”ฝ์„ ํ—ˆ์šฉ

    Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/_2020-05-13__9.44.11.png

2.2.2) ์‹ ๊ทœ Network ACL ์ƒ์„ฑ ์ ์šฉ ๋ฐ ํ™•์ธ

  • [VPC - ๋ณด์•ˆ - ๋„คํŠธ์›Œํฌ ACL] ์ƒ๋‹จ ๋„คํŠธ์›Œํฌ ACL ์ƒ์„ฑ ํด๋ฆญ

    • ์ด๋ฆ„ ํƒœ๊ทธ : NACL1
    • VPC : (SGLAB2) ์„ ํƒ
      • ํ•˜๋‹จ ์ƒ์„ฑ ํด๋ฆญ
  • [VPC - ๋ณด์•ˆ - ๋„คํŠธ์›Œํฌ ACL] ์ƒ์„ฑ๋œ NACL1 ์„ ํƒ โ†’ ์ƒ๋‹จ ์ž‘์—… ์„ ํƒ โ†’ ์„œ๋ธŒ๋„ท ์—ฐ๊ฒฐ ํŽธ์ง‘ ํด๋ฆญ

    • ์•„๋ž˜ ์ฒ˜๋Ÿผ 10.41.0.0/24 ์„œ๋ธŒ๋„ท์€ ์—ฐ๊ฒฐ ํ•ด์ฃผ๊ธฐ ์œ„ํ•ด์„œ ์„ ํƒ ํ›„ ํ•˜๋‹จ ํŽธ์ง‘ ํด๋ฆญ

      Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/Untitled%209.png

  • [VPC - ๋ณด์•ˆ - ๋„คํŠธ์›Œํฌ ACL] ์ƒ์„ฑ๋œ NACL1 ์„ ํƒ ํ›„ default ๊ทœ์น™ ํ™•์ธ

    • ์‹ ๊ทœ ์ƒ์„ฑ๋œ Network ACL ์ธ๋ฐ”์šด๋“œ ๊ทœ์น™ : ์ธ์ž…๋˜๋Š” ๋ชจ๋“  ํŠธ๋ž˜ํ”ฝ์„ ์ฐจ๋‹จ

      Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/Untitled%2010.png

    • ์‹ ๊ทœ ์ƒ์„ฑ๋œ Network ACL ์•„์›ƒ๋ฐ”์šด๋“œ ๊ทœ์น™ : ์ธ์ž…๋˜๋Š” ๋ชจ๋“  ํŠธ๋ž˜ํ”ฝ์„ ์ฐจ๋‹จ

      Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/Untitled%2011.png

2.2.3) NACL1 Network ACL ๊ทœ์น™ ํŽธ์ง‘ 1

  • ๋ชฉ์  : ์™ธ๋ถ€์—์„œ EC2๋Œ€์—ญ์— ๋Œ€ํ•œ SSH ์ ‘์†์„ ํ—ˆ์šฉ (Network ACL inbound outbound rule)

  • NACL Name: NACL1 ์„ ํƒ ํ›„ Inbound Rule (์ธ๋ฐ”์šด๋“œ ๊ทœ์น™) ํŽธ์ง‘

    • ๊ทœ์น™(10), ์œ ํ˜•(SSH) - ํ”„๋กœํ† ์ฝœ(TCP), ํฌํŠธ๋ฒ”์œ„(22), ์†Œ์Šค(0.0.0.0/0), ํ—ˆ์šฉ/๊ฑฐ๋ถ€(ALLOW)

      • ํฌํŠธ๋ฒ”์œ„๋Š” ํŠธ๋ž˜ํ”ฝ ์ธ์ž… ์‹œ ๋ชฉ์ ์ง€ ํฌํŠธ ๋ฒ”์œ„์ด๋‹ค
      • ์†Œ์ŠคIP๋Š” ํŠธ๋ž˜ํ”ฝ ์ธ์ž… ์‹œ ์ถœ๋ฐœ์ง€IP ๋ฒ”์œ„์ด๋‹ค
        • ์ดํ›„ ์ €์žฅ ์‹œ ์ตœํ•˜๋‹จ์— ๋ชจ๋“  ํŠธ๋ž˜ํ”ฝ์„ ๊ฑฐ๋ถ€ DENY Rule ์ด ์กด์žฌํ•œ๋‹ค
    • ์•„์›ƒ๋ฐ”์šด๋“œ ๊ทœ์น™๋„ ๊ธฐ๋ณธ(๋””ํดํŠธ)๋กœ ๋ชจ๋“  ํŠธ๋ž˜ํ”ฝ์„ ๊ฑฐ๋ถ€ DENY Rule ์ด ์กด์žฌํ•œ๋‹ค

      Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/_2020-05-13__9.57.39.png

  • ์™ธ๋ถ€์—์„œ EC2 ๋กœ SSH ์ ‘์† ํ™•์ธ

    • ์™ธ๋ถ€์—์„œ EC2 SSH ์ ‘์†์ด ๋ถˆ๊ฐ€๋Šฅํ•˜๋‹ค

      1
      2
      3
      4
      5
      HomePC$ ssh root@13.125.132.54
      ssh: connect to host 13.125.132.54 port 22: Operation timed out

      HomePC$ ssh root@52.78.166.174
      ssh: connect to host 52.78.166.174 port 22: Operation timed out
      • (์˜ต์…˜) Cloudwatch ์—๋„ EC2๋กœ ์ธ์ž…๋˜์—ˆ์ง€๋งŒ ๋ฆฌํ„ด ํŠธ๋ž˜ํ”ฝ(TCP-SYN ์€ 18๋กœ ํ‘œํ˜„)์ด outbound rule ์— ์˜ํ•ด์„œ REJECT ๋จ์„ ํ™•์ธ

        Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/_2020-05-13__10.02.11.png

      • ์ด์œ  : inbound rule ํ—ˆ์šฉ๋˜์ง€๋งŒ ์ดํ›„ ์‘๋‹ต ํŠธ๋ž˜ํ”ฝ์ด outbound rule ์— ์˜ํ•ด ์ฐจ๋‹จ

        โ‡’ ๋ณด์•ˆ ๊ทœ์น™(Security group)๊ณผ๋Š” ๋‹ค๋ฅด๊ฒŒ Stateful ํ•˜์ง€ ์•Š๊ณ , Stateless ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๋ฆฌํ„ด ํŠธ๋ž˜ํ”ฝ์— ๋Œ€ํ•œ ํ—ˆ์šฉ์„ ์•„์›ƒ๋ฐ”์šด๋“œ ๊ทœ์น™์— ์ถ”๊ฐ€ํ•ด์•ผ ํ•œ๋‹ค

  • ํŠธ๋ž˜ํ”ฝ ํ๋ฆ„์— ๋”ฐ๋ฅธ ์„ค๋ช…

    • (1) ์™ธ๋ถ€(HomePC)์—์„œ EC2์˜ PublicIP(13.125.132.54)๋กœ SSH ์ ‘์†์„ ์‹œ๋„ํ•œ๋‹ค

    • (2) NAT ๊ธฐ๋Šฅ์— ์˜ํ•ด์„œ ๋ชฉ์ ์ง€ PublicIP(13.125.132.54) ๋ฅผ PrivateIP(10.40.1.100)์œผ๋กœ ๋ณ€๊ฒฝํ•œ๋‹ค

    • (3) Network ACL์— ์˜ํ•ด์„œ ์ถœ๋ฐœ์ง€IP๊ฐ€ 0.0.0.0/0 ์ด๊ณ  ๋ชฉ์ ์ง€ ํฌํŠธ SSH 22 ์ด๋ฏ€๋กœ ํ—ˆ์šฉ(ALLOW) ๋œ๋‹ค

    • (4) EC2 ๋‚ด๋ถ€์˜ SSH ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ์ฒ˜๋ฆฌ ํ•œ๋‹ค

    • (5) ๋ฆฌํ„ด ํŠธ๋ž˜ํ”ฝ์ด๋ฏ€๋กœ ์ถœ๋ฐœ์ง€์™€ ๋ชฉ์ ์ง€์˜ IP์™€ Port ๊ฐ€ ๋’ค๋ฐ”๋€Œ์–ด ์ „๋‹ฌ๋œ๋‹ค

    • (6) ๋ฆฌํ„ด ํŠธ๋ž˜ํ”ฝ์ด Network ACL ์•„์›ƒ๋ฐ”์šด๋“œ์— ๊ทœ์น™์— ์˜ํ•ด์„œ ์ฐจ๋‹จ ๋œ๋‹ค

      Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/Untitled%2012.png

2.2.4) NACL1 Network ACL ๊ทœ์น™ ํŽธ์ง‘ 2 - Stateless ์ด๋ฏ€๋กœ ๋ฆฌํ„ด ํŠธ๋ž˜ํ”ฝ(Return)์— ๋Œ€ํ•œ ํ—ˆ์šฉ ์ถ”๊ฐ€

  • NACL Name: NACL1 ์„ ํƒ ํ›„ Outbound Rule (์•„์›ƒ๋ฐ”์šด๋“œ ๊ทœ์น™) ํŽธ์ง‘

    • ๊ทœ์น™(110), ์œ ํ˜•(์‚ฌ์šฉ์ž์ง€์ •TCP๊ทœ์น™) - ํ”„๋กœํ† ์ฝœ(TCP), ํฌํŠธ๋ฒ”์œ„(32768-65535), ๋Œ€์ƒ(0.0.0.0/0), ํ—ˆ์šฉ/๊ฑฐ๋ถ€(ALLOW)
      • ํฌํŠธ๋ฒ”์œ„๋Š” ๋Œ์•„๊ฐ€๋Š” ํŠธ๋ž˜ํ”ฝ์˜ ๋ชฉ์ ์ง€ ํฌํŠธ ๋ฒ”์œ„์ด๋‹ค โ†’ ๋งฅ ์œˆ๋„์šฐ ๋ฆฌ๋ˆ…์Šค์˜ ๋ชจ๋“  ์ž„์‹œ ํฌํŠธ ๋ฒ”์œ„๋ฅผ ํฌํ•จํ•œ ๋ฒ”์œ„
        • ์™ธ๋ถ€์—์„œ SSH ๋กœ ์ ‘์† ์‹œ ํด๋ผ์ด์–ธํŠธ์˜ ์†Œ์Šค ํฌํŠธ๋Š” ์ž„์‹œ ํฌํŠธ(Ephemeral port ์ž ์‹œ์‚ด์•„์žˆ๋Š” ํฌํŠธ) ์ด๋‹ค
          • ํด๋ผ์ด์–ธํŠธ์—์„œ ์‚ฌ์šฉ๋˜๋Š” ์ž„์‹œ ํฌํŠธ๋Š” OS๋ณ„ ๋ฒ”์œ„๊ฐ€ ๋‹ค๋ฅด๋‹ค
          • ์ผ๋ฐ˜์ ์œผ๋กœ IANA๊ถŒ๊ณ  ๋ฐ ๋งฅ๊ณผ ์œˆ๋„์šฐ(4915265535), Linux(3276861000)
      • ๋Œ€์ƒ๋Š” ๋Œ์•„๊ฐ€๋Š” ํŠธ๋ž˜ํ”ฝ์˜ ๋ชฉ์ ์ง€IP ๋ฒ”์œ„์ด๋‹ค
        • ์ดํ›„ ์ €์žฅ ์‹œ ์ตœํ•˜๋‹จ์— ๋ชจ๋“  ํŠธ๋ž˜ํ”ฝ์„ ๊ฑฐ๋ถ€ DENY Rule ์ด ์กด์žฌํ•œ๋‹ค
  • ์•„์›ƒ๋ฐ”์šด๋“œ ๊ทœ์น™์— ์•„๋ž˜์™€ ๊ฐ™์ด ์„ค์ •์ด ๋œ๋‹ค

    Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/_2020-05-13__4.34.44.png

  • ์™ธ๋ถ€์—์„œ ๋‚ด๋ถ€์˜ EC2 2๋Œ€ ๋ชจ๋‘๋กœ SSH ์ ‘์† ํ™•์ธ

    • ์™ธ๋ถ€์—์„œ EC2 SSH ์ ‘์†์ด ๊ฐ€๋Šฅํ•˜๋‹ค โ†’ HomePC์˜ ์†Œ์ŠคํฌํŠธ๋ฅผ ๋ณด๋ฉด ์ž„์‹œํฌํŠธ ์ค‘ ๋žœ๋คํ•˜๊ฒŒ ํ• ๋‹นํ•ด์„œ ์ ‘์†ํ•œ ๊ฒƒ์„ ์•Œ ์ˆ˜ ์žˆ๋‹ค

      1
      2
      3
      4
      5
      6
      7
      HomePC$ ssh root@13.125.132.54
      [root@SGLAB2-EC2-1 ~]# netstat -anp |grep 220.117
      tcp 0 0 10.41.1.100:22 220.117.X.X:55260 ESTABLISHED 3775/sshd: root@pts

      HomePC$ ssh root@52.78.166.174
      [root@SGLAB2-EC2-2 ~]# netstat -anp |grep 220.117
      tcp 0 0 10.41.1.200:22 220.117.X.X:52255 ESTABLISHED 3815/sshd: root@pts
  • ํŠธ๋ž˜ํ”ฝ ํ๋ฆ„์— ๋”ฐ๋ฅธ ์„ค๋ช…

    • (1) ์™ธ๋ถ€(HomePC)์—์„œ EC2์˜ PublicIP(13.125.132.54)๋กœ SSH ์ ‘์†์„ ์‹œ๋„ํ•œ๋‹ค. HomePC ์ž์‹ ์˜ ์†Œ์ŠคํฌํŠธ๋Š” ์ž„์‹œํฌํŠธ ๋ฒ”์œ„ ์ค‘ ๋žœ๋ค ์„ ํƒํ•œ๋‹ค

    • (2) NAT ๊ธฐ๋Šฅ์— ์˜ํ•ด์„œ ๋ชฉ์ ์ง€ PublicIP(13.125.132.54) ๋ฅผ PrivateIP(10.40.1.100)์œผ๋กœ ๋ณ€๊ฒฝํ•œ๋‹ค

    • (3) Network ACL์— ์˜ํ•ด์„œ ์ถœ๋ฐœ์ง€IP๊ฐ€ 0.0.0.0/0 ์ด๊ณ  ๋ชฉ์ ์ง€ ํฌํŠธ SSH 22 ์ด๋ฏ€๋กœ ํ—ˆ์šฉ(ALLOW) ๋œ๋‹ค

    • (4) EC2 ๋‚ด๋ถ€์˜ SSH ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ์ฒ˜๋ฆฌ ํ•œ๋‹ค

    • (5) ๋ฆฌํ„ด ํŠธ๋ž˜ํ”ฝ์ด๋ฏ€๋กœ ์ถœ๋ฐœ์ง€์™€ ๋ชฉ์ ์ง€์˜ IP์™€ Port ๊ฐ€ ๋’ค๋ฐ”๋€Œ์–ด ์ „๋‹ฌ๋œ๋‹ค

    • (6) ๋ฆฌํ„ด ํŠธ๋ž˜ํ”ฝ์ด Network ACL ์•„์›ƒ๋ฐ”์šด๋“œ์— ๊ทœ์น™์— ํ—ˆ์šฉ๋˜์–ด ํ†ต๊ณผํ•œ๋‹ค โ†’ ๋ชฉ์ ์ง€ ํฌํŠธ 55260 ์ด 32768~65535 ๋ฒ”์œ„์— ์†ํ•จ

    • (7) ์†Œ์ŠคIP๊ฐ€ PublicIP๋กœ NAT(๋ณ€๊ฒฝ)๋˜์–ด HomePC๋กœ ๋„์ฐฉํ•˜์—ฌ ์ฒ˜๋ฆฌ๊ฐ€ ๋œ๋‹ค

      Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/Untitled%2013.png

๐Ÿ’ก ์œ„ ์ƒํ™ฉ์—์„œ๋„ EC2 ๊ฐ„์—๋Š” ๋ชจ๋“  ํŠธ๋ž˜ํ”ฝ ํ†ต์‹ ์ด ๊ฐ€๋Šฅํ•˜๋‹ค. ํ˜„์žฌ ๋ณด์•ˆ๊ทธ๋ฃน(Security group)๋Š” โ€˜All Traffic ํ—ˆ์šฉโ€™ ์ƒํƒœ์ด๊ณ  Network ACL์€ 10.41.0.0/24(Subnet)์—์„œ ๋‹ค๋ฅธ ๋Œ€์—ญ๊ณผ ํ†ต์‹  ์‹œ์—๋งŒ ์ ์šฉ์ด ๋˜๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค. ์˜ˆ) [root@SGLAB2-EC2-1 ~]# ping 10.41.1.200 โ†’ ping ok

2.2.5) NACL1 Network ACL ๊ทœ์น™ ํŽธ์ง‘ 3

  • ๋ชฉ์  : ์™ธ๋ถ€์—์„œ EC2๋Œ€์—ญ์— ๋Œ€ํ•œ HTTP ์ ‘์†์„ ํ—ˆ์šฉ

    • ํ˜„์žฌ๋Š” ์™ธ๋ถ€(HomePC) ์—์„œ EC2(์›น์„œ๋ฒ„)๋กœ HTTP ์ ‘์†์ด ์ฐจ๋‹จ๋จ

      1
      2
      3
      4
      5
      HomePC$ curl 13.209.84.198
      curl: (7) Failed to connect to 13.209.84.198 port 80: Operation timed out

      HomePC$ curl 52.79.50.197
      curl: (7) Failed to connect to 52.79.50.197 port 80: Operation timed out
  • NACL Name: NACL1 ์„ ํƒ ํ›„ Inbound Rule (์ธ๋ฐ”์šด๋“œ ๊ทœ์น™) ํŽธ์ง‘

    • ๊ทœ์น™(20), ์œ ํ˜•(HTTP) - ํ”„๋กœํ† ์ฝœ(TCP), ํฌํŠธ๋ฒ”์œ„(80), ์†Œ์Šค(0.0.0.0/0), ํ—ˆ์šฉ/๊ฑฐ๋ถ€(ALLOW)

      • ์ดํ›„ ์ €์žฅ ์‹œ ์ตœํ•˜๋‹จ์— ๋ชจ๋“  ํŠธ๋ž˜ํ”ฝ์„ ๊ฑฐ๋ถ€ DENY Rule ์ด ์กด์žฌํ•œ๋‹ค

      Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/_2020-05-13__4.58.19.png

  • NACL Name: NACL1 ์„ ํƒ ํ›„ Outbound Rule (์•„์›ƒ๋ฐ”์šด๋“œ ๊ทœ์น™)

    • ์ด๋ฏธ ์œ„์—์„œ ์ž„์‹œํฌํŠธ์— ๋Œ€ํ•œ ํ—ˆ์šฉ์ด ์žˆ์œผ๋ฏ€๋กœ ์ถ”๊ฐ€ ์„ค์ • ํ•„์š” ์—†์Œ
  • ํ™•์ธ

    • ์™ธ๋ถ€์—์„œ EC2 HTTP ์ ‘์†์ด ๊ฐ€๋Šฅํ•˜๋‹ค

      1
      2
      3
      4
      5
      HomePC$ curl 13.209.84.198
      <html><h1>Hello from Network ACL Test Web Server 1 - IP 10.41.1.100</h1></html>

      HomePC$ curl 52.79.50.197
      <html><h1>Hello from Network ACL Test Web Server 2 - IP 10.41.1.200</h1></html>
    • ํ•˜์ง€๋งŒ ์•„์ง๋„ ๋‚ด๋ถ€์ธ EC2์—์„œ ์™ธ๋ถ€๋กœ ์ธํ„ฐ๋„ท๋„ ์ฐจ๋‹จ๋จ

      • ec2$ curl www.google.com

2.2.6) NACL1 Network ACL ๊ทœ์น™ ํŽธ์ง‘ 4

  • ๋ชฉ์  : ๋‚ด๋ถ€ EC2 ์—์„œ ์™ธ๋ถ€๋กœ ์ธํ„ฐ๋„ท ์ ‘์† ๋ฐ ๋‹ค์šด๋กœ๋“œ ๊ฐ€๋Šฅ (ํŒจ์น˜ ์ž‘์—… ๋“ฑ ํ•„์š”)

    • ํ˜„์žฌ๋Š” ๋‚ด๋ถ€์ธ EC2์—์„œ ์™ธ๋ถ€๋กœ ์ธํ„ฐ๋„ท ์ ‘์†์ด ์ฐจ๋‹จ๋จ

      1
      2
      3
      4
      5
      [root@SGLAB2-EC2-1 ~]# curl ifconfig.me
      curl: (7) Failed to connect to ifconfig.me port 80: Connection timed out

      [root@SGLAB2-EC2-2 ~]# curl ifconfig.me
      curl: (7) Failed to connect to ifconfig.me port 80: Connection timed out
  • NACL Name: NACL1 ์„ ํƒ ํ›„ Outbound Rule (์ธ๋ฐ”์šด๋“œ ๊ทœ์น™) ํŽธ์ง‘

    • ๊ทœ์น™(120), ์œ ํ˜•(HTTP) - ํ”„๋กœํ† ์ฝœ(TCP), ํฌํŠธ๋ฒ”์œ„(80), ์†Œ์Šค(0.0.0.0/0), ํ—ˆ์šฉ/๊ฑฐ๋ถ€(ALLOW)

    • ๊ทœ์น™(130), ์œ ํ˜•(HTTPS) - ํ”„๋กœํ† ์ฝœ(TCP), ํฌํŠธ๋ฒ”์œ„(443), ์†Œ์Šค(0.0.0.0/0), ํ—ˆ์šฉ/๊ฑฐ๋ถ€(ALLOW)

      • EC2 ์ž…์žฅ์—์„œ ์ž์‹ ์ด ํด๋ผ์ด์–ธํŠธ๊ฐ€ ๋˜์–ด์„œ ์™ธ๋ถ€์— ์ธํ„ฐ๋„ท ์›น์„œ๋ฒ„์— ์ ‘์†์„ ์‹œ๋„ ์‹œ์— ๋Œ€ํ•œ ํ—ˆ์šฉ

      • ์ดํ›„ ์ €์žฅ ์‹œ ์ตœํ•˜๋‹จ์— ๋ชจ๋“  ํŠธ๋ž˜ํ”ฝ์„ ๊ฑฐ๋ถ€ DENY Rule ์ด ์กด์žฌํ•œ๋‹ค

        Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/_2020-05-13__5.15.14.png

  • NACL Name: NACL1 ์„ ํƒ ํ›„ Inbound Rule (์ธ๋ฐ”์šด๋“œ ๊ทœ์น™) ํŽธ์ง‘

    • ๊ทœ์น™(30), ์œ ํ˜•(์‚ฌ์šฉ์ž์ง€์ •TCP๊ทœ์น™) - ํ”„๋กœํ† ์ฝœ(TCP), ํฌํŠธ๋ฒ”์œ„(32768-61000), ์†Œ์Šค(0.0.0.0/0), ํ—ˆ์šฉ/๊ฑฐ๋ถ€(ALLOW)

      • ๋ฆฌํ„ดํŠธ๋ž˜ํ”ฝ์„ ์ธ๋ฐ”์šด๋“œ๊ทœ์น™์— ํ—ˆ์šฉ๋˜๊ฒŒ Amazon Linux ์‚ฌ์šฉํ•˜๋Š” ์ž„์‹œ ํฌํŠธ(Ephemeral port) ๋ฒ”์œ„๋ฅผ ์ง€์ •ํ•œ๋‹ค

        1
        2
        [root@SGLAB2-EC2-1 ~]# cat /proc/sys/net/ipv4/ip_local_port_range
        32768 60999
      • ์ดํ›„ ์ €์žฅ ์‹œ ์ตœํ•˜๋‹จ์— ๋ชจ๋“  ํŠธ๋ž˜ํ”ฝ์„ ๊ฑฐ๋ถ€ DENY Rule ์ด ์กด์žฌํ•œ๋‹ค

        Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/_2020-05-13__5.16.25.png

  • ํ™•์ธ

    • ๋‚ด๋ถ€ EC2 ์—์„œ ์™ธ๋ถ€๋กœ HTTP ์ ‘์†์ด ๊ฐ€๋Šฅํ•˜๋‹ค

      1
      2
      3
      4
      5
      6
      7
      8
      9
      [root@SGLAB2-EC2-1 ~]# curl ifconfig.me
      13.209.84.198
      [root@SGLAB2-EC2-1 ~]# curl https://checkip.amazonaws.com/
      13.209.84.198

      [root@SGLAB2-EC2-2 ~]# curl ifconfig.me
      52.79.50.197
      [root@SGLAB2-EC2-2 ~]# curl https://checkip.amazonaws.com/
      52.79.50.197
  • ์ตœ์ข… Network ACL ๊ทœ์น™ ํ™•์ธ

    Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/_2020-05-13__5.19.59.png

    ์ธ๋ฐ”์šด๋“œ ๊ทœ์น™

    Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/_2020-05-13__5.20.42.png

    ์•„์›ƒ๋ฐ”์šด๋“œ ๊ทœ์น™


2.3 ์ƒ์„ฑํ•œ ์ž์› ์‚ญ์ œ

  • ์‹ ๊ทœ ์ƒ์„ฑํ•œ NACL1 Network ACL ์„ ์‚ญ์ œํ•œ๋‹ค
  • ์„œ์šธ Region์—์„œ CloudFormation ์Šคํƒ์„ ์‚ญ์ œํ•œ๋‹ค


3. Security Group ID ๋ฅผ ํ™œ์šฉํ•œ ๋ณด์•ˆ ๊ทœ์น™

3.1 Security Group ID ๋ฅผ ํ™œ์šฉํ•œ ๋ณด์•ˆ ๊ทœ์น™ ์†Œ๊ฐœ

  • ๋ณด์•ˆ๊ทธ๋ฃน ์ธ๋ฐ”์šด๋“œ ๊ทœ์น™์˜ ์†Œ์Šค์™€ ์•„์›ƒ๋ฐ”์šด๋“œ ๊ทœ์น™์˜ ๋Œ€์ƒ์— IP ๋Œ€์‹  ๋ณด์•ˆ๊ทธ๋ฃนID(=Security Group ID)๋ฅผ ์‚ฌ์šฉ ํ•  ์ˆ˜ ์žˆ๋‹ค

  • ํ†ต์ œํ•˜๋ ค๋Š” IP ๋Œ€์ƒ์ด ์œ ๋™์ ์ผ ๊ฒฝ์šฐ์— ํ™œ์šฉ ํ•  ์ˆ˜ ์žˆ๋‹ค. ์˜ˆ) EC2 ์˜คํ† ์Šค์ผ€์ผ ํ™˜๊ฒฝ

    • (์˜คํ†  ์Šค์ผ€์ผ ๊ทธ๋ฃน : ์›น์„œ๋ฒ„1-10.1.1.1 ์›น์„œ๋ฒ„2-10.1.1.2 ์›น์„œ๋ฒ„3-10.1.1.3 โ€ฆ) โ‡’ DB์„œ๋ฒ„ 10.2.1.11
    • ๊ธฐ์กด์— DB์„œ๋ฒ„์˜ ์ธ๋ฐ”์šด๋“œ ๊ทœ์น™์— 10.1.1.1~3 ํ˜„์žฌ 3๊ฐœ์˜ IP๋งŒ ์ ‘์†์ด ๋˜๊ฒŒ ์„ค์ •๋˜์–ด ์žˆ๋‹ค
    • ํ•˜์ง€๋งŒ ์‚ฌ์šฉ์ž ํŠธ๋ž˜ํ”ฝ์˜ ์ฆ๊ฐ€์— ๋”ฐ๋ผ์„œ ์›น์„œ๋ฒ„4(10.1.1.4)๊ฐ€ ์‹ ๊ทœ ๋ฐฐ์น˜๊ฐ€ ๋˜๋ฉด DB์„œ๋ฒ„ ์ธ๋ฐ”์šด๋“œ ๊ทœ์น™์— 10.1.1.4/32 ๋ฅผ ์ถ”๊ฐ€ํ•ด์ค˜์•ผ ํ•œ๋‹ค
    • ์œ„ ์™€ ๊ฐ™์ด IP๋Œ€์ƒ์ด ์œ ๋™์ ์ผ ๊ฒฝ์šฐ์—๋Š” DB์„œ๋ฒ„์˜ ์ธ๋ฐ”์šด๋“œ ๊ทœ์น™์— IP List ๋Œ€์‹  ์›น์„œ๋ฒ„๊ฐ€ ์‚ฌ์šฉํ•˜๋Š” Security Group ID๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋œ๋‹ค.
    • ์ฆ‰, DB์„œ๋ฒ„์˜ ๊ฒฝ์šฐ ์ธ์ž…๋˜๋Š” ์†Œ์ŠคIP๋ฅผ ์›น์„œ๋ฒ„์— ์—ฐ๊ฒฐ๋œ Security Group ID๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๋ชจ๋“  ์›น์„œ๋ฒ„๋ฅผ ํ—ˆ์šฉํ•ด์ฃผ๊ฒŒ ๋œ๋‹ค.
    • ๊ทธ๋Ÿผ ์‹ ๊ทœ ์›น์„œ๋ฒ„4๋ฒˆ์ด ์ƒ์„ฑ๋˜๋”๋ผ๋„ ๊ธฐ์กด ์›น์„œ๋ฒ„์™€ ๋™์ผํ•œ Security Group ID ๋ฅผ ์‚ฌ์šฉํ•˜๋‹ˆ DB์„œ๋ฒ„ ์ž…์žฅ์—์„œ ํ—ˆ์šฉํ•˜๊ฒŒ ๋œ๋‹ค.
  • ์•„๋ž˜๋Š” DB์„œ๋ฒ„์— ์ธ๋ฐ”์šด๋“œ ๊ทœ์น™์— ์†Œ์Šค๋ฅผ IP๊ธฐ๋ฐ˜์œผ๋กœ ์„ค์ • ์‹œ

Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/Untitled%2014.png

Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/Untitled%2015.png

  • ์•„๋ž˜๋Š” DB์„œ๋ฒ„์— ์ธ๋ฐ”์šด๋“œ ๊ทœ์น™์— ์†Œ์Šค๋ฅผ Security Group ๊ธฐ๋ฐ˜์œผ๋กœ ์„ค์ • ์‹œ

Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/Untitled%2016.png

Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/Untitled%2017.png


3.2 ์‹ค์Šต์„ ์œ„ํ•œ ๊ตฌ์„ฑ - ์›น๊ณผ DB๊ฐ„ ๋ณด์•ˆ ์„ค์ • ์˜ˆ์‹œ

3.2.1) Lab Topology

  • ์„œ์šธ Region ์— ์‹ ๊ทœ VPC์— ์‹ ๊ทœ EC2 Instances (์›น ์„œ๋ฒ„ 2๋Œ€, DB 1๋Œ€) ๊ฐ€ ๋ฐฐ์น˜๋˜์–ด ์žˆ๊ณ  ๊ฐ์ž ์ž์‹ ์˜ ์ง‘PC(HomePC)์—์„œ EC2(์›น ์„œ๋ฒ„)๋ฅผ ์ ‘์†ํ•œ๋‹ค.

    Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/Untitled%2018.png

3.2.2) ๊ตฌ์„ฑ์„ ์œ„ํ•œ ๊ธฐ๋ณธ ์„ค์ •

  • ๋ณธ ์‹ค์Šต์—์„œ ํ™œ์šฉํ•  AWS Region์€ ์„œ์šธ ์ž…๋‹ˆ๋‹ค. ํ•ด๋‹น Region์— ๋Œ€ํ•œ EC2-Key Pair๋ฅผ ์ƒ์„ฑ
  • ์„œ์šธ Region ์— ๋ฆฌ์†Œ์Šค๋Š” CloudFormation์— ์˜ํ•ด ์ธํ”„๋ผ๋ฅผ ์ž๋™ ๊ตฌ์ถ• (3.2.3ํ•ญ์—์„œ ์ง„ํ–‰)

3.2.3) CloudFormation

์„œ์šธ Region์—์„œ CloudFormation ์Šคํƒ์„ ์ƒ์„ฑํ•œ๋‹ค.
  • 1๋‹จ๊ณ„ ํ…œํ”Œ๋ฆฟ ์ง€์ •
    • ํ…œํ”Œ๋ฆฟ ์ค€๋น„ : ์ค€๋น„๋œ ํ…œํ”Œ๋ฆฟ
    • ํ…œํ”Œ๋ฆฟ ์†Œ์Šค : Amazon S3 URL
    • Amazon S3 URL : https://s3.ap-northeast-2.amazonaws.com/cloudformation.cloudneta.net/NetworkSecurity/Network-SGID.yaml
      • ์šฐ์ธก ํ•˜๋‹จ ๋‹ค์Œ ํด๋ฆญ
  • 2๋‹จ๊ณ„ ์Šคํƒ ์„ธ๋ถ€ ์ •๋ณด ์ง€์ •
    • ์Šคํƒ ์ด๋ฆ„ : SGID
    • KeyName : ์ž์‹ ์˜ EC2-Key Pair ๋ฅผ ์ง€์ •
  • 3๋‹จ๊ณ„ ์Šคํƒ ์˜ต์…˜ ๊ตฌ์„ฑ
    • ์šฐ์ธก ํ•˜๋‹จ ๋‹ค์Œ ํด๋ฆญ
  • 4๋‹จ๊ณ„ ๊ฒ€ํ† 
    • ์šฐ์ธก ํ•˜๋‹จ ์Šคํƒ ์ƒ์„ฑ ํด๋ฆญ
์„œ์šธ CloudFormation ์ƒ์„ฑ ์ธํ”„๋ผ
- VPC, 1 Subnet, 1 IGW, 1 Route table
- Amazon Linux 2 EC2 Instance 3๋Œ€ (Public IP, User data ์‚ฌ์šฉ - ์›น์„œ๋ฒ„2๋Œ€, DB์„œ๋ฒ„1๋Œ€

3.2.4) ๊ฒ€์ฆ

  • ์‚ฌ์šฉ์ž PC์—์„œ ์„œ์šธ EC2(3๋Œ€) Instances Public IP ์ฃผ์†Œ๋กœ SSH ์ ‘๊ทผํ•œ๋‹ค. ์ ‘์† ๊ณ„์ • root / qwe123

    1
    2
    $ ssh root@13.209.10.34
    root@13.209.10.34's password: qwe123
  • Web1 ๊ณผ Web2 EC2์—์„œ DB EC2(10.42.1.200) ๋กœ mysql ์ ‘์†. DB ์ ‘์† ๊ณ„์ • gasida / qwe123

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    [root@WEB1 ~]# mysql -h 10.42.1.200 -P 3306 -ugasida -pqwe123
    Welcome to the MariaDB monitor. Commands end with ; or \g.
    ..
    MariaDB [(none)]> SHOW DATABASES;
    +--------------------+
    | Database |
    +--------------------+
    | information_schema |
    | mysql |
    | performance_schema |
    | sample |
    +--------------------+
    4 rows in set (0.00 sec)
  • Web1 ๊ณผ Web2 ์˜ PublicIP ๋กœ ์›น ์ ‘์† ์‹œ index.php ํŽ˜์ด์ง€์—์„œ mysql DB๋กœ ์—ฐ๊ฒฐ๋œ ํ™”๋ฉด ์ถœ๋ ฅ ํ™•์ธ โ†’ ์ฐธ๊ณ  ๋งํฌ

    • Web - DB ๊ฐ„ ์—ฐ๊ฒฐ์ด ์ •์ƒ์ผ ๊ฒฝ์šฐ ์•„๋ž˜์™€ ๊ฐ™์€ ํ™”๋ฉด์ด ์ถœ๋ ฅ๋œ๋‹ค

      Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/Untitled%2019.png

    • Name ๊ณผ ADDRESS ์— ๊ฐ’์„ ์ถ”๊ฐ€ ํ›„ ์™ผ์ชฝ์— Add Data ํด๋ฆญ ์‹œ ์‹ค์ œ DB์— table ์— ๋ฐ˜์˜๋œ๋‹ค

      Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/_2020-05-14__3.46.59.png

    • DB ํ…Œ์ด๋ธ” ํ™•์ธ

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      23
      24
      25
      26
      27
      28
      29
      30
      31
      32
      [root@WEB1 ~]# mysql -h 10.42.1.200 -P 3306 -ugasida -pqwe123
      Welcome to the MariaDB monitor. Commands end with ; or \g.
      ..
      MariaDB [(none)]> SHOW DATABASES;
      +--------------------+
      | Database |
      +--------------------+
      | information_schema |
      | mysql |
      | performance_schema |
      | sample |
      +--------------------+
      4 rows in set (0.00 sec)

      MariaDB [(none)]> USE sample;

      MariaDB [sample]> SHOW tables;
      +------------------+
      | Tables_in_sample |
      +------------------+
      | EMPLOYEES |
      +------------------+
      1 row in set (0.00 sec)

      MariaDB [sample]> SELECT * FROM EMPLOYEES;
      +----+--------+------------------+
      | ID | NAME | ADDRESS |
      +----+--------+------------------+
      | 1 | gasida | samsung-dong 123 |
      | 2 | ongja | suwon 111 |
      +----+--------+------------------+
      2 rows in set (0.00 sec)

3.2.5) ์‹ค์Šต ์ „ ์‚ฌ์ „ ์„ค์ •

  • ํ˜„์žฌ ์ ์šฉ๋œ ๋ณด์•ˆ ๊ทธ๋ฃน ๊ณผ Network ACL ์„ ํ™•์ธํ•œ๋‹ค

3.3 Security Group ID ๋ฅผ ํ™œ์šฉํ•œ ๋ณด์•ˆ ๊ทœ์น™ ์„ค์ • - ์›น๊ณผ DB๊ฐ„ ๋ณด์•ˆ ์„ค์ • ์˜ˆ์‹œ

3.3.1) ๋ณด์•ˆ ์š”๊ตฌ ์กฐ๊ฑด

  • ์™ธ๋ถ€ โ†’ ์›น์„œ๋ฒ„
    • ์™ธ๋ถ€์˜ ์ธํ„ฐ๋„ท ์‚ฌ์šฉ์ž๋Š” ์›น๋ธŒ๋ผ์šฐ์ €๋กœ ์›น์„œ๋ฒ„๋กœ ์ ‘์†์ด ๊ฐ€๋Šฅํ•ด์•ผํ•จ - TCP 80(HTTP)
    • ์™ธ๋ถ€์— ์žˆ๋Š” ๊ด€๋ฆฌ์ž๋Š” ์›น์„œ๋ฒ„ ๊ด€๋ฆฌ๋ฅผ ์œ„ํ•ด์„œ SSH๋กœ ์ ‘์†์ด ๊ฐ€๋Šฅํ•ด์•ผํ•จ - TCP 22(SSH)
  • ์›น์„œ๋ฒ„ โ†’ ์™ธ๋ถ€
    • ์›น์„œ๋ฒ„๋Š” ๋ณด์•ˆ ํŒจ์น˜ ๋“ฑ ํ•„์š”๋กœ ์ธํ•ด ์™ธ๋ถ€์—์„œ ์—…๋ฐ์ดํŠธ ๋ฐ ๋‹ค์šด๋กœ๋“œ๊ฐ€ ๊ฐ€๋Šฅํ•ด์•ผํ•จ - TCP 80(HTTP) 443(HTTPS)
  • ์›น์„œ๋ฒ„ โ†’ DB์„œ๋ฒ„
    • ์›น์„œ๋ฒ„๋“ค๋งŒ DB์„œ๋ฒ„์— mysql ์ ‘์†์ด ๊ฐ€๋Šฅํ•ด์•ผํ•จ - TCP 3306(MYSQL) โ‡’ Security Group ID ๋ฅผ ํ™œ์šฉํ•  ์˜ˆ์ •
  • DB์„œ๋ฒ„ โ†’ ์™ธ๋ถ€
    • DB์„œ๋ฒ„๋Š” ๋ณด์•ˆ ํŒจ์น˜ ๋“ฑ ํ•„์š”๋กœ ์ธํ•ด ์™ธ๋ถ€์—์„œ ์—…๋ฐ์ดํŠธ ๋ฐ ๋‹ค์šด๋กœ๋“œ๊ฐ€ ๊ฐ€๋Šฅํ•ด์•ผํ•จ - TCP 80(HTTP) 443(HTTPS)
  • ์™ธ๋ถ€ โ†’ DB์„œ๋ฒ„
    • ์ผ๋ฐ˜์ ์ธ ํ™˜๊ฒฝ์—์„œ๋Š” DB์„œ๋ฒ„์— ์™ธ๋ถ€์—์„œ ์ง์ ‘ ์ ‘์†์„ ํ•˜์ง€ ์•Š๋Š”๋‹ค. ๋‹ค๋งŒ ์‹ค์Šต์˜ ํŽธ์˜๋ฅผ ์œ„ํ•ด์„œ ์™ธ๋ถ€์—์„œ SSH์ ‘์†์„ ํ—ˆ์šฉํ•จ

3.3.2) โ€˜์™ธ๋ถ€ โ†’ ์›น์„œ๋ฒ„โ€™ ๋ณด์•ˆ ์š”๊ตฌ ์กฐ๊ฑด ๊ด€๋ จ ๋ณด์•ˆ๊ทธ๋ฃน ์„ค์ • ๋ฐ ํ™•์ธ

  • ์ด๋ฏธ Cloudformation ๋ฐฐํฌ ์‹œ ์›น์„œ๋ฒ„์— ์ธ๋ฐ”์šด๋“œ ๋ณด์•ˆ๊ทœ์น™์— HTTP, SSH ์— ๋Œ€ํ•œ ์ ‘์†์ด ๊ฐ€๋Šฅํ•˜๊ฒŒ ์„ค์ •๋˜์–ด ์žˆ๋‹ค

  • ํŠธ๋ž˜ํ”ฝ ํ๋ฆ„์— ๋”ฐ๋ฅธ ์„ค๋ช…

    • (1) ์™ธ๋ถ€(HomePC)์—์„œ EC2์˜ PublicIP๋กœ HTTP ํ˜น์€ SSH ์ ‘์†์„ ์‹œ๋„ํ•œ๋‹ค. HomePC ์ž์‹ ์˜ ์†Œ์ŠคํฌํŠธ๋Š” ์ž„์‹œํฌํŠธ ๋ฒ”์œ„ ์ค‘ ๋žœ๋ค ์„ ํƒํ•œ๋‹ค. NAT ๊ธฐ๋Šฅ์— ์˜ํ•ด์„œ ๋ชฉ์ ์ง€ IP๋Š” PublicIP ๋ฅผ PrivateIP(10.42.1.100 ํ˜น์€ 10.42.1.101)๋กœ ๋ณ€๊ฒฝ๋œ๋‹ค. Web ๋ณด์•ˆ๊ทธ๋ฃน ์ธ๋ฐ”์šด๋“œ ๊ทœ์น™์— ํ—ˆ์šฉ๋˜์–ด EC2 ๋‚ด๋ถ€์—์„œ ์ฒ˜๋ฆฌํ•œ๋‹ค

    • (2) ๋ฆฌํ„ด ํŠธ๋ž˜ํ”ฝ์€ ์ถœ๋ฐœ์ง€์™€ ๋ชฉ์ ์ง€์˜ IP์™€ Port ๊ฐ€ ๋’ค๋ฐ”๋€Œ์–ด ์ „๋‹ฌ๋œ๋‹ค. ๋ณด์•ˆ๊ทธ๋ฃน์œผ๋กœ ๋ฆฌํ„ด ํŠธ๋ž˜ํ”ฝ์€ ์ž๋™์œผ๋กœ ํ—ˆ์šฉ๋˜์–ด ์‚ฌ์šฉ์ž์—๊ฒŒ ๋„๋‹ฌํ•œ๋‹ค

      Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/Untitled%2020.png

3.3.3) โ€˜์›น์„œ๋ฒ„ โ†’ ์™ธ๋ถ€โ€™ ๋ณด์•ˆ ์š”๊ตฌ ์กฐ๊ฑด ๊ด€๋ จ ๋ณด์•ˆ๊ทธ๋ฃน ์„ค์ • ๋ฐ ํ™•์ธ

  • ๋ณด์•ˆ ์š”๊ตฌ ์กฐ๊ฑด : ์›น์„œ๋ฒ„๋Š” ๋ณด์•ˆ ํŒจ์น˜ ๋“ฑ ํ•„์š”๋กœ ์ธํ•ด ์™ธ๋ถ€์—์„œ ์—…๋ฐ์ดํŠธ ๋ฐ ๋‹ค์šด๋กœ๋“œ๊ฐ€ ๊ฐ€๋Šฅํ•ด์•ผํ•จ - TCP 80(HTTP) 443(HTTPS)

  • Web ๋ณด์•ˆ๊ทธ๋ฃน ์•„์›ƒ๋ฐ”์šด๋“œ ๊ทœ์น™ ๋ณ€๊ฒฝ โ†’ TCP 80(HTTP) 443(HTTPS) ์ œ์™ธํ•œ ๋‚˜๋จธ์ง€ ํŠธ๋ž˜ํ”ฝ์€ ์ฐจ๋‹จ

    • ๊ธฐ์กด์˜ โ€˜๋ชจ๋“  ํŠธ๋ž˜ํ”ฝ ํ—ˆ์šฉโ€™ ๊ทœ์น™์€ ์‚ญ์ œํ•œ๋‹ค

    • HTTP ์™€ HTTPS ๋ฅผ ํ—ˆ์šฉํ•˜๋Š” ๊ทœ์น™์„ ์ถ”๊ฐ€ํ•œ๋‹ค

      Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/_2020-05-15__3.58.27.png

  • โ€˜์›น์„œ๋ฒ„ โ†’ ์™ธ๋ถ€โ€™ ๋กœ HTTP or HTTPS ํ†ต์‹  ํ—ˆ์šฉ์„ ํ™•์ธํ•œ๋‹ค

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    # ์•„๋ž˜ ์ฒ˜๋Ÿผ HTTP HTTPS๋Š” ์™ธ๋ถ€ ํ†ต์‹ ์ด ํ—ˆ์šฉ๋œ๋‹ค
    [root@WEB1 ~]# curl -O http://example.com/foo.txt --silent
    [root@WEB1 ~]# curl -O https://example.com/bar.txt --silent
    [root@WEB1 ~]# ls *.txt
    bar.txt foo.txt

    # ์•„๋ž˜ ์ฒ˜๋Ÿผ HTTP HTTPS ์ด์™ธ์— ๋‹ค๋ฅธ ํŠธ๋ž˜ํ”ฝ์€ ์™ธ๋ถ€๋กœ ํ†ต์‹ ์ด ์ฐจ๋‹จ๋œ๋‹ค
    [root@WEB1 ~]# ping -c 1 -W 1 www.google.com
    PING www.google.com (172.217.25.68) 56(84) bytes of data.
    --- www.google.com ping statistics ---
    1 packets transmitted, 0 received, 100% packet loss, time 0ms

    [root@WEB1 ~]# ssh root@10.42.1.101
    ssh: connect to host 10.42.1.101 port 22: Connection timed out
  • ํŠธ๋ž˜ํ”ฝ ํ๋ฆ„์— ๋”ฐ๋ฅธ ์„ค๋ช…

    • (1) ์›น์„œ๋ฒ„(EC2)์—์„œ ์ธํ„ฐ๋„ท(HTTP HTTPS)์— ์ ‘์†์„ ์‹œ๋„ํ•œ๋‹ค. Web๋ณด์•ˆ๊ทธ๋ฃน ์•„์›ƒ๋ฐ”์šด๋“œ ๊ทœ์น™์— ์˜ํ•ด์„œ ํ—ˆ์šฉ๋˜์–ด

    • (2) ๋ฆฌํ„ด ํŠธ๋ž˜ํ”ฝ์€ ์ถœ๋ฐœ์ง€์™€ ๋ชฉ์ ์ง€์˜ IP์™€ Port ๊ฐ€ ๋’ค๋ฐ”๋€Œ์–ด ์ „๋‹ฌ๋œ๋‹ค. ๋ณด์•ˆ๊ทธ๋ฃน์œผ๋กœ ๋ฆฌํ„ด ํŠธ๋ž˜ํ”ฝ์€ ์ž๋™์œผ๋กœ ํ—ˆ์šฉ๋˜์–ด ์‚ฌ์šฉ์ž์—๊ฒŒ ๋„๋‹ฌํ•œ๋‹ค

      Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/Untitled%2021.png

3.3.4) โ€˜์›น์„œ๋ฒ„ โ†’ DB์„œ๋ฒ„โ€™ ๋ณด์•ˆ ์š”๊ตฌ ์กฐ๊ฑด ๊ด€๋ จ ๋ณด์•ˆ๊ทธ๋ฃน ์„ค์ • ๋ฐ ํ™•์ธ

  • ๋ณด์•ˆ ์š”๊ตฌ ์กฐ๊ฑด : ์›น์„œ๋ฒ„๋“ค๋งŒ DB์„œ๋ฒ„์— mysql ์ ‘์†์ด ๊ฐ€๋Šฅํ•ด์•ผํ•จ - TCP 3306(MYSQL) โ‡’ Security Group ID ๋ฅผ ํ™œ์šฉํ•  ์˜ˆ์ •

  • Web ๋ณด์•ˆ๊ทธ๋ฃน ์•„์›ƒ๋ฐ”์šด๋“œ ๊ทœ์น™ ๋ณ€๊ฒฝ โ†’ TCP 3306(MYSQL) ๋Œ€์ƒ(DB์„œ๋ฒ„) ํ—ˆ์šฉ

    • ์œ ํ˜•(MYSQL) , ๋Œ€์ƒ(DB์„œ๋ฒ„์— ์ ์šฉ๋˜์–ด ์žˆ๋Š” ๋ณด์•ˆ๊ทธ๋ฃน ID) ๋ฅผ ์ง€์ •ํ•˜์—ฌ ๊ทœ์น™์„ ์ถ”๊ฐ€ํ•œ๋‹ค

      Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/_2020-05-15__4.32.19.png

  • DB ๋ณด์•ˆ๊ทธ๋ฃน ์ธ๋ฐ”์šด๋“œ ๊ทœ์น™ ๋ณ€๊ฒฝ โ†’ TCP 3306(MYSQL) ์†Œ์Šค(์›น์„œ๋ฒ„) ํ—ˆ์šฉ

    • ์œ ํ˜•(MYSQL), ์†Œ์Šค(์›น์„œ๋ฒ„์— ์ ์šฉ๋˜์–ด ์žˆ๋Š” ๋ณด์•ˆ๊ทธ๋ฃน ID) ๋ฅผ ์ง€์ •ํ•˜์—ฌ ๊ทœ์น™์„ ๋ณ€๊ฒฝํ•œ๋‹ค

      Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/_2020-05-15__4.35.26.png

  • โ€˜์›น์„œ๋ฒ„ โ†’ DB์„œ๋ฒ„โ€™ ๋กœ MYSQL ์ ‘์†์„ ํ™•์ธํ•œ๋‹ค

    1
    2
    3
    4
    5
    6
    7
    [root@WEB1 ~]# mysql -h 10.42.1.200 -P 3306 -ugasida -pqwe123
    Welcome to the MariaDB monitor. Commands end with ; or \g.
    Your MariaDB connection id is 19
    Server version: 5.5.64-MariaDB MariaDB Server
    Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    MariaDB [(none)]>
  • ํŠธ๋ž˜ํ”ฝ ํ๋ฆ„์— ๋”ฐ๋ฅธ ์„ค๋ช…

    • (1) ์›น์„œ๋ฒ„์—์„œ DB์„œ๋ฒ„๋กœ ์ ‘์†์„ ์‹œ๋„ํ•œ๋‹ค. (๋ชฉ์ ์ง€) ๋Œ€์ƒ์ด ๋ณด์•ˆ๊ทธ๋ฃน(DB์„œ๋ฒ„)๋กœ ํ–ฅํ•˜๊ธฐ ๋•Œ๋ฌธ์— ํ—ˆ์šฉ๋œ๋‹ค

    • (2) DB์„œ๋ฒ„๋กœ ์ธ์ž…๋˜๋Š” ํŠธ๋ž˜ํ”ฝ์˜ ์†Œ์Šค๊ฐ€ ๋ณด์•ˆ๊ทธ๋ฃน (์›น์„œ๋ฒ„)๋ฅผ ์‚ฌ์šฉํ•จ์œผ๋กœ ํ—ˆ์šฉ๋œ๋‹ค.

    • (3) DB์„œ๋ฒ„ ๋‚ด๋ถ€์—์„œ ์ฒ˜๋ฆฌ ํ›„ ๋ฆฌํ„ด ํŠธ๋ž˜ํ”ฝ์€ ์•„์›ƒ๋ฐ”์šด๋“œ ๊ทœ์น™๊ณผ ์ƒ๊ด€์—†์ด ๋น ์ ธ๋‚˜๊ฐ„๋‹ค

    • (4) DB์„œ๋ฒ„์—์„œ ๋Œ์•„์˜ค๋Š” ํŠธ๋ž˜ํ”ฝ์€ ์›น์„œ๋ฒ„ ์—ญ์‹œ ๋ฆฌํ„ดํŠธ๋ž˜ํ”ฝ์œผ๋กœ ์ธ๋ฐ”์šด๋“œ ๊ทœ์น™๊ณผ ์„ฑ๊ด€์—†์ด ํ—ˆ์šฉ๋˜์–ด ์ตœ์ข…์ ์œผ๋กœ ์›น์„œ๋ฒ„์— ๋Œ์•„์˜จ๋‹ค

      Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/Untitled%2022.png

3.3.5) โ€˜DB์„œ๋ฒ„ โ†’ ์™ธ๋ถ€โ€™ ๋ณด์•ˆ ์š”๊ตฌ ์กฐ๊ฑด ๊ด€๋ จ ๋ณด์•ˆ๊ทธ๋ฃน ์„ค์ • ๋ฐ ํ™•์ธ โ‡’ 3.3.3) ํ•ญ๋ชฉ๊ณผ ๋™์ผํ•œ ์„ค์ •

  • ๋ณด์•ˆ ์š”๊ตฌ ์กฐ๊ฑด : DB์„œ๋ฒ„๋Š” ๋ณด์•ˆ ํŒจ์น˜ ๋“ฑ ํ•„์š”๋กœ ์ธํ•ด ์™ธ๋ถ€์—์„œ ์—…๋ฐ์ดํŠธ ๋ฐ ๋‹ค์šด๋กœ๋“œ๊ฐ€ ๊ฐ€๋Šฅํ•ด์•ผํ•จ - TCP 80(HTTP) 443(HTTPS)

  • DB ๋ณด์•ˆ๊ทธ๋ฃน ์•„์›ƒ๋ฐ”์šด๋“œ ๊ทœ์น™ ๋ณ€๊ฒฝ โ†’ TCP 80(HTTP) 443(HTTPS) ์ œ์™ธํ•œ ๋‚˜๋จธ์ง€ ํŠธ๋ž˜ํ”ฝ์€ ์ฐจ๋‹จ

    • ๊ธฐ์กด์˜ โ€˜๋ชจ๋“  ํŠธ๋ž˜ํ”ฝ ํ—ˆ์šฉโ€™ ๊ทœ์น™์€ ์‚ญ์ œํ•œ๋‹ค

    • HTTP ์™€ HTTPS ๋ฅผ ํ—ˆ์šฉํ•˜๋Š” ๊ทœ์น™์„ ์ถ”๊ฐ€ํ•œ๋‹ค

      Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/_2020-05-15__4.56.49.png

  • โ€˜DB์„œ๋ฒ„ โ†’ ์™ธ๋ถ€โ€™ ๋กœ HTTP or HTTPS ํ†ต์‹  ํ—ˆ์šฉ์„ ํ™•์ธํ•œ๋‹ค

3.3.6) ์ตœ์ข… ์„ค์ •๋œ ๋ณด์•ˆ๊ทธ๋ฃน ํ™•์ธ

  • ์›น์„œ๋ฒ„ ๋ณด์•ˆ๊ทธ๋ฃน ์ธ๋ฐ”์šด๋“œ ๊ทœ์น™

    Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/Untitled%2023.png

  • ์›น์„œ๋ฒ„ ๋ณด์•ˆ๊ทธ๋ฃน ์•„์›ƒ๋ฐ”์šด๋“œ ๊ทœ์น™

    Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/Untitled%2024.png

  • DB์„œ๋ฒ„ ๋ณด์•ˆ๊ทธ๋ฃน ์ธ๋ฐ”์šด๋“œ ๊ทœ์น™

    Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/Untitled%2025.png

  • DB์„œ๋ฒ„ ๋ณด์•ˆ๊ทธ๋ฃน ์•„์›ƒ๋ฐ”์šด๋“œ ๊ทœ์น™

    Security%20Group%20Network%20ACL%20ea8e94b888d349f1bed19bff39f8cd54/Untitled%2026.png


3.4 ์ƒ์„ฑํ•œ ์ž์› ์‚ญ์ œ

  • ์„œ์šธ Region์—์„œ CloudFormation ์Šคํƒ์„ ์‚ญ์ œํ•œ๋‹ค


4. Network Security Check (Source Destination Check , Uncheck) - ํ–ฅํ›„ ๋‚ด์šฉ ์ถ”๊ฐ€ ์˜ˆ์ •


Welcome to my other publishing channels