Ubuntu: Give 2nd nic card with different subnet internet access



Question:

I have an ubuntu server running 16.04

There are 2 NIC cards:

One is 192.168.10.9/24, this has internet access through the gateway of 192.168.10.254.

My second Nic card had an IP of 192.168.25.1/24 and currently does not have a gateway or internet access.

Everything on the 192.168.25.x network is using DHCPD from the ubuntu server.

How do I allow internet access to the 192.168.25.x?


Solution:1

You need to enable IPv4 Forwarding. There is an excellent write up on the subject here.

The following will help you check the system state and set the parameter from the command line. Please note, this setting will be ephemeral; you will need to determine how to make the setting permanent (if you so wish) based upon your specific distribution and version.

The following is taken from this article:


Check if IP Forwarding is enabled

We have to query the sysctl kernel value net.ipv4.ip_forward to see if forwarding is enabled or not:

Using sysctl:

sysctl net.ipv4.ip_forward  net.ipv4.ip_forward = 0  

or just checking out the value in the /proc system:

cat /proc/sys/net/ipv4/ip_forward  0  

As we can see in both the above examples this was disabled (as show by the value 0).

Enable IP Forwarding on the fly

As with any sysctl kernel parameters we can change the value of net.ipv4.ip_forward on the fly (without rebooting the system):

sysctl -w net.ipv4.ip_forward=1  

or

echo 1 > /proc/sys/net/ipv4/ip_forward  

the setting is changed instantly; the result will not be preserved after rebooting the system.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »