| 용어 | 설명 |
|---|---|
| network | 컴퓨터와 같은 노드들이 통신 기술을 통해 그물망처럼 연결되어 통신을 하는 형태 |
| LAN | Local Area Network = 근거리 통신망 |
| internet | LAN 과 LAN의 통신 |
| protocol | 데이터 통신을 원활하게 하기 위해 필요한 통신 규약 |
| tcp/ip | protocol의 한 종류, telnet과 ftp,mail등 가장 많이 사용 |
| gateway | 다른 network와 통신을 위한 관문 |
| ip | 통신을 하기 위해 각각 컴퓨터에 부여된 주소 |
| Domain | 어떤 웹 사이트를 지칭하기 위해 의미를 확장한 단어 = LAN 이름 |
| Hostname | LAN에서 다른 host들과 구분하기 위한 이름 |
| network 주소 | LAN의 대표 ip - 가장 작은 번호 |
| BroadCast | LAN내에 모든 host들이 듣는 특별한 주소 - 가장 큰 번호 |
| DNS | Domain Name System = 도메인을 ip로 변경해주는 시스템 |
| netmask | 내부망과 외부마을 구분하는 값, LAN의 크기를 결정하는 값 |
| ICMP | Internet Control Message Protocol = host서버와 Internet GateWay사이에서 메시지를 제어하고 에러를 알려주는 protocol |
| packet | 네트워크 전송의 용량 단위 / 분할 |
| 공인 ip | 공인기관에서 인증한 공개형(public) IP 주소 |
| 사설 ip | 공인되지 않은IP 주소 = 폐쇄형 |
| NIC | Network Interface Card = 호스트에서 네트워크와의 연결을 담당한 인터페이스 역할을 하는 장치, 랜카드 |
| traceroute | 자신의 컴퓨터가 인터넷을 통해 목적지에 찾아가면서 거치는 구간의 정보를 기록하는 유틸리티. IP 주소,각 구간마다 지나는 게이트웨이 컴퓨터의 이름이나 주소, 그리고 걸리는 시간 등을 표시 |
| Router | Gateway 역할을 하는 장비 |
| SWITCH | MAC 주소를 바탕으로 필터링 가능한 지능 HUB |
| HUB | 여러대의 컴퓨터를 연결하는 장비, 물리적 포트를 연결 |
vi /etc/netplan/yaml
root@nc7
09:22:43:~# nl /etc/netplan/00-installer-config.yaml
1 # This is the network config written by 'subiquity'
2 network: - 네트워크 설정
3 ethernets: - 이더넷 인터페이스에 대한 설정
4 enp0s3: - enp0s3라는 이름의 이더넷 인터페이스를 설정
5 dhcp4: true - 해당 인터페이스에서 DHCP를 사용하여 IPv4 주소를 동적으로 할당받도록 설정
6 version: 2
위 설정 파일은 enp0s3 인터페이스에 대해 DHCP를 사용하여 IPv4 주소를 자동으로 할당하도록 구성하고 있습니다. 이러한 설정은 해당 인터페이스가 네트워크에 연결되어 있을 때 자동으로 IP 주소를 할당받도록 하여, 인터넷에 연결할 수 있도록 도와줍니다.
ifconfig
root@nc7:~# ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
<inet 10.0.2.15 netmask 255.255.255.0 broadcast 10.0.2.255> - inet : 고유 ip
inet6 fe80::a00:27ff:fe2d:2631 prefixlen 64 scopeid 0x20<link> - 인터페이스 MAC Address
ether 08:00:27:2d:26:31 txqueuelen 1000 (Ethernet)
RX packets 648 bytes 523247 (523.2 KB) - RX : recieve
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 361 bytes 59498 (59.4 KB) - TX : Tranceportp
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
<inet 127.0.0.1 netmask 255.0.0.0>
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 110 bytes 9175 (9.1 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 110 bytes 9175 (9.1 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
- lo : loopback = host 자신 = 자신으로 돌아오는 주소
root@nc7:/etc/netplan# ifconfig -a - a : all
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
<inet 10.0.2.15 netmask 255.255.255.0 broadcast 10.0.2.255>
inet6 fe80::a00:27ff:fe2d:2631 prefixlen 64 scopeid 0x20<link>
ether 08:00:27:2d:26:31 txqueuelen 1000 (Ethernet)
RX packets 5330 bytes 6902430 (6.9 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3568 bytes 297907 (297.9 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
<inet 127.0.0.1 netmask 255.0.0.0 >
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 2123 bytes 94445 (94.4 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2123 bytes 94445 (94.4 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
-ping
-bash: ping: command not found - ping이 입력이 되지 않을떄
root@il7@15:12:42:~# ai iputils-ping - tool을 설치
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
iputils-ping
0 upgraded, 1 newly installed, 0 to remove and 3 not upgraded.
Need to get 42.9 kB of archives.
After this operation, 116 kB of additional disk space will be used.
Get:1 http://kr.archive.ubuntu.com/ubuntu jammy/main amd64 iputils-ping amd64 3:20211215-1 [42.9 kB]
Fetched 42.9 kB in 3s (14.3 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package iputils-ping.
(Reading database ... 80198 files and directories currently installed.)
Preparing to unpack .../iputils-ping_3%3a20211215-1_amd64.deb ...
Unpacking iputils-ping (3:20211215-1) ...
Setting up iputils-ping (3:20211215-1) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline
Scanning processes...
Scanning linux images...
Running kernel seems to be up-to-date.
No services need to be restarted.
No containers need to be restarted.
No user sessions are running outdated binaries.
No VM guests are running outdated hypervisor (qemu) binaries on this host.
root@il7@15:13:24:~# ping 8.8.8.8 - 정상적인 ping 입력이 완료
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=55 time=37.7 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=55 time=37.5 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=55 time=37.7 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=55 time=37.6 ms
64 bytes from 8.8.8.8: icmp_seq=5 ttl=55 time=37.5 ms
^C
--- 8.8.8.8 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4007ms
rtt min/avg/max/mdev = 37.466/37.590/37.686/0.078 ms
root@nc7:~# apt -y install nmap - nmap 설치 !
root@nc7:/etc/netplan# nmap localhost - 본인
Starting Nmap 7.80 ( https://nmap.org ) at 2023-05-01 15:13 UTC
Nmap scan report for localhost (127.0.0.1)
Host is up (0.0000010s latency).
Not shown: 999 closed ports
PORT STATE SERVICE
22/tcp open ssh
Nmap done: 1 IP address (1 host up) scanned in 0.07 seconds
root@nc7:/etc/netplan#
root@nc7:/etc/netplan# nmap google.com - google ip 탐색
Starting Nmap 7.80 ( https://nmap.org ) at 2023-05-01 15:13 UTC
Nmap scan report for google.com (142.250.206.238)
Host is up (0.0079s latency).
Other addresses for google.com (not scanned): 2404:6800:400a:80a::200e
rDNS record for 142.250.206.238: kix06s10-in-f14.1e100.net
Not shown: 998 filtered ports
PORT STATE SERVICE
80/tcp open http
443/tcp open https
Nmap done: 1 IP address (1 host up) scanned in 4.89 seconds
traceroute
root@nc7:~# apt-get install traceroute - traceroute 설치!
root@nc7:~# traceroute naver.com - naver.com까지 경로 추척
traceroute to naver.com (223.130.195.95), 30 hops max, 60 byte packets
1 _gateway (10.0.2.2) 0.269 ms 0.240 ms 0.322 ms
2 * * *
3 * * *
4 * * *
5 * * *
6 * * *
7 * * *
8 * * *
9 * * *
10 * * *
11 * * *
12 * *^C
### Ip_class 구분방법
내부망과 외부망을 구분하는 방법
목적지 주소와 netmask를 &&연산한다.(&& = and)
Routing table 계산법
목적지 주소와 첫번째 genmask값을 &&연산한다.
결과값과 목적지 destination값과 비교하여 일치하면 paket을 보내고, 일치하지 않으면 다음 genmask값과 목적지 주소를 && 연산한다.(genmask = 특정 패킷이 어디로 가야할지 결정하기 위해 해당 패킷이 가진 목적지 IP 주소와 AND 연산을 할 때 사용되는 값)
사설 ip
| 사설 ip | 범위 | 허용 범위 |
|---|---|---|
| A class | 10.0.0.0 ~ | 10.255.255.255 |
| B class | 172.16.0.0 ~ | 172.32.255.255 |
| C class | 192.168.0.0 ~ | 192.168.255.255 |
Netmask ? : IP 주소의 네트워크 부분과 호스트 부분을 구별하는데 사용
| class | Netmask |
|---|---|
| A class | 255.0.0.0 |
| B class | 255.255.0.0 |
| C class | 255.255.255.0 |
IP 주소는 네트워크 구간과 호스트 구간으로 나뉨.
Netmask는 어떤 비트까지가 “네트워크 부분”인지 알려줌.
예:
Netmask = /24 = 255.255.255.0
| 항목 | 값 |
|---|---|
| Network 주소 | 200.100.100.0 |
| Broadcast 주소 | 200.100.100.255 |
| Netmask | 255.255.255.0 |
| 유효 IP 범위 | 200.100.100.1 ~ 200.100.100.254 |
200.100.100.30 → 같은 네트워크200.100.100.190 → 같은 네트워크 (내망)200.100.100.190 & 255.255.255.0 = 200.100.100.0✅ 결과:
두 IP의 AND 결과가 같으면 같은 네트워크에 속함.
| 항목 | 값 |
|---|---|
| Netmask | /25 = 255.255.255.128 |
| 첫 번째 네트워크 | 200.100.100.0 ~ 200.100.100.127 |
| 두 번째 네트워크 | 200.100.100.128 ~ 200.100.100.255 |
200.100.100.30 & 255.255.255.128 = 200.100.100.0200.100.100.190 & 255.255.255.128 = 200.100.100.128결과가 다르므로,
✅ 30은 0번 네트워크,
✅ 190은 128번 네트워크에 속함.
즉,
30 → 내부망
190 → 외부망
| 구분 | IP | Netmask | AND 결과 | 네트워크 |
|---|---|---|---|---|
| 예1 | 200.100.100.30 | 255.255.255.0 | 200.100.100.0 | 동일망 |
| 예1 | 200.100.100.190 | 255.255.255.0 | 200.100.100.0 | 동일망 |
| 예2 | 200.100.100.30 | 255.255.255.128 | 200.100.100.0 | 내부망 |
| 예2 | 200.100.100.190 | 255.255.255.128 | 200.100.100.128 | 외부망 |
💡 정리
- IP와 Netmask를 AND 연산한다.
- 결과(NetID)가 같으면 같은 네트워크, 다르면 다른 네트워크.
- Netmask가 작을수록(예: /24) 더 큰 네트워크를 의미.
반대로 /25, /26처럼 길어질수록 네트워크가 더 세분화됨.
network IP : 내부 네트워크의 시작이 되는 IP (0으로 끝나는 ip)
Broadcast : 내부 네트워크의 끝이 되는 IP (255 가 끝인 ip)
상대 ip가 들어오면 Netmask와 IP를 &&연산 =>같으면 ★내부 network
상대 ip가 들어오면 Netmask와 IP를 &&연산 =>다르면 ★외부 network
내 Netmask 계산 방법
Netmask를 이용하여 상대 ip와 netmask를 && 연산시 하여 본인 ip와 비교하고 같으면 외/내부 네트워크를 구별한다!