- Protecting Valuable Resources
- Interfaces: Action-Packed Entities
- Configuring IP Addresses
- Solution Introduction and the Flyweight Pattern
- A Generic Network Link
- A Generic Network Link Context
- A Real Network Link
- The GenericLink Implementation
- The GenericLinkContext Implementation
- The RealLink Implementation
- Bringing the Code Together
- Additional Reading
Configuring IP Addresses
Configuring one or two IP addresses is pretty manageable—we all do this on our own machines. But when you have to attach a range of IP addresses to a set of interfaces, the process can get complex. Let’s assume that you have two links to which you want to attach the following IP address ranges:
- Link 1 supports eight IP addresses from 10.81.1.0 to 10.81.1.7.
- Link 2 supports four IP addresses from 220.127.116.11 to 18.104.22.168.
At this point, you’d have to figure out the IP address ranges and write some scripts to assign them to the interfaces as required. This is our problem definition—how to write some C++ code that will help in automating the assignment of IP addresses to network links.