In previous task, you already setup your machine and learned about basic networking in Linux Enterprise. Now, you should try to learn about ip forwarding and network namespace in linux.
Example:
1 VM has 1 interface bridge with static IP
1 VM has 2 interface bridge (1 static IP and 1 DHCP)
IP forwarding, also known as IP routing, is a networking function that allows a computer to receive incoming network packets, analyze them, and then forward them to their intended destination. This is especially useful in network configurations where the Ubuntu system acts as a router or a gateway between two or more networks.
Configure a Namespace Network
Create linux namespace named ns1
ββββββββip netns add ns1
As you can see from here, we've created the linux namespace.
Check the network namespace
ββββββββip -n ns1 link
In this namespace we can see the lo
network in container and can't see the host network due to the namespace isolation.
Configure the veth
peer connectivity
ββββββββip link add tipTest2 type veth peer name br-tipTest2
ββββββββip link set tipTest2 netns ns1
I set the name of veth
of ns1
is tipTest2
and have peer name for the linux bridge connectivity later named br-tipTest2
.
Configure the veth
named tipTest2
attached to ns1
After the veth
is attached to the namespace, we can see that the interface is no longer visible in host. It means the isolation network function is working.
Configure the veth
IP Address and make it running
ββββββββip -n ns1 addr add 192.168.158.9/24 dev tipTest2
ββββββββip -n ns1 link set tipTest2 up
Note that we need to exec
the namespace by -n
option before execute the command. Set the IP static with your internal IP configuration and make sure to change the state to up
, in order to make the veth
is running.
Configure the Linux Bridge
Create linux bridge named brTest2
ββββββββip link add brTest2 type bridge
ββββββββip link set dev brTest2 up
As you can see from here, I've add some configuration to make the new bridge is up and running. And also the new fifth interface is can be seen below.
Configure the brTest2
IP Address and make the running
ββββββββip addr add 192.168.158.10/24 dev brTest2
After we configure the internal IP Address for the bridge. Make sure every interface is up and running.
Configure the bridge named brTest2
attached to peer-veth
which named br-tipTest2
ββββββββip link set tipTest2-br master brTest2
After the br-tipTest2
is attached to the linux bridge, we can see that the interface is properly master
to the brTest2
.
Validate if the namespace can ping bridge
Finally we can connect the interface to the intended namespace network.
Bind Linux Bridge to Physical Interface
Install the debian package for bridge utilization
After that we can use brctl
command.
Bind the linux bridge brTest2
to the pyshical enp0s3
network as a switch
ββββββββip link set br-tipTest2 master brTest2
We can validate the connection to the physical network is by information master brTest
in enp0s8
interface.
Validate if the namespace can ping server side
Configure the Routing Process
Exec the namespace for configuration process
ββββββββip netns exec blue ns1
Add route to the second interface on server side
ββββββββip route add 192.168.100.0/23 via 192.168.158.6
Route the connection to the gateway second interface through first interface in server side.
Add the first interface as a default gateway
ββββββββip route add default via 192.168.158.6
Create an IP Table configuration for NAT Connection
ββββββββiptables -t nat -A POSTROUTING -s 192.168.158.0 -j MASQUERADE
This configuration make the connection β¦ to β¦
Note:
At this point the client still unable to ping the internet, because the server side still reject the packet to be forwarded. And there's no logic to do the intended task.
Configure IP Forwarding on Server Side
Enable IP Forwarding on VM 1
As you cansee from here, we've created the linux namespace.
Validate IP Forwarding on VM 1
As you cansee from here, we've created the linux namespace.
Disable a Firewall
As you cansee from here, we've created the linux namespace.
Configure iptables
ββββββββiptables -t nat -A POSTROUTING -s 192.168.158.0/24 -d 0/0 -j MASQUERADE
Validate the connection from namespace through tipTest2
Interface
As you can see from here, we've established the connetion from namespace trough tipTest2 Interface.
Validate the connection from namespace through tipTest2
Interface
As you can see from here, we've established the connetion from Server trough enp0s8
interface.
Validate chain packets
The chain packet is up to > 0, means there's packet that use configured iptables.