netinfo - Read Network & PC Information into a Local Text File

So please_try_again, I installed links and run your script and it worked like a champ. I had neither program loaded by default and so one had to be installed. I must ask though, what name did you intend for your program? We need to let others know what you called it. Did you know I have a script file called nsf - New Script File, that takes care of a lot of this stuff for you. You just open up terminal, type nsf scriptname and your favorite text editor comes up, the header is made and when you save it, it is made executable. You are brilliant and way above the rest, but keep us more simple minded people in your thoughts here. Here is the location of nsf should you have missed it:

N.S.F. - New Script File Header Creator

So, I used nsf and called your program ipcheck, for lack of a better name at the time. Copy and past the following text into your favorite text editor and save it as the file ipcheck in your home area bin folder (~/bin/ipcheck):

#!/bin/bash

#: Title       : /home/james/bin/ipcheck
#: Date Created: Wed Oct 13 17:17:14 CDT 2010
#: Last Edit   : Wed Oct 13 17:20:00 CDT 2010
#: Author      : please_try_again
#: Version     : 1.00
#: Description : Find Internet IP Address & Check for being Blacklisted
#: Options     : no options required

# Written for the openSUSE forums on October 13, 2010

# Save file as the file ipcheck in your home bin folder (~/bin)
# Run the following terminal command to make it executable: chmod +x ~/bin/ipcheck

#
# Open YaST / Software Manager & Search on links and install this WWW Text Based Broweser
#

# Text browser, either links or lynx
TBrowser=links

# Preferred web browser
GBrowser=firefox

# read your Internet IP fron this site 
TestSite=http://ipinfo.info/html/my_ip_address.php

# Check if the IP is blacklisted by the honeypot project
honeypot=http://www.projecthoneypot.org/ip

ip=${1:-$($TBrowser -dump $TestSite | sed -n 's|^0-9]*\([1-9][0-9.]*\).*|\1|p')}

$TBrowser -dump  ${honeypot}_$ip | grep -q "We don't have data on this IP currently" && exec echo "Ip $ip is not blacklisted"
read -p "Ip $ip is currently blacklisted. See more info in webbrowser? [y|n]" YesNo
echo

 "$YesNo" == "y" -o "$YesNo" == "Y" ] && exec $GBrowser ${honeypot}_$ip

exit 0
# End Of Script


After you save the script file, open up a terminal session and run the following command:

chmod +x ~/bin/ipcheck

Once the script file is executable, if you have not already done so, run YaST / Software Management and search on the program links, a text based WWW browser. Find and load this program. Once loaded, now you can open up a terminal session and type in the command ipcheck, with no run time options. You now know your online/internet IP address, given to you by your ISP and if you have been blacklisted. Presumably, if you are blacklisted, this would be bad.

Thank You,

Hi James,
I don’t know. ipcheck sounds familiar. There must be (at least) one program with that name already. I called it ‘blip’ (from ‘blacklisted ip’) for my personal use. But feel free to call it as you like. I added 2 other ‘ipcheck’ sites in case the first one doesn’t respond.


#!/bin/bash

#: Title       : ipcheck
#: Date Created: Wed Oct 13 17:17:14 CDT 2010
#: Last Edit   : Wed Oct 13 17:06:51 PDT 2010
#: Author      : please_try_again
#: Version     : 1.00
#: Description : Find Internet IP Address & Check for being Blacklisted
#: Options     : no options required

# Written for the openSUSE forums on October 13, 2010

# Save file as the file ipcheck in your home bin folder (~/bin)
# Run the following terminal command to make it executable: chmod +x ~/bin/ipcheck

#
# Open YaST / Software Manager & Search on links and install this WWW Text Based Browser
#

# Text browser, either links or lynx
TBrowser=links

# Preferred web browser
GBrowser=firefox

# read your Internet IP from one of this site 
TestSite[0]=http://checkip.dyndns.com
TestSite[1]=http://ipcheck.org
TestSite[2]=http://ipinfo.info/html/my_ip_address.php

# Check if the IP is blacklisted by the honeypot project
honeypot=http://www.projecthoneypot.org/ip

# get your internet ip 

if [ "$1" ] ; then
	ip=$1
else
	for t in ${TestSite[li]} ; do[/li]		ip=`$TBrowser -dump $t 2>/dev/null | sed -n 's|[^0-9]*\([1-9][0-9.]*\).*|\1|p' | head -1`
		[ "$ip" ] && break	
	done
fi

$TBrowser -dump  ${honeypot}_$ip | grep -q "We don't have data on this IP currently" && exec echo "Ip $ip is not blacklisted"
read -N 1 -p "Ip $ip is currently blacklisted. See more info in webbrowser? [y|n]" YesNo
echo

[ "$YesNo" == "y" -o "$YesNo" == "Y" ] && exec $GBrowser ${honeypot}_$ip
exit 0

You can use it with an IP as argument to check if a Windows-using friend got a spambot and has been blacklisted.

Here’s an example with a blacklisted ip:
ipcheck 92.90.21.4

  • read -N 1 in this script requires bash 4.x.

OK, so we call it blip then. Copy and paste the following text in the code block into your favorite text editor and save it as the file blip in your home area bin folder (~/bin/blip)

#!/bin/bash

#: Title       : blip - Black List & Internet Protocol Checker
#: Date Created: Wed Oct 13 17:17:14 CDT 2010
#: Last Edit   : Wed Oct 13 19:45:41 CDT 2010
#: Author      : please_try_again
#: Version     : 1.01
#: Description : Find Internet IP Address & Check for being Blacklisted or optionaly check external ip for being blcklisted
#: Options     : blip [internet ip address]

# Written for the openSUSE forums on October 13, 2010

# Save file as the file blip in your home bin folder (~/bin)
# Run the following terminal command to make it executable: chmod +x ~/bin/blip

#
# Open YaST / Software Manager & Search on links and install this WWW Text Based Browser
#

# Text browser, either links or lynx
TBrowser=links

# Preferred web browser
GBrowser=firefox

# read your Internet IP from one of this site 
TestSite[0]=http://checkip.dyndns.com
TestSite[1]=http://ipcheck.org
TestSite[2]=http://ipinfo.info/html/my_ip_address.php

# Check if the IP is blacklisted by the honeypot project
honeypot=http://www.projecthoneypot.org/ip

# get your internet ip 

if [ "$1" ] ; then
    ip=$1
else
    for t in ${TestSite
[li]} ; do[/li]        ip=`$TBrowser -dump $t 2>/dev/null | sed -n 's|[^0-9]*\([1-9][0-9.]*\).*|\1|p' | head -1`
        [ "$ip" ] && break    
    done
fi

$TBrowser -dump  ${honeypot}_$ip | grep -q "We don't have data on this IP currently" && exec echo "Ip $ip is not blacklisted"
read -N 1 -p "Ip $ip is currently blacklisted. See more info in webbrowser? [y|n]" YesNo
echo

[ "$YesNo" == "y" -o "$YesNo" == "Y" ] && exec $GBrowser ${honeypot}_$ip

exit 0
# End Of Script

To make the file executable run the following command:

chmod +x ~/bin/blip

In order to use blip, you need the www terminal text browser links installed. Open up YaST / Software Management and search for links. When found, install it and exit YaST. To use blip, type the following terminal command:

blip [xxx.xxx.xxx.xxx]

blip requires no command line option to provide your internet IP address and if you have been blacklisted. If you provide an internet IP address, you can check if this address has been blacklisted.

Thank You,

Looks like you also try to help the Linux community in the network configuration area and all the problems which may pop up :wink:

Looks like you also try to help the Linux community in the network configuration area and all the problems which may pop up :wink:
Yes framp I do try to help out with everything I can. It does seem that I am not smart enough most of the time however. If I have the right hardware to test with, I can do it, but otherwise it is often just a guess.

Thank You,

I have updated netinfo to version 1.20. The text display function has been updated to the same as is in mmcheck. I also added a warning concerning the data that netinfo captures about your wireless connection. Please edit out your wireless password and name before you post this information online.

To use netinfo copy and paste the following code text as the file netinfo into your home area bin folder ( ~/bin/netinfo).

#!/bin/bash

#: Title       : netinfo
#: Date Created: Jun-03-2009
#: Last Edit   : Sat Nov 13 11:26:32 CDT 2010
#: Author      : nixCraft, Edited by j. McDaniel
#: Version     : 1.20
#: Description : Reads Network & PC Info into a Text File
#: Options     : None, Start netinfo as a Standard User

# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# -------------------------------------------------------------------------

# Modified for use on the openSUSE Forums on November 13, 2010

# Copy and paste this text as the file netinfo into the ~/bin folder.
# Run the terminal command: chmod +x ~/bin/netinfo, to make the file executable
# Open up a terminal session and type: netinfo, to start the program

#
# Location to put information File, Save Home Area Before Becoming Root
#

DOC=~/Documents

#
# Check to see if we are root, Do not run as root since we need save the USER name.
#

tput clear
if  $UID -ne 0 ]]; then
  echo "Root User Permissions are required, Please Enter the ..."
  echo
  sudo $0 $DOC $USER
  exit 0
fi

#Display One or More Line(s) with different foreground and background colors
# $1=foreground color $2=background color 
# $3=Number of Lines to Display 
# $4 and higher are lines text to display

function print_color {
  fgrd=$1
  bgrd=$2
  maxnum=$3
  counter=1
  tput bold
  tput setf $(( fgrd ))
  tput setb $(( bgrd ))
  while  $(( counter )) -lt $(( maxnum + 1 )) ] ; do
    echo "$4"
    let counter=counter+1
    shift
  done
  tput sgr0
  echo
}

print_color 7 2 1 "netinfo 1.20 - Read Network & PC Information into a Text File for Later Review. "

DOC=$1
OWNER=$2
HWINF=/usr/sbin/hwinfo
IFCFG=/sbin/ifconfig
IP4FW=/usr/sbin/iptables
IP6FW=/usr/sbin/ip6tables
LSPCI=/sbin/lspci
ROUTE=/sbin/route
NETSTAT=/bin/netstat
LSB=/usr/bin/lsb_release
 
## files ##
DNSCLIENT="/etc/resolv.conf"
NETCFC="/etc/sysconfig/network/ifcfg-eth?"
SYSCTL="/etc/sysctl.conf"
 
## Output file ##
OUTPUT=$DOC"/network.$(date +'%d-%m-%y').info.txt"
 
## Email info to?? ##
SUPPORT_ID="you@example.com"
 
chk_root(){
    local meid=$(id -u)
    if  $meid -ne 0 ];
    then
        echo "You must be root user to run this tool"
        exit 999
    fi
}
 
write_header(){
    echo "---------------------------------------------------" >> $OUTPUT
    echo "$@" >> $OUTPUT
    echo "---------------------------------------------------"  >> $OUTPUT
}
 
dump_info(){
    echo "* Hostname: $(hostname)" >$OUTPUT
    echo "* Run date and time: $(date)" >>$OUTPUT
 
    write_header "Linux Distro"
    echo "Linux kernel: $(uname -mrs)" >>$OUTPUT
    $LSB -a >> $OUTPUT    
 
     -x ${HWINF} ] && write_header "${HWINF} --network_ctrl"
     -x ${HWINF} ] && ${HWINF} --network_ctrl >> $OUTPUT
 
     -x ${HWINF} ] && write_header "${HWINF} --isapnp"
     -x ${HWINF} ] && ${HWINF} --isapnp >> $OUTPUT
 
    write_header "PCI Devices"
    ${LSPCI} -v >> $OUTPUT
 
    write_header "$IFCFG Output"
    $IFCFG >> $OUTPUT
 
    write_header "Kernel Routing Table"
    $ROUTE -n >> $OUTPUT
 
    write_header "DNS Client $DNSCLIENT Configuration"
     -f $DNSCLIENT ] && cat $DNSCLIENT >> $OUTPUT || echo "Error $DNSCLIENT file not found." >> $OUTPUT
 
    write_header "Network Configuration File"
    for f in $NETCFC
    do
        if  -f $f ]
        then
            echo "** $f **" >> $OUTPUT
            cat $f >> $OUTPUT
        else
            echo "Error $f not found." >> $OUTPUT
        fi
    done 
 
    write_header "IP4 Firewall Configuration"
    $IP4FW -L -n >> $OUTPUT
 
    write_header "IP6 Firewall Configuration"
    $IP6FW -L -n  >> $OUTPUT
 
    write_header "Network Stats"
    $NETSTAT -s >> $OUTPUT
 
    write_header "Network Tweaks via $SYSCTL"
     -f $SYSCTL ] && cat $SYSCTL >> $OUTPUT || echo "Error $SYSCTL not found." >>$OUTPUT
 
#
# Change Owner of Text File from root to User
#    
    chown $OWNER:users $OUTPUT

#
# Display Information about Using the Less command to view Text Fie
#

    l1="Your Network and PC Information Text File Has Been Created.  Your Text File will"
    l2="be loaded for viewing using the Less command..........Just Press Q to Quit Less."
        l3=""
        l4="Be careful in posting the information contained in this text file as your wireless"
        l5="Passwords and other private information will be contained within.  Please edit out"
        l6="this informatiuon before placing this text online for others to see, Thank You...."
    print_color 7 4 6 "$l1" "$l2" "$l3" "$l4" "$l5" "$l6"
        read -p "Please Press <enter> to continue..."

    less $OUTPUT

        l1=""
    l2="Your Network Configuration Info was Written To the Text file: "
        l3=""
    l4="---->  $OUTPUT   <----"
    print_color 7 1 4 "$l1" "$l2" "$l3" "$l4"
    read -p "Please Press <enter> to continue..."
}
 
chk_root
dump_info

exit 0
# End Of Script


Run the terminal command:

chmod +x ~/bin/netinfo, 

… to make the file executable.

To use netinfo open up a terminal session and type:

netinfo

… to start the program.

Thank You,

Thanks for the work on netinfo and blip. I added --line-numbers -v to the iptables command that will number lines, display number of packets and bytes through each rule.

Thanks for the work on netinfo and blip. I added --line-numbers -v to the iptables command that will number lines, display number of packets and bytes through each rule.
Sounds like a good thing. Can you post your patch or the whole thing or however you would like to do it and we will add it to the main script.

Thank You,