Thứ Năm, 25 tháng 4, 2013

Tìm IP ngoài từ command line




Lately, I was configuring Nagios and most of the systems were on the same private IP block as the Nagios server. One of the servers was outside the LAN and I was using the allowed_hosts directive for nrpe daemons where I needed to put the external IP of Nagios server in nrpe configuration of the outside host. I fiddled with elinks and it did not work which was a bit of frustration.

I thought about pinging the external host and capturing the icmp packets with tcpdump and many other ways came to mind. It turned out that I can find the external IP more easily using some of these ways.
The easiest way is to use is to use curl
curl www.whatismyip.org
Another way is to use wget by directing the output of standard output and sending the error messages to /dev/null
wget http://www.whatismyip.org -O - -o /dev/null
or if I wanted clearer output, I could use wget this way
wget -q -O - checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'
I could use elinks with checkip.dyndns.org and not with whatismyip.com
elinks checkip.dyndns.org
An additional tip. If you want to find all the IPs assigned to a system, the following gives you what you want
ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}
Hope this helps

Không có nhận xét nào:

Đăng nhận xét

ASTPP VoIP Billing v3.6 CentOS v7 Freeswitch v1.6 Apache Install Guide

This guide covers the installation of the ASTPP VoIP billing and Freeswitch applications.  ASTPP is installed manually from ...