[Hyper-V]Network ์„ค์ • - NAT / Port Forwarding / ๋‚ด๋ถ€ IP ๊ณ ์ •

2023. 7. 7. 17:08ใ†System ์ž‘์—…์‹ค/Server ๊ด€๋ จ

728x90
๋ฐ˜์‘ํ˜•

 




 

 

 

๐Ÿš€ [Hyper-V]Network ์„ค์ • - NAT / Port Forwarding / ๋‚ด๋ถ€ IP ๊ณ ์ •

    ๐Ÿ”ฝ ๊ฐœ์š”

        ๐Ÿ“ฆ ์†Œ๊ฐœ

์ด๋ฒˆ ๊ธ€์—์„œ๋Š” Hyper-V๋ฅผ ์ด์šฉํ•ด์„œ ๊ฐ€์ƒ ๋จธ์‹ ์„ ์šด์˜ํ•  ๋•Œ, ํ•„์š”ํ•œ ๋‚ด๋ถ€ IP ๊ณ ์ •, NAT / ํฌํŠธ ํฌ์›Œ๋”ฉ ๋“ฑ์— ๋Œ€ํ•ด ์ž‘์—…์„ ํ•ด๋ณด๋ ค๊ณ  ํ•ด์š”.

Hyper-V ํŠน์ง•์— ๋Œ€ํ•ด ์ž ์‹œ ์†Œ๊ฐœ๋ฅผ ํ•˜์ž๋ฉด Hyper-V์—์„œ ๊ธฐ๋ณธ์ ์œผ๋กœ ์ œ๊ณต๋˜๋Š” Default Switch์˜ ๊ฒฝ์šฐ ํ• ๋‹น๋˜๋Š” IP ๋Œ€์—ญํญ๋„ ๋งŽ๊ณ , ๋‚ด๋ถ€๋ง์ด๊ธฐ ๋•Œ๋ฌธ์— ํฌํŠธ ํฌ์›Œ๋”ฉ๋„ ๋˜์ง€ ์•Š๋Š”๋‹ค๋Š” ๋‹จ์ ์„ ๊ฐ€์ง€๊ณ  ์žˆ์–ด์š”.

๊ทธ๋ž˜์„œ NAT Network๋ฅผ ๋”ฐ๋กœ ๋งŒ๋“ค์–ด์ฃผ๊ณ , ํฌํŠธ ํฌ์›Œ๋”ฉํ•˜๋Š” ์ž‘์—…์„ ํ•ด๋ณด๋ ค๊ณ  ํ•ด์š”.

 

 

 

    ๐Ÿ”ฝ Hyper-V

        ๐Ÿ“ฆ NAT Network ๋งŒ๋“ค๊ธฐ

์ตœ์ดˆ Hyper-V๊ฐ€ ๊ตฌ๋™์ค‘์ธ VM Host Server์—์„œ ์œ„์™€ ๊ฐ™์ด Windows PowerShell์„
๊ด€๋ฆฌ์ž ๊ถŒํ•œ์œผ๋กœ ์‹คํ–‰ ์‹œ์ผœ ์ค„๊ฑฐ์—์š”.

 

 

๊ทธ๋ฆฌ๊ณ , ์•„๋ž˜ ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด NAT Network๋ฅผ ๋งŒ๋“ค์–ด ์ค„๊ฒŒ์š”.

New-VMSwitch -SwitchName "Giggal-NAT-Switch" -SwitchType Internal
728x90

 


๊ทธ๋Ÿฐ ๋’ค ๋„คํŠธ์›Œํฌ ๋ฐ ๊ณต์œ  ์„ผํ„ฐ(์‹คํ–‰ -> ncpa.cpl)์—์„œ ๋„คํŠธ์›Œํฌ๋ฅผ ํ™•์ธํ•ด ๋ณด๋ฉด

 

 

 

์œ„์™€ ๊ฐ™์ด vEthnet Port๊ฐ€ ๋งŒ๋“ค์–ด์ง„ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์–ด์š”.

์ด์ œ PowerShell์—์„œ ๋‹ค์‹œ ์ž‘์—…์„ ํ•ด์ค„๊ฑฐ์—์š”.

New-NetIPAddress -IPAddress 172.16.0.1 -PrefixLength 12 -InterfaceAlias "vEthernet (NAT-Switch)"


์œ„์˜ ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด Hyper-V ์ž…์žฅ์—์„œ๋Š” vSwitch๊ฐ€ ๋˜๋Š” ๊ณณ์— IP๋ฅผ ๋ถ€์—ฌํ•ด ์ฃผ๋„๋ก ํ• ๊ฑฐ์—์š”.

์‚ฌ์„ค Network IP ๋Œ€์—ญ์€ ๋ณดํŽธ์ ์œผ๋กœ ์•„๋ž˜์™€ ๊ฐ™์ด ์กด์žฌํ•ด์š”.

IP ์ฃผ์†Œ ๋Œ€์—ญ CIDR
10.0.0.0 ~ 10.255.255.255 10.0.0.0/8
172.16.0.0 ~ 172.31.255.255 172.16.0.0/12
192.168.0.0 ~ 192.168.255.255 192.168.0.0/16


์œ„ ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด ํ• ๋‹น๋˜๋Š” IP๊ฐ€ vSwitch IP๊ฐ€ ๋  ๊ฒƒ์ด๊ณ ,
์ด Network์— ์—ฐ๊ฒฐ๋œ Virtual Machine๋“ค์˜ Gateway๋Š” ์ด IP์ฃผ์†Œ๋ฅผ ๋ฐ”๋ผ๋ณด๊ฒŒ ์„ค์ •์„ ํ•ด์ฃผ์–ด์•ผ ํ•ด์š”.

 

 


์œ„์™€ ๊ฐ™์ด ํ•œ ๋’ค ์•„๋ž˜ ๋ช…๋ น์–ด๋ฅผ ์ด์šฉํ•ด NAT๋ฅผ ํ™œ์„ฑํ™” ์‹œ์ผœ์ค„ ์ˆ˜ ์žˆ์–ด์š”.

New-NetNat -Name NAT-Swtich -InternalIPInterfaceAddressPrefix 172.16.0.0/12
๋ฐ˜์‘ํ˜•


์—ฌ๊ธฐ๊นŒ์ง€ ์ž˜ ๋˜์—ˆ๋‹ค๋ฉด NAT๋ฅผ ์ด์šฉํ•  ์ค€๋น„๋Š” ๋ชจ๋‘ ๋๋‚œ ๊ฒƒ์ด์—์š”.

 

 

 

 

 

 

        ๐Ÿ“ฆ Vitual Machine Static IP & Network Setting

์ด๋ฒˆ์—๋Š” ๊ฐ€์ƒ๋จธ์‹ ์˜ ์„ค์ •์„ ํ•ด์ฃผ๋„๋ก ํ• ๊ฒŒ์š”.


์ตœ์ดˆ Hyper-V ๊ฐ€์ƒ ๋จธ์‹  ์„ค์ •์ฐฝ์—์„œ ๋„คํŠธ์›Œํฌ ์–ด๋Œ‘ํ„ฐ์—์„œ ์œ„์™€ ๊ฐ™์ด ๋งŒ๋“ค์–ด์ค€ vSwitch๋ฅผ ์„ ํƒํ•ด ์ค„๊ฑฐ์—์š”.

๊ทธ๋Ÿฐ ๋’ค ๊ฐ€์ƒ ๋จธ์‹ ์„ ๊ฐ€๋™ํ•ด ์ค„๊ฒŒ์š”.


vim /etc/netplan/00-installer-config.yaml

 



netplan apply

 


์œ„ ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด apply๋ฅผ ํ•ด ์ฃผ๊ฒŒ ๋˜๋ฉด ์œ„์™€ ๊ฐ™์ด Network๊ฐ€ ์ •์ƒ ์ž‘๋™ํ•˜๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์–ด์š”.






๐Ÿง ์ฐธ๊ณ  ์ž๋ฃŒ

 

Hyper-V์—์„œ ๋‚ด๋ถ€ ip๊ณ ์ • ๋ฐ NAT/ํฌํŠธํฌ์›Œ๋”ฉ ๋ฐฉ๋ฒ•.

์•ˆ๋…•ํ•˜์„ธ์š”. ๋‹ฌ์†Œ์ž…๋‹ˆ๋‹ค. ์ด๋ฒˆ๊ธ€์€ ์œˆ๋„์šฐ์—์„œ ๊ฐ€์ƒ๋จธ์‹ ์„ ์šด์˜ํ• ๋•Œ ์‚ฌ์šฉ๋˜๋Š” Hyper-V์—์„œ ๋‚ด๋ถ€ ip๊ณ ์ • ๋ฐ NAT/ํฌํŠธํฌ์›Œ๋”ฉ์„ ํ•˜๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค. ๊ธฐ๋ณธ์ ์œผ๋กœ Hyper-V์—์„œ ์ œ๊ณต๋˜๋Š” Default Switch์˜ ๊ฒฝ์šฐ

it-svr.com

 

 

 

 

 

 

 

728x90
๋ฐ˜์‘ํ˜•