Showing posts with label ip. Show all posts
Showing posts with label ip. Show all posts

Tuesday, April 28, 2020

how to find my public ip address in linux ?

Using dig


dig (domain information groper) is a simple command line utility for probing DNS name servers. To find your public IP addresses, use the opendns.com resolver as in the command below:


Syntax:


dig +short myip.opendns.com @resolver1.opendns.com


Example:


dig +short myip.opendns.com @resolver1.opendns.com


111.125.200.200


Using host


host command is an easy-to-use command line utility for carrying out DNS lookups. The command below will help to display your system public IP address.


Syntax:
host myip.opendns.com resolver1.opendns.com | grep "myip.opendns.com has" | awk '{print $4}'


Example:


host myip.opendns.com resolver1.opendns.com | grep "myip.opendns.com has" | awk '{print $4}'
111.125.200.200


Using wget


curl is a popular command line tool for uploading or downloading files from a server using any of the supported protocols (HTTP, HTTPS, FILE, FTP, FTPS and others). The following
commands display your public IP address.


Syntax:


wget -qO- http://ipecho.net/plain | xargs echo


Or


wget -qO - icanhazip.com


Example:


 wget -qO- http://ipecho.net/plain | xargs echo
111.125.200.200


 wget -qO- http://ipecho.net/plain | xargs echo
111.125.200.200


Using curl


curl is a popular command line tool for uploading or downloading files from a server using any of the supported protocols (HTTP, HTTPS, FILE, FTP, FTPS and others). The following
commands display your public IP address.


Syntax:


curl ifconfig.me


Example:
curl ifconfig.me
111.125.200.200


The following commands will get you the IP address list to find public IP addresses for your machine:

  • curl ifconfig.me
  • curl icanhazip.com
  • curl ipinfo.io/ip
  • curl api.ipify.org
  • curl checkip.dyndns.org
  • curl ident.me
  • curl bot.whatismyipaddress.com
  • curl ipecho.net/plain

Tuesday, March 7, 2017

How do I display all available network interfaces on linux?

How do I display all available network interfaces names under Linux operating systems using bash shell prompt?

You can use the following commands to see all network interfaces under Linux operating systems:

Method 1:

Using ip command

Syntax: ip link show

Example:

root@linuxforfreshers.com:~$ ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether 00:1b:78:8b:33:c4 brd ff:ff:ff:ff:ff:ff
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default qlen 1000
    link/ether 46:41:6e:87:64:74 brd ff:ff:ff:ff:ff:ff

Where
1.    lo – Loopback interface.
2.    eth0 – First Ethernet network interface.
3.     vboxnet0, vmnet1, vmnet8 – Virtual machine interface working in bridge mode or NAT mode. 
Method 2:
Using ifconfig
Syntax: ifconfig
Example:
root@linuxforfreshers.com:~$ ifconfig
eth0      Link encap:Ethernet  HWaddr 00:1b:78:8b:39:d5 
          inet addr:192.168.101.26Bcast:192.1.16.255  Mask:255.255.255.0
          inet6 addr: fe80::21b:78ff:fe8b:33c4/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1881405 errors:0 dropped:0 overruns:0 frame:0
          TX packets:841660 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1234319479 (1.2 GB)  TX bytes:157758923 (157.7 MB)
          Interrupt:19 Memory:f2400000-f2420000

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:148 errors:0 dropped:0 overruns:0 frame:0
          TX packets:148 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1
          RX bytes:21549 (21.5 KB)  TX bytes:21549 (21.5 KB)

virbr0    Link encap:Ethernet  HWaddr 46:41:6e:87:64:74 
          inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.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:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

Example 2:
root@linuxforfreshers.com:~$ ifconfig -a | sed 's/[ \t].*//;/^$/d'
eth0
lo
virbr0

Method 3:
Usinf sys.
Example:
root@linuxforfreshers.com:~$ ls /sys/class/net/
eth0  lo  virbr0
 Method 4:
Using basename
Example :
root@linuxforfreshers.com:~$ basename -a /sys/class/net/*
eth0
lo
virbr0