Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I have a question about IP address and subnet mask.
My understanding is each IP address has netid part and hostid part. The netid part is used for routing efficiently.
For example: an IP address 126.96.36.199 with a netmask 255.255.255.0, (ie /24 ) has a subnet number of 188.8.131.52, and there can be 2^8-2 = 254 hosts in this system.
But, for the same IP address, if I want to divide the 254 hosts into 8 subnets, what should I do? Change the subnet mask? How do I know they are in different subnets?
Furthermore, I read in a book said:
“When you divide a class C address 184.108.40.206 into eight subnets, you get a subnet mask of 255.255.255.224 (27 1s). The eight resultant network are 220.127.116.11, 18.104.22.168, 22.214.171.124, 126.96.36.199, 188.8.131.52, 184.108.40.206, 220.127.116.11, and 18.104.22.168”
I understand 224 is 27 1s. But I don’t know where 224 comes from. Also, I thought hosts in a subnet has a range of IP address. For exmaple, 22.214.171.124-126.96.36.199 are in the first subnet. But how can the routers between the subnets know?
I’m really confused with these concepts. Please advise.
Distribution: RedHat (RHEL, FC, CentOS), openSuSE, Mac OS X
8 subnets, so sections of 32 each 2*2*2*2*2 or 2^5 -> 32-5 = 27
OR alternatively 256(total addresses)-32(desired addresses) = 224
That said if you want 15 addresses you can't go 256-15 = 241 -> 255.255.255.241
Or if you have a CIDR table handy
CIDR Dec Netmask Hex Netmask No of IP addresses
/27 255.255.255.224 0xFFFFFFE0 32
so your networks are:
188.8.131.52/27 which is the exact same as 184.108.40.206/255.255.255.224 *
* well not exactly the same - hosts.allow understands the long form, but not the short form. On that note, don't specify individual IPs in your hosts.allow (or deny) as 220.127.116.11/255.255.255.255 cause that will be ignored/not matched.
Each of those CIDR notations are a range, not a single address. Or they are a network address block, which is a range. The routers between the subnet can know by a number of means: Vlans are one popular mean though i'm not sure what deeper explanation you might need there.
in a Vlan setup your system tags each packet so the router knows that the source is part of a vlan, and based on this can route it. Unless you have a complex setup though, vlans might not be the way to go. If you use a firewall you can restrict access of your network blocks to each other in the router and not bring vlan's into it. Vlans offer enhanced security (as potential targets are not part of the Vlan so they won't respond to the packets as said target knows to ignore them), but this can be subverted by the router due to making a port tagged or untagged. but again, this gets complex and unless you need to know there is little point in telling you, and i'm sure wikipedia will do a better job.
Distribution: RedHat (RHEL, FC, CentOS), openSuSE, Mac OS X
well CIDR is based on 2 to the power of 32 = 4294967296
this is the same as 256*256*256*256 ... each section of the netmask can be 0 - 255 (or 0x00 to 0xFF) in other words 256 values, so total potential number of IP addresses is that long number with 4 at the start.
CIDR does not care about the number of hosts, in fact it completely ignores that aspect of it. It can be used to denote a range of IPs which are all hosts (say in a firewall) or a subsection of a network. In the case of the network subset, it may or may not include all sorts of non host usable IPs such as Base IP, Gateway, Broadcast, HSRP interfaces, Router Management IP etc.
so really you have not 254 hosts but 256 IPs. 256 / 32 = 8. Or 8 equal sized network segments out of 256 potential IP addresses gives 32.
CIDR uses a starting point of /32 meaning one IP address only, each step towards 0 means double the IPs, so /31 is 2; /30 is 4; /29 is 8; /28 is 16; and /27 is 32.
An easier way to derive this, rather than counting backwards, is to take the 32 (number of IPs) and work out 2 to the power of what = 32. (2^x=32) so the value in question (x) is 5. To then work out what you CIDR mask for this would be is 32 (base CIDR value of one IP) and reduce that by x -> 27 so /27 (CIDR) gives 32 IP addresses.
So in other words, if you are doing your network split instead of 254 host usable IP address; you end up with 240 host usable IP addresses only.
oh, and one other things, say we have 192.168.5.16/27 - that would mean 192.168.5.16-192.168.5.48; but depending on the place you use it, it may mean something else; for instance most routers will interpret that as meaning you want the /27 block of the 192.168.5.0/24 address range, which will contain .16 and interpret that as 192.168.5.0/27 instead;
If you used this in a firewall on the other hand, it might be legal and mean 16-48 instead (i'm really not sure, i've not come across that, but firewalls generally interpret it as a range, and don't give the bounds special meaning as a router would). To be safe that this is interpreted as the range, you'd probably have a group of 192.168.5.16/28 and 192.168.5.32/28 which would not confuse a firewall, but would mean something completely different to a router.
I realize that this is all a bit confusing and probably more info than you wanted, but just know it's based on Y = 2 to the power of X; and then 32 - X is the notation that gives you Y addresses. As long as you know X or Y you'll be fine.