Ubuntu/linux Command

Linux System Command (ifconfig) - interface configuration

HobbyCoding 2021. 8. 9. 17:27
728x90

ifconfig는 “interface configuration”의 약자로 리눅스의 네트워크 관리를 위한 인터페이스 구성 유틸리티

ifconfig 명령은 현재 네트워크 구성 정보를 표시하고 네트워크 인터페이스에 IP 주소, 넷 마스크 또는 broadcast 주소를 설정하고 네트워크 인터페이스의 별칭을 만들고 하드웨어 주소를 설정하고 네트워크 인터페이스를 활성화 또는 비활성화하는 등 다양한 곳에 사용

 

용례1 : ifconfig 

 

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.25.57  netmask 255.255.255.0  broadcast 192.168.25.255
        inet6 fe80::58a9:b29b:50ae:c5e5  prefixlen 64  scopeid 0xfd<compat,link,site,host>
        ether e8:6a:64:2f:22:22  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        
        
 lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 1500
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0xfe<compat,link,site,host>
        loop  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

  • [eth0] : 네트워크 인터페이스
  • [flags] : 네트워크 카드의 상태 표시
  • [mtu] : 네트워크 인터페이스의 최대 전송 단위(Maximum Transfer Unit)
  • [inet] : 네트워크 인터페이스에 할당된 IP 주소
  • [netmask] : 네트워크 인터페이스에 할당된 넷마스크 주소
  • [broadcast] : 네트워크 인터페이스에 할당된 브로드캐스트 주소
  • [inet6] : 네트워크 인터페이스에 할당된 IPv6 주소
  • [prefixlen] : IP 주소에서 서브 넷 마스크로 사용될 비트 수
  • [scopeid] : IPv6의 범위. LOOPBACK / LINKLOCAL / SITELOCAL / COMPATv4 / GLOBAL
  • [ether] : 네트워크 인터페이스의 하드웨어 주소
  • [RX packets] : 받은 패킷 정보
  • [TX packets] : 보낸 패킷 정보
  • [collision] : 충돌된 패킷 수
  • [Interrupt] : 네트워크 인터페이스가 사용하는 인터럽트 번호

 

 

용례2 : ifconfig -a

   -a :  all 

   비활성화된 네트워크 인터페이스도 볼 수 있게 된다.

 

 

용례3 : ifconfig <interface>

인터페이스가 너무 많은 경우에는 원하는 인터페이스만 조회.

ex) ifconfig eth0

 

 

용례4 : ifconfig <interface> down

인터페이스 비활성화. (ex : ifconfig eth0 down)

flags=4098 <BROADCAST,MULTICAST> 와 같이 선두에 표시가 됨

 

 

용례5 : ifconfig <interface> up

인터페이스 활성화. (ex : ifconfig eth0 up)

flags=4163<UP,BROADCAST,RUNNING,MULTICAST>

 

 

용례6 :  ifconfig <interface> <IP>

인터페이스에 IP 변경하기 :  (ex : ifconfig  eth0 172.21.213.76)