Setup a second network interface - Linux

 


It has happen to me some times, when I try to use two network interfaces (NIC) in a VM, and when verify its ip addresses just one has any assignated. In this post I'll show how to configure the interfaces to accept two NICs in a Kali VirtualBox VM.


First of all, in the following image, we can see, I've added two network interfaces for the same VM, one for NAT connection and the other one for a host-only adapter:



But, once the VM is started, I can verify that just one of them has an ip assignated, or tring to make a ping request to the two different networks just one responds:


What we need to do in to configure bith network interfaces. If we consult the interfaces man pages (man interfaces), we can see an example of how to do it:



It says that we can configure eth0 to brought up at boot with:

auto eth0

and eth1 when the network card is detected as follows:

allow-hotplug eth1

finally, we need to configure an ip methos for each of them, static or dhcp:

iface eth0 inet dhcp


We have to edit this on /etc/network/interfaces file, and configure them as needed. In my case, all add two interfaces, one at boot time and the othen when its detected, in case I need to disable one of them:



Just had to add:

# eth0

auto eth0

iface eth0 inet dhcp


# eth1

allow-hotplug eth1

iface eth1 inet dhcp



Save the file, and restart network service:
sudo /etc/init.d/networking restart



Now, we can verify ips and conectivity to both networks (local and to internet in this case).


This is an easy solution to solve the problem when having two network interfaces and just one of them is working properly. I hope this was useful.


natryvat


Comments

Popular Posts