Book Image

Openswan: Building and Integrating Virtual Private Networks

By : Ken Bantoft, Paul Wouters
Book Image

Openswan: Building and Integrating Virtual Private Networks

By: Ken Bantoft, Paul Wouters

Overview of this book

<p>With the widespread use of wireless and the integration of VPN capabilities in most modern laptops, PDA's and mobile phones, there is a growing desire for encrypting more and more communications to prevent eavesdropping. Can you trust the coffee shop's wireless network? Is your neighbor watching your wireless? Or are your competitors perhaps engaged in industrial espionage? Do you need to send information back to your office while on the road or on board a ship? Or do you just want to securely access your MP3's at home? IPsec is the industry standard for encrypted communication, and Openswan is the de-facto implementation of IPsec for Linux.</p> <p>Whether you are just connecting your home DSL connection with your laptop when you're on the road to access your files at home, or you are building an industry size, military strength VPN infrastructure for a medium to very large organization, this book will assist you in setting up Openswan to suit those needs.</p> <p>The topics discussed range from designing, to building, to configuring Openswan as the VPN gateway to deploy IPsec using Openswan. It not only for Linux clients, but also the more commonly used Operating Systems such as Microsoft Windows and MacOSX. Furthermore it discusses common interoperability examples for third party vendors, such as Cisco, Checkpoint, Netscreen and other common IPsec vendors.</p> <p>The authors bring you first hand information, as they are the official developers of the Openswan code. They have included the latest developments and upcoming issues. With experience in answering questions on a daily basis on the mailing lists since the creation of Openswan, the authors are by far the most experienced in a wide range of successful and not so successful uses of Openswan by people worldwide.</p>
Table of Contents (22 chapters)
Building and Integrating Virtual Private Networks with Openswan
Credits
About the Authors
Acknowledgements
About the Reviewers
Preface

Calculating with Subnets: The Subnet Mask


Because subnets can have different sizes, we need to have a method for hosts to know what they should consider as their subnet. You do not want the host to try and find the host in the local subnet when the host it is trying to talk to is on the other side of the planet. Remember that an IP address is just a 32-bit number. The IP address 193.110.157.77 can be written in bits as 11000001 01101110 10011101 01001101. What do we know about these bits for the subnet that contains all the addresses in 193.110.157.*? Well, we notice that some of the bits, in our case the first 24, are always the same. The last 8 bits change, depending on the number we want that "*" to be, as anything from 0 to 255. This is exactly what the subnet mask (also called the netmask) tells us. It is also a series of 32 bits, but now the bits do not represent a number, but the property of a bit in the IP address.

Note

For each bit in an IP address range that will never change, the corresponding bit in the netmask will be 1. If changing a bit in an IP address would indicate a different host in the same network, the netmask bit corresponding to the address bit would be 0.

Let us visualize this in a table, because it sounds a lot more complex than it really is. Let us write down our IP address, but also the first and last address possible in our subnet. The parts in bold in the table below never change, and are part of the subnet, and thus receive a 1 in the netmask.

IP address

Binary notation

193.110.157.0

1100000101101110 1001110100000000

193.110.157.77

11000001 01101110 10011101 01001101

193.110.157.255

11000001 01101110 10011101 11111111

Netmask

11111111 11111111 11111111 00000000

As expected, the only difference between IP addresses in the 193.110.157.* range are the last 8 bits: the first 24 bits (3 bytes) are always the same. We can also see another property of the netmask. It will always start with 1s and at one (and only one) point, it will switch to zeros. This is because our subnets will always be a continuous set of increasing numbers, e.g. from 0 to 255.

So if we want to describe our IP address and its subnet, we could use the decimal syntax 193.110.157.77/255.255.255.0. This gives us all the information we need. Our host's IP address is 193.110.157.77, and all the IP addresses that fall within 193.110.157.* can be reached directly.

But since sysadmins are inherently lazy, they do not want to write all these netmask numbers every time they need an address. Instead, a shorthand notation is used. For instance, for '255.255.255.0' we count the number of 1s in the netmask, and write that. So, the most common notation for our machine here would be 193.110.157.77/24. If we want to describe the entire subnet instead of a single host in a subnet, we would use the lowest address in that subnet. Our subnet would be written as 193.110.157.0/24. This is called the CIDR notation, the Classless Internet Domain Routing notation.

Let us now see how this works with a second range, often used elsewhere in this book, and go from CIDR to a full network description. The CIDR notation is 205.150.200.223/28. First, we rewrite the full netmask. 28 bits is 8 bits + 8 bits + 8 bits + 4 bits. So we have a netmask of 11111111 11111111 11111111 11110000, which in decimal is 255.255.255.240.

IP address

205.150.200.223

11001101 10010110 11001000 11011111

Netmask

255.255.255.240

11111111 11111111 11111111 11110000

So, the bits in the netmask that are zero are those that can be changed for this subnet. Again, to get the lowest address, we write zeros in the IP address for which the netmask has a zero, which means that bit can be changed. To get the highest address, we write ones in the IP address for which the netmask has a zero.

The following table might help make this clear:

 

IP address

Netmask

IP address AND netmask

Lowest IP

205.150.200.223

11001101 10010110 11001000 11010000

205.150.200.208

Highest IP

205.150.200.223

11001101 10010110 11001000 11011111

205.150.200.223

The lowest address is also called the network address, the highest address is also called the broadcast address, as this is used to send messages that need to reach all the hosts in the subnet. It is important to realize that a netmask does not mean anything on its own; it must be used in conjunction with an actual IP address.