LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 01-10-2015, 07:03 PM   #1
jzoudavy
Member
 
Registered: Apr 2012
Distribution: Ubuntu, SUSE, Redhat
Posts: 180

Rep: Reputation: Disabled
how to find out what subnet my eth belongs to


Hi all

I got this interesting problem:

I have a server that has two ethernet connections, cabled up to the switch.

The server has a clonezilla liveboot cd in it which I am currently booting from. The clonezilla is a debian OS.

So from the cmd line I can see I have two eth interfaces that is connected, eth0 and 2.

Now I need to configure one of these two interfaces to do let clonezilla do its job.

The problem is that each of these two interfaces are going to different subnets. I got the two subnets, which we will just call them A and B. And I can't recall whether A belongs on eth0 or B belongs there.

Now I know there is a simple solution to this: config one and try it out. I could do that, in fact I will do that just to save time. But I was wondering, cause when I did ifconfig I can see from the packet counters that these two interfaces are live, if there is some other way to monitor these two interfaces, and by looking at the packets that is being sent to these interfaces, I can determine which interface goes with which subnet?

Or phrased another way: you just installed a new computer, and have plugged in the internet cable, but you forgot to put an IP address on it and really don't want to wait for your IT guy to come in on monday to tell you what your IP is and dhcp is not an option. What do you do?

Thanks
Feel free to ask questions if anything is not clear.
 
Old 01-10-2015, 08:57 PM   #2
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Debian, Mageia, and whatever VMs I happen to be playing with
Posts: 11,685
Blog Entries: 12

Rep: Reputation: 2903Reputation: 2903Reputation: 2903Reputation: 2903Reputation: 2903Reputation: 2903Reputation: 2903Reputation: 2903Reputation: 2903Reputation: 2903Reputation: 2903
You can determine the subnet for a connection from the IP address. How exactly to do so depends on whether it's a Class A, Class B, or Class C network. For example, in a typical home network with a 192.168.x.xxx address, 192.168.1.xxx is a different subnet from 192.168.2.xxx.

Quote:
And I can't recall whether A belongs on eth0 or B belongs there.
Does it matter which one you use? If this is a work network, that sounds like a question for a network administrator.

Last edited by frankbell; 01-10-2015 at 09:01 PM.
 
Old 01-11-2015, 06:10 AM   #3
jzoudavy
Member
 
Registered: Apr 2012
Distribution: Ubuntu, SUSE, Redhat
Posts: 180

Original Poster
Rep: Reputation: Disabled
yes it does belong to the net admin, but say if the network admin is not available then what could be done? I meant this question more as a theoretical discussion.
 
Old 01-11-2015, 06:47 AM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,654

Rep: Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255
Irrelevent to the class distinctions, it depends on the netmasks assigned.

These are what defines the networks. Using IPv4 (still the useual, and is much easier to write), the following is how you determine the networks in use:

Code:
what it is          an example
IP number          192.168.0.5
netmask            255.255.0.0
logical and       ============
the network number 192.168.0.0
The above example uses the default netmask for a class C net. It allows 16k hosts. The networks shown is one of the non-routable networks, and is usually used for either standalone networks or put behind a router that performs network address translation.

This network can be used to "subnet" in that the netmask defines a different network:
Code:
what it is          an example
IP number          192.168.000.5
netmask            255.255.255.0
logical and       ==============
the network number 192.168.000.0
Note how the network number stayed the same - but also note, this only allows that network to have 253 usable addresses (0 and 255 are predefined, 0 is the network number, 255 is the broadcast address).

There are now 256 different networks that can be used (each with the 253 usable addresses).

So if a second network interface were given 192.168.1.1, then its network would be:

Code:
IP number          192.168.  1.1
netmask            255.255.255.0
logical and       ==============
the network number 192.168.  1.0
So the network address would be 192.168.1.0, which is a different network from 192.168.0.0.

Had we used the default netmask (255.255.0.0), then both addresses would be on the same network.

Using netmasks to define the network allows the kernel to route an packet to the appropriate interface to reach a given IP number.

It also requires all hosts within the network to use the same netmasks, or packets will get misrouted. It is less noticeable when there is only one interface, but it can still happen that it gets a "no route to host" when the netmask is wrong.

The non-routing addresses (also called "private" networks) are:
Code:
Class 	Private Networks 	Subnet Mask 	Address Range
A 	10.0.0.0 	        255.0.0.0 	10.0.0.0 - 10.255.255.255
B 	172.16.0.0 - 172.31.0.0 255.240.0.0 	172.16.0.0 - 172.31.255.255
C 	192.168.0.0 	        255.255.0.0 	192.168.0.0 - 192.168.255.255
reference:http://vlsm-calc.net/ipclasses.php

Originally, these were intended for stand alone internal networks used for testing systems to be installed in a nearly final configuration. Only the routeable addresses would need to be set.

Last edited by jpollard; 01-11-2015 at 06:56 AM.
 
Old 01-11-2015, 07:54 AM   #5
vincix
Member
 
Registered: Feb 2011
Distribution: Centos 6.7, 7
Posts: 556

Rep: Reputation: 52
I don't think the OP has even said that he couldn't compute subnets, he only wants to know where the interfaces belong.

You could try tcpdump -i eth0 (or whatever interfaces you want to try it on), but I don't think it will be very successful if it's not configured. But you do know exactly the subnets and netmasks of these networks, right? (including the gateways) If you do, I think the shortest way to do it is trying the configure it (one at a time would be advisable) and then simply try to ping in both subnets and see which one works.

Last edited by vincix; 01-11-2015 at 07:55 AM.
 
Old 01-11-2015, 08:01 AM   #6
jzoudavy
Member
 
Registered: Apr 2012
Distribution: Ubuntu, SUSE, Redhat
Posts: 180

Original Poster
Rep: Reputation: Disabled
@vincix

that's what i ended up doing. I was just curious what alternatives exist to possibly find out. Because when I did ifconfig eth0, I could see that the interface is seeing traffic. The TX/RX counters are climbing. So I thought there must be a way to analyze what's being sent to the interface and from that try to determine the networking information for this interface.
 
Old 01-11-2015, 08:13 AM   #7
vincix
Member
 
Registered: Feb 2011
Distribution: Centos 6.7, 7
Posts: 556

Rep: Reputation: 52
Correct me if I'm wrong, but I think that what was sent was on a Level 2 OSI (Data link level), as the L3 (Network level) IP wasn't configured.

But perhaps you might find some L3 packages if you monitor your interface even if it doesn't have an IP (I'll try to work it out somehow, because I think this is important to know) from various L3 (or higher) protocols of various stations on the respective subnets. Even if these packages are dropped, they should show up on a monitoring tool.

On the other hand, when the interface isn't configured, if I'm not mistaken, Linux also assigns a default IP (like in Windows, I think, 169.254.0.0/16).

[later edit]
Ok, I've searched a little bit, and you can definitely use tcpdump in order to see broadcasts, arp, whatever, regardless of whether you've configured your IP address. So that's a good tool to use. The problem is that it's rather hard to find out what the exact netmask is. One solution would be to infer it from the IPs that you see there (how high they go) or if you see dhcp messages, then that would carry a netmask too (and all the necessary information). So that's definitely a good solution. You could try it out in a simulated environment (or today, before the admin arrives!!)

Last edited by vincix; 01-11-2015 at 08:20 AM.
 
Old 01-11-2015, 10:03 AM   #8
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,654

Rep: Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255
Even in a single network interface, there can be two or more logical networks on the cable, depending on whether a switch or a hup is being used.

And if traffic is being seen, then it is already configured...

ahh well, either way.

Last edited by jpollard; 01-11-2015 at 10:05 AM.
 
  


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
how to find out which eth0 or eth1 does card belongs g_paschoal Linux - Networking 5 06-15-2011 02:41 PM
Check if IP belongs to subnet krizzz Programming 2 06-11-2007 07:35 PM
Looking for a way to find a PID and kill the process it belongs to johngreenwood Programming 6 01-14-2007 06:45 AM
securing samba to a particular subnet or eth device? evank Linux - Networking 3 12-22-2006 10:00 AM
Where to find to whom an ip belongs to ? juanb Linux - Security 4 10-24-2004 03:56 PM


All times are GMT -5. The time now is 10:30 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