ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 맥 터미널 명령어 입문3: 네트워크 관련 명령어
    개발입문/개발환경 세팅 2016. 12. 11. 17:20

    내 컴퓨터의 네트워크 환경에 대해 알아보려고 한다.


    네트워크와 TCP/IP 프로토콜 관련 내용은 다음 유투브 링크에서 확인할 수 있다 (조금 딱딱하지만 정석!)

    (주) 한빛미디어 뇌를 자극하는 TCP/IP 소켓 프로그래밍 제 1강. 개요부터


    아래 글에서는 터미널을 통해 OS X 네트워크 상태를 확인할 수 있는 명령어를 설명한다.


    | $ping OOO.com 

    핑테스트 Ping Test 는 네트워크 상 각 호스트간 통신이 가능한 상태인지 확인하는 명령어이다. 핑테스트를 하는 이유는 인터넷 속도가 정상인지, 끊김은 없는지를 알아보기 위함이다. 

    여기서는 google.com 으로 ping 해보았다. 
    - google.com 의 Domain Name 은 google.com 이지만, 실제 ip 주소는 172.217.25.206
    - TTL (Time to Live): 몇개의 라우터를 거치는 동안 살아남을 수 있는지 (TTL 초과하면 자동 소멸)
    - time: 응답시간 네트워크의 전송 단위: 패킷 (64 bytes)이 약 40 ms 마다 전송

    Ctrl + C 를 누르면 ping Test를 종료하고 통계를 보여준다. 

    YOUKYUNGs-MacBook-Air:~ HALORA$ ping google.com

    PING google.com (172.217.25.206): 56 data bytes

    64 bytes from 172.217.25.206: icmp_seq=0 ttl=52 time=39.673 ms

    64 bytes from 172.217.25.206: icmp_seq=1 ttl=52 time=40.708 ms

    64 bytes from 172.217.25.206: icmp_seq=2 ttl=52 time=40.354 ms

    64 bytes from 172.217.25.206: icmp_seq=3 ttl=52 time=42.136 ms

    64 bytes from 172.217.25.206: icmp_seq=4 ttl=52 time=45.761 ms

    ^C

    --- google.com ping statistics ---

    5 packets transmitted, 5 packets received, 0.0% packet loss

    round-trip min/avg/max/stddev = 39.673/41.726/45.761/2.172 ms



    | $ifconfig  Interface Configurator

    운영체제에 설정된 네트워크 장치의 목록을 보여준다. 네트워크 장치의 IP를 변경하거나 장치를 비활성화하거나 재활성화 하는 등의 기능도 가지고 있다.


    YOUKYUNGs-MacBook-Air:~ HALORA$ ifconfig

    lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384

    options=3<RXCSUM,TXCSUM>

    inet6 ::1 prefixlen 128 

    inet 127.0.0.1 netmask 0xff000000 

    inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 

    nd6 options=1<PERFORMNUD>



    | $netstat -a 

    NETwork STATus 네트워크의 연결상태를 모니터링하는 명령이다. 

    - Recv-Q, Send-Q는 소켓 버퍼사이즈로 아직 전송/수신되지 못한 바이트 수이다. 

    - Foreign Address (공인 IP, 공유기 IP)와 Foreign Address내에서의 IP주소인 Local Address가 구분되어있다.

    - state를 통해 어떤 서비스가 활성화되어 동작중인지 (Established), 어떤 클라이언트가 접속중인지 (LISTEN) 확인할 수 있다.


    netstat 명령어는 -a 외 많은 옵션을 가진다. 그 부분은 필요할 때마다 찾아보자~

    그 외 커널 관련은 운영체제 단의 작업이므로 일단 신경을 껐다.


    Active Internet connections (including servers)

    Proto Recv-Q Send-Q  Local Address          Foreign Address        (state)  

    tcp4       0      0  192.168.0.5.56674      www.evernote.com.https ESTABLISHED

    tcp4       0      0  192.168.0.5.56532      17.252.156.53.5223     ESTABLISHED

    tcp4      37      0  172.30.23.229.49766    www.eclipse.org.https  CLOSE_WAIT 

    tcp46      0      0  *.mysql                *.*                    LISTEN     

    (...)

    // 그 외

    Active Multipath Internet connections

    Active LOCAL (UNIX) domain sockets

    Registered kernel control modules

    Active kernel event sockets

    Active kernel control sockets



    | $traceroute

    말그대로 Routing 경로를 추적하는 명령어이다. 패킷(데이터 조각)이 발신 컴퓨터에서 출발해 인터넷을 거쳐 목적지까지 도착하려면 숨낳은 라우터 또는 게이트웨이를 지나가야 한다. 이렇게 패킷이 라우터를 거쳐서 전달되는 과정을 라우팅 -Routing- 이라고 한다. 첫번째 게이트웨이는 내 무선공유기 (공인IP) 가 된다. 그 이후 지나가는 라우터의 주소 및 처리시간이 찍힌다. 


    YOUKYUNGs-MacBook-Air:~ HALORA$ traceroute google.com

    traceroute to google.com (172.217.25.238), 64 hops max, 52 byte packets

     1  192.168.0.1 (192.168.0.1)  4.044 ms  1.275 ms  1.862 ms

     2  192.168.25.1 (192.168.25.1)  2.602 ms  2.058 ms  2.635 ms

     3  1.241.111.1 (1.241.111.1)  5.301 ms  5.495 ms *

     4  * * *

     5  * 58.234.17.245 (58.234.17.245)  7.768 ms  3.187 ms

     6  * * *

     (...)



    |$nslookup

    nslookup 은 Name Server 와 관련된 내용을 조회하는 (DNS 주소를 IP로 확인하는) 명령어이다. 

    haloaround.tistory.com 은 두 서버에서 응답한다. (175.126.170.110, 70) google.com은 ns 레코드로 nameserver 목록을 확인했다. (총 4대)

    참고: (Eng) DNS Record and Record Types  / nslookup 명령어 사용법 및 예제 정리


    YOUKYUNGs-MacBook-Air:~ HALORA$ nslookup haloaround.tistory.com

    Server: 210.220.163.82

    Address: 210.220.163.82#53


    Non-authoritative answer:

    Name: haloaround.tistory.com

    Address: 175.126.170.110

    Name: haloaround.tistory.com

    Address: 175.126.170.70


    (...)


    YOUKYUNGs-MacBook-Air:~ HALORA$ nslookup -type=ns google.com

    Server: 210.220.163.82

    Address: 210.220.163.82#53


    Non-authoritative answer:

    google.com nameserver = ns1.google.com.

    google.com nameserver = ns3.google.com.

    google.com nameserver = ns4.google.com.

    google.com nameserver = ns2.google.com.




    댓글

Designed by Tistory.