0

I am trying to configure networking in Linux VM with two Network Adapters (eth0 and eth1). I wanted eth0's IP to be assigned statically for the local network and eth1 to be assigned by the DHCP for the internet connection.

So, the machine should be able to ping another VM in the same local network via eth0 and should access the internet via eth1 without alternating either adapter connection.

I need to configure the interfaces.conf (/etc/network/interface.conf) and NetworkManager config file or anything that needs to to make it work.

  • On what distribution? – Gilles Jun 26 '17 at 21:23
1

To enable network interfaces:

vi /etc/network/interfaces

There, for the respective interface, write

# network card

    auto eth0
    iface eth0 inet static
    address 192.168.1.250
    netmask 255.255.255.0
    network 192.168.1.0
    broadcast 192.168.1.255
    gateway 192.168.1.1

    auto eth1
    iface eth1 inet dhcp

(Change IP address details as per your requirements)

Restart network after that:

service networking restart

or

sudo /etc/init.d/networking restart
  • 1
    The above only works for Debian and derivatives, but not for RedHat for instance, and the OP does not specify the distro in use. Also, you need to configure the Hypervisor so that it knows what to do with the two interfaces, which again cannot be done yet because we have not been told which beteen VirtualBox, VMWre, Xen, and so on is being used. – MariusMatutiae Jun 26 '17 at 9:28
  • Since /etc/network/interfaces is available only in Debian and derivatives, so the solution provided is for that only. RHEL uses /etc/sysconfig/network-scripts/ifcfg-ethX where we have to configure the interfaces. And it is clearly mentioned that /etc/network/interface.conf file is needed to be edited. – Amit24x7 Jun 26 '17 at 10:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.