LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-30-2013, 06:42 AM   #1
jknath
LQ Newbie
 
Registered: Oct 2013
Posts: 7

Rep: Reputation: Disabled
IP Address


Hi,

I'm new to linux. I need to know ip address for my pc. I entered "/sbin/ifconfig" in turn i got the same from inet addr: xxx.xxx.x.xxx

Now I need to cross check ip whether really is that my ip address. Plz tell some other command to check ip address. If i put that ip address shown through new command should match the ip address retrieved from "/sbin/ifconfig". Plz guide me.
 
Old 10-30-2013, 06:49 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
cross check? ifconfig will tell you the addresses of all local interface, there's no need to check it with anything else. Maybe you mean somethign different to what you are asking?
 
Old 10-30-2013, 07:34 AM   #3
jknath
LQ Newbie
 
Registered: Oct 2013
Posts: 7

Original Poster
Rep: Reputation: Disabled
IP Address

What im asking is when I put /sbin/ifconfig Im getting the below response.

eth0 Link encap:Ethernet HWaddr 00:17:7C:10:4F:50
inet addr:192.168.2.200 Bcast:192.168.2.255 Mask:255.255.255.0
inet6 addr: fe80::217:7cff:fe10:4f50/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:154835 errors:0 dropped:0 overruns:0 frame:0
TX packets:159843 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:30268603 (28.8 MiB) TX bytes:39755892 (37.9 MiB)
Interrupt:225

I want to cross check whether "inet addr" is my ip or "Bcast" or "Mask" are my ips... If any options apart from this is available means I will check with that command. So help me...
 
Old 10-30-2013, 08:49 AM   #4
rtmistler
Moderator
 
Registered: Mar 2011
Location: Sutton, MA. USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu
Posts: 4,087
Blog Entries: 10

Rep: Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520
Recommend you be careful posting exact outputs of things like addresses, or usernames to the forum. Probably the riskiest thing to post there is your MAC address.

acid_kewpie already answered, however you need some clarification.

Your IP address IS the inet addr. This is the answer to your question.

Your Bcast is the broadcast address for the IP sub-network which you are in.

Your Mask determines the IP sub-network type which you are in.

Class A would have a Mask of 255.0.0.0.
Class B would have a Mask of 255.255.0.0.
Class C would have a Mask of 255.255.255.0

The reason for this is called sub-netting, sort of like phone number areas codes and prefixes. Example two phone numbers:

978-555-1212
408-555-1212

The area codes are different; however the prefixes and the final four numbers are all the same. But these are two different phone numbers. Not sure, but I'm betting that you can have the same area code, prefix, and phone number in different countries where the difference would be the prefix. It really would depend if both countries used the same number of dialing digits.

To extend that further, there is an address translation performed by your router. The router gives out 192.168.2.xxx addresses; however the actual IP address seen publicly is translated by your router. What it really does is multiplexes all addresses on your side of the network through the one address it has on it's externally facing side - the side attached to the broader, more public network.

So consequently, you and I can have the exact same IP address of 192.168.2.200; however mine is within my corporate or home network, and yours is within your local network; and then our routers which attach us to the internet or corporate network use one or more series of address translation (multiplexing) to combine local network users for public access.

Similarly an ISP will do the same thing. They get one or a few public IP addresses for the internet and they create a network underneath that hierarchy and can have any class of network they wish, so long as they use address translation for all their users to allow their sessions to be visible externally to the global internet.
 
1 members found this post helpful.
Old 10-30-2013, 08:56 AM   #5
jknath
LQ Newbie
 
Registered: Oct 2013
Posts: 7

Original Poster
Rep: Reputation: Disabled
IP Address

Thanks for your posts and advices. But you have missed out my point. I need some other command to check my ip. Is there anything apart from /sbin/ifconfig??

Plz clear me.
 
Old 10-30-2013, 09:06 AM   #6
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
Try this:
Code:
ip addr show eth0
Output would look something like this:
Code:
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 20:cf:30:39:bb:20 brd ff:ff:ff:ff:ff:ff
    inet 10.0.100.12/24 brd 10.0.100.255 scope global eth0
    inet6 fe80::22cf:30ff:fe39:bb20/64 scope link 
    valid_lft forever preferred_lft forever
Bold part is your IP address.

BTW: ifconfig is slowly being phased out, ip is its replacement.
 
Old 10-30-2013, 09:12 AM   #7
jknath
LQ Newbie
 
Registered: Oct 2013
Posts: 7

Original Poster
Rep: Reputation: Disabled
IP Address

Hi,

Below error is coming when I entered the command given by u.

[oracle@oraclehost shell]$ ip addr show eth0
-bash: ip: command not found
[oracle@oraclehost shell]$


Plz assist me. Plz give me some other command.
 
Old 10-30-2013, 09:18 AM   #8
rtmistler
Moderator
 
Registered: Mar 2011
Location: Sutton, MA. USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu
Posts: 4,087
Blog Entries: 10

Rep: Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520
What's wrong with ifconfig? Why can't you use that? You were given an alternative and still had a problem. Is this just you asking questions, or are you writing a script or program and needing to obtain your IP address in a particular format?
 
Old 10-30-2013, 09:19 AM   #9
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
@jknath: It seems ip isn't present/installed. Which linux distro and version are you using?
 
Old 10-30-2013, 09:31 AM   #10
jknath
LQ Newbie
 
Registered: Oct 2013
Posts: 7

Original Poster
Rep: Reputation: Disabled
IP Address

No. As im a newbie I had curiosity to cross check. Its a healthy practice to me.

Thats y im asking this much time.

Im ok with ifconfig. But if any command is there means I would be happy.

Sorry for continuously asking.

Thanks
 
Old 10-30-2013, 09:53 AM   #11
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 12,541
Blog Entries: 23

Rep: Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943
Member Response

Hi,

Welcome to LQ!

Look at these links, especially #2,3 ,9 &10 also others will be helpful to investigate;
Quote:
Just a few links to aid you to gaining some understanding;



1 Linux Documentation Project
2 Rute Tutorial & Exposition
3 Linux Command Guide
4 Bash Beginners Guide
5 Bash Reference Manual
6 Advanced Bash-Scripting Guide
7 Linux Newbie Admin Guide
8 LinuxSelfHelp
9
Ultimate Linux Newbie Guide
10 Linux Home Networking
11 Virtualization- Top 10

The above links and others can be found at 'Slackware-Links'. More than just SlackwareŽ links!
Hope this helps.
 
Old 10-30-2013, 09:55 AM   #12
mddnix
Member
 
Registered: Mar 2013
Location: Bengaluru, India
Distribution: Redhat, Arch, Ubuntu
Posts: 498

Rep: Reputation: 137Reputation: 137
Code:
$ /sbin/ifconfig
$ /sbin/ip addr show
$ /bin/hostname -i
$ /usr/bin/dig $(hostname) | grep -iA1 'answer section'
Just incase you want to find external ip address (router):
Code:
$ lynx --dump http://ipecho.net/plain
$ curl http://ipecho.net/plain; echo

Last edited by mddnix; 10-30-2013 at 10:03 AM.
 
1 members found this post helpful.
Old 10-31-2013, 07:08 AM   #13
ntu929
Member
 
Registered: Jun 2010
Location: India
Distribution: Ubuntu
Posts: 128

Rep: Reputation: 4
This may help

http://www.whatismyip.com/linux-ip-commands/

Quote:
Originally Posted by jknath View Post
Hi,

I'm new to linux. I need to know ip address for my pc. I entered "/sbin/ifconfig" in turn i got the same from inet addr: xxx.xxx.x.xxx

Now I need to cross check ip whether really is that my ip address. Plz tell some other command to check ip address. If i put that ip address shown through new command should match the ip address retrieved from "/sbin/ifconfig". Plz guide me.
ntu929
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Program to assign globa lIPv6 address and bind() to the previously assigned address. mwnn Linux - Networking 2 10-07-2010 03:29 AM
Find real ip address using link local address, mdns/zeroconf dannemanare Linux - Networking 0 01-17-2008 05:31 AM
Single DHCP server ,to provide the ip address to a MAC address in two different subne alix123 Linux - Software 5 05-09-2007 12:16 AM
how to get ip address, broadcast address, mac address of a machine sumeshstar Programming 2 03-12-2005 05:33 AM


All times are GMT -5. The time now is 11:01 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration