1

This question already has an answer here:

I'm trying to configure a virtual network in VirtualBox with a central node as gateway & DHCP & DNS server (I'm using the dnsmasq).

Central node has two interfaces:

  • enp03 which faces the host network. It configured by host network DHCP and has a dynamic IP address.
  • enp08 which faces the virtual network. dnsmasq is listening this interfase.

Now I want to set some static configuration for enp08.

Is it possible to do something like that in /etc/network/interfaces:

auto enp03
iface enp03 inet dhcp

auto enp08
iface enp08 inet static
 address 10.0.5.1
 netmask 255.255.255.0
 gateway enp03

marked as duplicate by Christopher, mdpc, countermode, GAD3R, Kusalananda Jan 13 '17 at 13:37

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    @Christopher I don't think the OP wants to add a second route. IMO, they want to duplicate the default one. – xhienne Jan 13 '17 at 0:46
2

If I understand correctly, you want to define a gateway for the enp08 interface, and tell the kernel that this gateway is the same than the one used on enp03, right?

Then just remove/comment that gateway line. It defines a default gateway and the default is already set (by DHCP on enp03), no need to add a duplicate.

  • Thus, if we don't configure the gateway for some network interface (enp08) then it would be searched on other configured interfaces (enp03, ...) for all incomming enp08 packets? Is it exsists some priority for that searh for configured interfaces (enp03, ...)? – Silk0vsky Jan 13 '17 at 7:31
  • 1
    Yes. You need only one default gateway, not one per interface. Actually, the problems start when you have multiple default gateways, not when you have one. Then it depends on your system: certain alternate between the two (round-robin), others use only the last. The best then is to put a priority (metrics) on each gateway. The lower the better. – xhienne Jan 13 '17 at 9:02

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