Backend with Golang

[Network] IP Class, Subnet Mask, CIDR

아직개구리 2023. 8. 3. 00:08

1. IP Class 

  • A,B,C 등등 클래스로 나누게 되는데, 
    • A클래스: 00000000.00000000.00000000.00000000 (Network Address: 0 - 127)
      • A class network → 128개 → 하나 당 사용할 수 있는 ip 개수 16,777,216 가 된다.
    • B클래스: 10000000.00000000.00000000.00000000 (Network Address: 128.0 ~ 191.255)
    • C클래스: 11000000.00000000.00000000.00000000 (Network Address: 192.0.0 ~ 223.255.255)
  • highlight : network number, other numbers for local address
  • inflexible 하고, 쉽게 split up 하기 어려움. 주소공간 낭비. cidr로 표기하면 suffix가 8, 16, 24 로 제한되는 것이다. 

2. Subnet Mask 

  • IP 주소 와 subnet mask를 사용해서 AND 연산을 해서 network address를 구할 수 있다. 
    • network address: 첫번째 주소
    • broadcast address: 마지막 주소, host 영역에 1로 채운 것
    • 실제 사용한 주소는 network address와 broadcast address사이
  • 32 bit number가 filter역할을 하고, network와 host portion으로 나눌때 사용된다. element의 division이 효율적으로 이뤄지기 때문에 confusion이나 delay가 없어져 hosts 간의 data전송이 빠르게 이뤄질 수 있다.

3. CIDR: Classless Inter-Domain Routing

  • 원래 목적은 routing table의 size를 줄이기 위함. 더불어 security, scalability, performance의 향상도 있었음.
  • subnet mask를 나타내는 또다른 방식이라 할 수 있다.
  • slash + suffix ( total # of bits used for the network address)
  • IPv6일 떄는 2001:0db8:/32 이런식으로 표기된다. 
  • CIDR을 사용하면 subnetting과 supernetting을 할 수 있다. 
    • Subnetting : host 부분에서 bit를 빌려와서 subnet을생성하고 각각 여러개의 host들을 가지게 된다.
    • Supernetting: 인접한 subnet을 하나의 network로 aggregation 하는 것이다. IP 주소 네트워크 id portion에서 비트를 선택하여 aggregated representation을 만든다.