Friday, 7 February 2014

Linux Network NameSpaces


Namespace : A class of elements (e.g. addresses, file locations, etc.) in which each element has a name unique to that class, although it may be shared with elements in other classes. (Definition)

Generally, Linux shares a single set of Network interfaces and routing tables across the entire Operating System. With Networking Namespace, its now possible for each Namespace to have its own routing table and other networking constructs.

Creating a Network Namespace

Listing the Namespace

Executing a command in a Namespace

Adding interfaces to a Namespace

Its not possible to add a physical interface(like eth0) to a Namespace. One needs to create a virtual interface and add it to the Namespace. Virtual interfaces are created in pairs. One of them can be added to the default Namespace and other to the newly created Namespace.

Creating pair of Virtual Interface

Lets create two virtual interfaces "veth0" and "veth_blue". virtual interfaces are created here in the default namespace.

Adding Virtual Interface to a Namespace

This command adds veth0 to Namespace blue, the other pair (veth_blue) is still present in the default namespace

Listing of default Namespace

This commands show the listing of default namespace, veth_blue is still present in the default namespace.

Listing of blue Namespace

veth0 has now moved to the blue Namespace.

Similar setup for Red Namespace

Adding veth0 to red Namespace and its peer (veth_red) remains in the default namespace.

No comments:

Post a Comment