How To Check Public IP & Private IP Address in Linux Terminal - The Tech Influences

1

In Linux, a public IP (Internet Protocol) address is used to uniquely identify a device or network on the Internet. and It has many more important purposes:


Internet Connectivity: A public IP address is required to connect your Linux system to the Internet. It enables communication with other devices and servers on the Internet.


Communication and Data Transfer: Public IP addresses enable communication and data transfer between different devices, servers, and networks on the Internet. They facilitate various protocols such as HTTP, FTP, SSH and others for the exchange of data and information.


How To Check Public IP & Private IP Address in Linux Terminal


To Check the Public IP address in Red Hat Linux:- 

Method 1:- Using the Curl Command-

Open your Linux Terminal and type the following command and press enter

[root@redhat-1 ~]# curl ifconfig.me
10.12.13.21[root@redhat-1 ~]#
Here you can see that your Public IP address is showing.

To Check the Private IP address in Red Hat Linux:- 

Method 1:- Using IF Config Command-

Open your Linux Terminal and type the following command and press enter
[test@redhat-1 ~]$ ifconfig
ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.10.3  netmask 255.255.255.0  broadcast 192.168.10.255
        inet6 2323:4242:492b:433c:3232  prefixlen 64  scopeid 0x20<link>
        inet6 2323:3au8:1be0:2843:7987:676a:232e:24dd  prefixlen 64  scopeid 0x0<global>
        ether 36:0c:33:da:43:rr  txqueuelen 1000  (Ethernet)
        RX packets 30507  bytes 41102809 (39.1 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 11335  bytes 1028642 (1004.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 46354
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 40  bytes 3268 (3.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 40  bytes 3268 (3.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[test@redhat-1 ~]$
Here you can see that your Private IP address is showing.

Method 2:- Using IP Address Command-
[test@redhat-1 ~]$ ip address
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: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 43:43:53:cf:39:53 brd ff:ff:ff:ff:ff:ff
    altname enp3s0
    inet 192.168.10.4/24 brd 192.168.10.255 scope global dynamic noprefixroute ens160
       valid_lft 2561sec preferred_lft 2561sec
    inet6 4322:242c:2:42c3:4342:9586:43cc:3ccc:43ccc/64 scope global dynamic noprefixroute
       valid_lft 6572sec preferred_lft 6572sec
    inet6 2323:4242:492b:433c:3232/64 scope link noprefixroute
valid_lft forever preferred_lft forever [test@redhat-1 ~]$
Here you can see that your Private IP address is showing.

Post a Comment

1Comments
Post a Comment