ifconfig

2 분 소요

linux의 ifconfig는 시스템에 설정된 네트워크 인터페이스의 상태를 확인 할 수 있는 명령어 입니다.

$> ifconfig
docker0   Link encap:Ethernet  HWaddr 02:42:ed:b0:91:f2  
          inet addr:172.17.0.1  Bcast:172.17.255.255  Mask:255.255.0.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

enp3s0    Link encap:Ethernet  HWaddr 74:d4:35:1e:a9:87  
          inet addr:192.168.0.50  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::3be5:4edf:81f5:2037/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:11149676 errors:0 dropped:0 overruns:0 frame:0
          TX packets:9835684 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:3583344722 (3.5 GB)  TX bytes:1229319911 (1.2 GB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:376652 errors:0 dropped:0 overruns:0 frame:0
          TX packets:376652 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:31212407 (31.2 MB)  TX bytes:31212407 (31.2 MB)

출력된 내용은 부분별로 다음을 의미 합니다.

  • docker0 : Docker가 설치되어 있는 경우 Docker용 가상 인터페이스가 추가로 설정되어 있습니다.
  • enp3s0 : 유선 네트워크 인터페이스를 의미 합니다.(랜카드)
  • lo : 루프 백 인터페이스로 자기자신과 통신하는데 사용하는 가상 장치를 의미합니다.
  • HWaddr : 하드웨어 주소, 즉 MAC address를 나타낸다.
  • inet addr : 할당된 IPv4 주소
  • inet6 addr : 할당된 IPv6 주소
  • Bcast : 브로드캐스트 주소
  • Mask : 넷마스크
  • MTU : 네트워크 최대 전송 단위(Maxium Transter Unit)
  • RX packets : 받은 패킷 정보
  • TX packets : 보낸 패킷 정보
  • collisions : 충돌된 패킷 수
  • txqueuelen : 송신 큐 길이를 나타낸다.

help ifconfig

$> ifconfig --help
Usage:
  ifconfig [-a] [-v] [-s] <interface> [[<AF>] <address>]
  [add <address>[/<prefixlen>]]
  [del <address>[/<prefixlen>]]
  [[-]broadcast [<address>]]  [[-]pointopoint [<address>]]
  [netmask <address>]  [dstaddr <address>]  [tunnel <address>]
  [outfill <NN>] [keepalive <NN>]
  [hw <HW> <address>]  [metric <NN>]  [mtu <NN>]
  [[-]trailers]  [[-]arp]  [[-]allmulti]
  [multicast]  [[-]promisc]
  [mem_start <NN>]  [io_addr <NN>]  [irq <NN>]  [media <type>]
  [txqueuelen <NN>]
  [[-]dynamic]
  [up|down] ...

  <HW>=Hardware Type.
  List of possible hardware types:
    loop (Local Loopback) slip (Serial Line IP) cslip (VJ Serial Line IP) 
    slip6 (6-bit Serial Line IP) cslip6 (VJ 6-bit Serial Line IP) adaptive (Adaptive Serial Line IP) 
    ash (Ash) ether (Ethernet) ax25 (AMPR AX.25) 
    netrom (AMPR NET/ROM) rose (AMPR ROSE) tunnel (IPIP Tunnel) 
    ppp (Point-to-Point Protocol) hdlc ((Cisco)-HDLC) lapb (LAPB) 
    arcnet (ARCnet) dlci (Frame Relay DLCI) frad (Frame Relay Access Device) 
    sit (IPv6-in-IPv4) fddi (Fiber Distributed Data Interface) hippi (HIPPI) 
    irda (IrLAP) ec (Econet) x25 (generic X.25) 
    eui64 (Generic EUI-64) 
  <AF>=Address family. Default: inet
  List of possible address families:
    unix (UNIX Domain) inet (DARPA Internet) inet6 (IPv6) 
    ax25 (AMPR AX.25) netrom (AMPR NET/ROM) rose (AMPR ROSE) 
    ipx (Novell IPX) ddp (Appletalk DDP) ec (Econet) 
    ash (Ash) x25 (CCITT X.25)

tldr ifconfig

$> tldr ifconfig

  ifconfig

  Network Interface Configurator.

  - View network settings of an ethernet adapter:
    ifconfig eth0

  - Display details of all interfaces, including disabled interfaces:
    ifconfig -a

  - Disable eth0 interface:
    ifconfig eth0 down

  - Enable eth0 interface:
    ifconfig eth0 up

  - Assign IP address to eth0 interface:
    ifconfig eth0 ip_address

참고 링크