IT/Linux

[Linux] CentOS7 IP 확인 방법

Erynn 2022. 6. 10.
VMware Workstation
OS : CentOS 7.9

 

📌 참고사항 
Redhat은 centOS7 부터는 기본적으로 net-tools 패키지를 더 이상 설치하지 않습니다.
ifconfig 나 netstat 과 같은 명령어를 사용하려면 net-tools 패키지를 yum으로 설치해야합니다.

 


1.  ip addr / ip addr show

두 명령어 모두 결과 출력 화면은 같습니다.

[root@test ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:a3:8c:f3 brd ff:ff:ff:ff:ff:ff
    inet 211.183.3.147/24 brd 211.183.3.255 scope global noprefixroute dynamic ens32
       valid_lft 1497sec preferred_lft 1497sec
    inet6 fe80::564c:628c:199e:de87/64 scope link noprefixroute
       valid_lft forever preferred_lft forever
[root@test ~]# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:a3:8c:f3 brd ff:ff:ff:ff:ff:ff
    inet 211.183.3.147/24 brd 211.183.3.255 scope global noprefixroute dynamic ens32
       valid_lft 1476sec preferred_lft 1476sec
    inet6 fe80::564c:628c:199e:de87/64 scope link noprefixroute
       valid_lft forever preferred_lft forever

 

2. hostname -I (대문자 i)

간단하게 IP만 뽑아서 볼 수 있습니다.

[root@test ~]# hostname -I
211.183.3.147

 

3. ifconfig

가장 일반적으로 많이 쓰이는 명령어 인 것 같습니다.

해당 명령어가 안먹힌다면 yum install net-tools 로 설치하셔서 활용하시면 됩니다.

[root@test ~]# ifconfig
ens32: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 211.183.3.147  netmask 255.255.255.0  broadcast 211.183.3.255
        inet6 fe80::564c:628c:199e:de87  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:a3:8c:f3  txqueuelen 1000  (Ethernet)
        RX packets 19824  bytes 24712018 (23.5 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3604  bytes 263068 (256.9 KiB)
        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 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