LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   IP Address (https://www.linuxquestions.org/questions/linux-newbie-8/ip-address-4175482745/)

jknath 10-30-2013 05:42 AM

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.

acid_kewpie 10-30-2013 05:49 AM

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?

jknath 10-30-2013 06:34 AM

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...

rtmistler 10-30-2013 07:49 AM

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.

jknath 10-30-2013 07:56 AM

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.

druuna 10-30-2013 08:06 AM

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.

jknath 10-30-2013 08:12 AM

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.

rtmistler 10-30-2013 08:18 AM

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?

druuna 10-30-2013 08:19 AM

@jknath: It seems ip isn't present/installed. Which linux distro and version are you using?

jknath 10-30-2013 08:31 AM

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

onebuck 10-30-2013 08:53 AM

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.

Madhu Desai 10-30-2013 08:55 AM

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


ntu929 10-31-2013 06:08 AM

This may help
 
http://www.whatismyip.com/linux-ip-commands/

Quote:

Originally Posted by jknath (Post 5055072)
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


All times are GMT -5. The time now is 01:42 AM.