Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Linux \ How to find an IP address through the command line     - Oracle bug Ora-04043 (Database)

- In Spring AOP example explanation (Programming)

- Linux startup and logon security settings (Linux)

- When a software RAID data recovery and reconstruction of how failure (Linux)

- Elixir: the future of programming languages (Programming)

- ImportTsv-HBase data import tool (Database)

- IntelliJ IDEA run in Mac10.9 and JDK7 environment (Linux)

- Install snort intrusion detection system on Debian (Linux)

- SYN attack hacker attack and defense of the basic principles and prevention technology (Linux)

- Install the latest Pinta graphics editing software on Ubuntu 14.04 (Linux)

- Linux console password solution (Programming)

- Swift notes - let you two hours to learn Swift (Programming)

- C language keywords Comments (Programming)

- To install Xen in Ubuntu 12.04 (Linux)

- Create your own YUM repository (Linux)

- Linux administrator should command: sed and awk (Linux)

- Iptables principle (Linux)

- RHEL6.4 x86_64 build SVN service (Server)

- Linux dd command make U disk boot disk (Linux)

- Basic Tutorial: Linux novice should know 26 commands (Linux)

  How to find an IP address through the command line
  Add Date : 2018-11-21      
  If you want to find an IP address on the actual physical location on Earth, there are now a lot of online GeoIp lookup services you can take advantage of (eg geoiptool.com). Most of these online services are supported by free GeoIP databases like MaxMind. While using these web-based services, there are a number of different ways to query the GeoIP database, especially the Linux command line.

In this tutorial, I want to show you how to get the actual location of the IP address from the Linux command line.

method one

The first method is to use the geoiplookup tool, which is a command-line client for querying MaxMind's GeoIP database. Geoiplookup allows you to query an IP address (or domain name) of the geographical information or network information. You can install it with the following command (it comes with a free GeoIP database).

Install geoiplookup on Debian, Ubuntu, or Linux Mint:

Sudo apt-get install geoip-bin

Installing on Fedora:

Sudo yum install geoip

To install on CentOS, you first need to open the EPEL source, and then use the yum command:

Sudo yum install geoip

The geoiplookup and GeoIP.dat database files that are installed by default are located in / usr / share / GeoIP. This database can only query the country information.


GeoIP Country Edition: US, United States

You can download the additional GeoIP database from MaxMind, which will tell you more information than just the country. You can also download many of the latest GeoIP.dat databases from this site. I recommend you do this because GeoIP.dat installed from a Linux source may be out of date. The GeoIP database on MaxMind is updated monthly.

To install the GeoIP database from MaxMind, do the following. You may want to add a cronjob (crontab task, which is a Unix and Unix-like system for the periodic execution of tasks, annotations) to automate this process.

Wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
Wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
Wget http://download.maxmind.com/download/geoip/database/asnum/GeoIPASNum.dat.gz
Gunzip GeoIP.dat.gz
Gunzip GeoIPASNum.dat.gz
Gunzip GeoLiteCity.dat.gz
Sudo cp GeoIP.dat GeoIPASNum.dat GeoLiteCity.dat / usr / share / GeoIP /

Now if you re-run geoiplookup, you will see additional AS number information. This will give you a rough idea of which administrative domain the IP address belongs to.


GeoIP Country Edition: US, United States
GeoIP ASNum Edition: AS88 Princeton University

If you run the command without any parameters, the geoiplookup tool will only use GeoIP.dat and GeoIPASNum.dat automatically, instead of GeoLiteCity.dat. The following will teach you to view the city-level information.

To get the geo-location information at the city level, you need to explicitly tell the geoiplookup to use the GeoLiteCity.dat database.

Geoiplookup -f /usr/share/GeoIP/GeoLiteCity.dat

GeoIP City Edition, Rev 1: US, MA, Cambridge, 02142, 42.362598, -71.084297, 506, 617

Outputs include states, cities, postal codes, latitude, and longitude. The accuracy of the indicated country and network addresses varies from place to place. For example, the broadband IP address of the geographical location information than the mobile network accuracy.

Method two

If you want to remove the trouble of installing and upgrading the GeoIP database, you can try the ipinfo.io online service. Unlike other services, ipinfo.io provides a JSON-based geographic information API, so you can easily get geographic information on the command line using tools like curl.

Curl ipinfo.io/

It is important to note that their API limits up to 1,000 requests per day.

How to set up EPEL repository on CentOS

If you are using CentOS or RHEL, it is strongly recommended that you configure EPEL (Extra Packages for Enterprise Linux) repository on your system. EPEL is a community effort to create a repository of high-quality add-on freeware packages for RHEL-based Distributions. Once you set up EPEL repository, you can use yum command to install any of close to 7,000 EPEL packages.

In order to enable EPEL repository on your CentOS system, you need to check CentOS version. To do that, run the following command.

$ Cat / etc / RedHat-release
CentOS release 6.3 (Final)
Then install an EPEL repository rpm file as follows. Note that the rpm file does not depend on the underlying processor architecture (eg, 32-bit / 64-bit x86, ppc, sparc, alpha, etc), so no need to pay attention To processor architecture difference.

For CentOS 5. *:

$ Sudo rpm -Uvh http://mirrors.kernel.org/Fedora-epel/5/i386/epel-release-5-4.noarch.rpm
For CentOS 6. *:

$ Sudo rpm -Uvh http://mirrors.kernel.org/fedora-epel/6/i386/epel-release-6-8.noarch.rpm

To verify that EPEL yum repository has been set up successfully, run the following command to list all available repositories on your system.

$ Yum repolist
Repo id repo name status
Base CentOS-6 - Base 4,776
Epel Extra Packages for Enterprise Linux 6 - i386 6,913
Extras CentOS-6 - Extras 17
Updates CentOS-6 - Updates 960
Repolist: 12,666
- Database Blob data type conversion String (Programming)
- Single Instance ASM under CRS-4124, CRS-4000 error handling (Database)
- CentOS 7 repair MBR and GRUB (Linux)
- Use smartmontools view the health status of hard disk (Linux)
- Timeout control related to Python threads and a simple application (Programming)
- Usage sed some of the parameters (Linux)
- Linux crontab commands and detailed usage examples (Linux)
- The Samba service does not have permission to access (Server)
- Several Ceph performance optimization of new methods and ideas (2015 SH Ceph Day after flu reference) (Server)
- CentOS 7 install Hadoop-cdh-2.5 on Mesos (Server)
- Linux security settings Notes (Linux)
- Service manager OpenBSD on rccl (Server)
- MySQL appears data too long for column 'name' at row 1 to solve (Database)
- Improve WordPress performance (Server)
- Linux itself disguised illusion strengthen security (Linux)
- Linux User Management (Linux)
- Spring + Log4j + ActiveMQ remote logging - Analysis of combat (Server)
- PXE install CentOS 6.4 (Linux)
- MySQL InnoDB table --BTree basic data structures (Database)
- Oracle utilized undo data recovery operations (Database)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.