3 minute read

Udemy - CKA ๊ฐ•์ขŒ์˜ Linux Network์— ๋Œ€ํ•œ ๋ถ€๋ถ„์„ ๋“ฃ๊ณ , ๊ณต๋ถ€ํ•œ ๋‚ด์šฉ์„ ์ •๋ฆฌํ•œ ํฌ์ŠคํŠธ์ž…๋‹ˆ๋‹ค. CKA ์‹œํ—˜์„ ํ•ฉ๊ฒฉํ•˜๊ณ  ๋˜๋Œ์•„๋ณด๋‹ˆ CKA ์‹œํ—˜์— ์ด ๋ถ€๋ถ„์€ ๋„ˆ๋ฌด ์ง€์—ฝ์ ์ธ ๋ถ€๋ถ„์ด์—ˆ์Šต๋‹ˆ๋‹ค. Linux Network์˜ ip ๋ช…๋ น์–ด๋“ค์˜ ์ข…๋ฅ˜๋งŒ ํ›‘๊ณ  ๋„˜์–ด๊ฐ‘์‹œ๋‹ค!

๋ช…๋ น์–ด ์„ค๋ช…
link ๋„คํŠธ์›Œํฌ ์ธํ„ฐํŽ˜์ด์Šค CRUD
addr ๋„คํŠธ์›Œํฌ IP ์ฃผ์†Œ CRUD
route SKIP
netns SKIP

ip link

ํ˜„์žฌ ์‹œ์Šคํ…œ์˜ ๋„คํŠธ์›Œํฌ ๋””๋ฐ”์ด์Šค๋“ค์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

# `ip link show`์™€ ๋™์ผ
$ ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
...

์‹ค์ œ ๋ช…๋ น์–ด๋กœ๋Š” ๋ชจ๋“  ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ์ง€๋งŒ, ์ด ํฌ์ŠคํŠธ์—์„  1๋ฒˆ ๋””๋ฐ”์ด์Šค์ธ ๋ฃจํ”„๋ฐฑ(lo) ์ธํ„ฐํŽ˜์ด์Šค์˜ ์ •๋ณด๋งŒ ์‚ดํŽด๋ณด์ž.

  • mtu 65536
    • mtu๋Š” Maximum Transmission Unit์˜ ์•ฝ์ž
    • ๋ฃจํ”„๋ฐฑ ์ธํ„ฐํŽ˜์ด์Šค๋กœ ์ตœ๋Œ€ 65536 byte1์˜ ํŒจํ‚ท ๋ณด๋‚ผ ์ˆ˜ ์žˆ๋‹ค. ๋งŒ์•ฝ ์ด ์‚ฌ์ด์ฆˆ๋ฅผ ๋„˜๋Š”๋‹ค๋ฉด, ํŒจํ‚ท์€ ์ž‘์€ ์กฐ๊ฐ์œผ๋กœ ์ชผ๊ฐœ์–ด ์ „์†ก๋  ๊ฒƒ์ด๋‹ค.
  • qdisc nonqueue
    • qdisc๋Š” Queuing Discipline์˜ ์•ฝ์ž
    • ์ธํ„ฐํŽ˜์ด์Šค๊ฐ€ ๋‹ค์Œ ํŒจํ‚ท์„ ์ „์†กํ•˜๋Š” ์ •์ฑ…์„ ๋งํ•œ๋‹ค.
    • noqueue์˜ ์˜๋ฏธ๋Š” ์ธํ„ฐํŽ˜์ด์Šค๊ฐ€ ์•„๋ฌด๋Ÿฐ ํ๋„ ์‚ฌ์šฉํ•˜์ง€ ์•Š์Œ์„ ๋งํ•œ๋‹ค.
  • state UNKNOWN
    • ๋„คํŠธ์›Œํฌ ์ธํ„ฐํŽ˜์ด์Šค์˜ ์ƒํƒœ๋กœ๋Š” UP, DOWN, UNKNOWN์ด ๊ฐ€๋Šฅํ•˜๋‹ค. UP์ด๋ฉด ํ™œ์„ฑํ™”, DOWN์ด๋ฉด ๋น„ํ™œ์„ฑํ™” ์ƒํƒœ๋‹ค.
  • mode DEFAULT
  • group default
  • qlen 1000
    • qlen์€ Transimission Queue Length์˜ ์•ฝ์ž๋‹ค
    • 1000๊ฐœ ํŒจํ‚ท๊นŒ์ง€ ํ์— ์ €์žฅ๋˜๊ณ , 1001๊ฐœ ํŒจํ‚ท๋ถ€ํ„ฐ ๋“œ๋กญ๋œ๋‹ค.
  • link/loopback
    • ๋ฃจํ”„๋ฐฑ ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๋งํ•œ๋‹ค.
  • brd
    • Broadcast๋ฅผ ์˜๋ฏธํ•œ๋‹ค.
    • ์—ฌ๊ธฐ์„œ๋Š” ๋„คํŠธ์›Œํฌ ์ธํ„ฐํŽ˜์ด์Šค ์ด๋ฏ€๋กœ MAC ์ฃผ์†Œ์˜ ์—ฐ๊ฒฐ ์ •๋ณด๊ฐ€ ๋‹ด๊ฒจ์žˆ๋‹ค.

ip addr

$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
...

๋„คํŠธ์›Œํฌ ์ธํ„ฐํŽ˜์ด์Šค ๋ณ„๋กœ ํ• ๋‹น๋œ IP ์ฃผ์†Œ๋“ค์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค. ip link ๋ช…๋ น์–ด์˜ ์ถœ๋ ฅ๊ณผ ์œ ์‚ฌํ•˜์ง€๋งŒ, ๋งˆ์ง€๋ง‰์— ์ธํ„ฐํŽ˜์ด์Šค์— ํ• ๋‹น๋œ CIDR ๊ฐ’์ด ๋ณด์ธ๋‹ค.

์ถœ๋ ฅ๊ฐ’์„ ๋ณด๋ฉด ์ต์ˆ™ํ•œ ์ด๋ฆ„์ธ 127.0.0.1 ์ฃผ์†Œ๊ฐ€ ๋ณด์ธ๋‹ค. ๋กœ์ปฌ ํ˜ธ์ŠคํŠธ์˜ ์ฃผ์†Œ๋‹ค! ์ฆ‰, ์šฐ๋ฆฌ๊ฐ€ 127.0.0.1 ํ–ˆ์„ ๋•Œ, ๋กœ์ปฌ ํ˜ธ์ŠคํŠธ์— ๋ฐ์ดํ„ฐ๋ฅผ ์ „์†กํ•  ์ˆ˜ ์žˆ๋Š” ์ด์œ ๊ฐ€ ๋ฃจํ”„๋ฐฑ ์ธํ„ฐํŽ˜์ด์Šค์— ํ• ๋‹น๋˜์–ด ์žˆ๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค!

์ •ํ™•ํžˆ๋Š” 127.0.0.1/8 CIDR์ด ๋ฃจํ”„๋ฐฑ ์ธํ„ฐํŽ˜์ด์Šค์— ํ• ๋‹น๋˜์–ด ์žˆ๊ธฐ ๋•Œ๋ฌธ์— 127.0.0.1 ~ 127.255.255.255 ๋ฒ”์œ„์˜ ๋ชจ๋“  IP ์ฃผ์†Œ๋Š” ๋กœ์ปฌ ํ˜ธ์ŠคํŠธ๋ฅผ ๊ฐ€๋ฆฌํ‚จ๋‹ค.

inet์€ ๋„คํŠธ์›Œํฌ ๋ ˆ์ด์–ด์˜ ํ”„๋กœํ† ์ฝœ๋กœ inet์ด๋ฉด ipv4๋ฅผ inet6๋ฉด ipv6์ด๋‹ค.

lft๋Š” Lifetime์˜ ์•ฝ์ž๋กœ ๋ฃจํ”„๋ฐฑ์˜ IP ์ฃผ์†Œ๊ฐ€ ํ‰์ƒ ์œ ํšจํ•˜๊ฒŒ ์„ค์ • ๋˜์–ด ์žˆ๋‹ค.

๋ฃจํ”„๋ฐฑ ์ฃผ์†Œ ์ถ”๊ฐ€ํ•˜๊ธฐ

$ ip addr add 192.168.40.1/32 dev lo

References


  1. 65 Kbย