1

I have a Debian Stretch server with a network card. I want it to connect to my (normal configured standart DHCP) Router.

So normaly i would say something like iface eth0 inet dhcp. But i have a network Card installed with two additional ethernet ports.

The names of the ports are different based on the PCI Slot of the Network Card:

  1. No Network Card installed. The Ethernet Jack is called enp5s0
  2. Network Card is installed in PCI Slot 1: The Mainboard Jack is called enp8s0 The First Card Jack is called enp3s0 The Second Card Jack is called enp4s0
  3. Network Card is Installed in PCI Slot 2: The Mainboard Jack is called enp9s0 The First Card Jack is called enp6s0 The Second Card Jack is called enp7s0

I want my Server to connect to the Router with enp5s0, enp8s0 or enp9s0 whatever is available as a normal dhcp client.

I don't want to use the other connections because i was to assign special Virtualisation Configuration later on :)

Can anyone recommend me a /etc/network/interfaces configuration which can achieve this ?

2
  • 1
    Why do you keep pulling the cards in and out and plugging the router cable into different card ethernet ports that it requires such a config? Can you please explain what the purpose is... there may be a far better method.
    – hookenz
    Mar 20, 2017 at 19:44
  • The Mainboard itself has no grafical output. So when attaching a PCIe GPU i have to disconnect the network card. And i would like to have a solution which works in both cases. The workaround is to reconfigure it every time when attaching the GPU.
    – mac.1
    Mar 20, 2017 at 20:22

1 Answer 1

1

Three years ago I had an issue under Ubuntu 12.04 where hardware was not being consistently named between two identical servers. The fix was pretty simple and I think you'll be able to do the same type of thing under Debian.

My solution was to use udev to rename the device according to it's mac address. This way, no matter what slot you plug it into, the device will always be named the same.

This should work under Debian.

e.g. get the mac address of the card with ifconfig

enp0s25   Link encap:Ethernet  HWaddr 20:cf:30:2f:40:79  
          inet addr:192.168.0.114  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::ecb9:ee41:b487:b54a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:338426 errors:0 dropped:0 overruns:0 frame:0
          TX packets:168905 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:385564822 (385.5 MB)  TX bytes:32387645 (32.3 MB)
          Interrupt:20 Memory:f9de0000-f9e00000

Then edit or create file /etc/udev/rules.d/010_netinterfaces.rules (Under Ubuntu 12.04 it was called /etc/udev/rules.d/70-persistent-net.rules)

Add one line for each card:

KERNEL=="eth*", SYSFS{address}=="20:cf:30:2f:40:79", NAME="eth0"

Then update your /etc/network/interfaces with the new names.

# The primary network interface
auto eth0
iface eth0 inet dhcp

Now you can plug your card in any slot and the device name will always be eth0.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .