Add a Network Interface with Ubuntu

By Connor Taffe | Published .

I recently needed to add a new network card to a Dell Optiplex 755 running Ubuntu Server. It has an integrated GbE port, but I'd already run fiber to this corner of the room and had a spare PCIe HP NC552SFP 10GbE 2-port SFP+ card, sporting a couple of Cisco SFP-10G-SR SFP+ modules. This combo is an affordable way to use 10GbE fiber at home, at $12/card and $8/module.

HP NC552SFP 10GbE 2-port SFP+ card
HP NC552SFP 10GbE 2-port SFP+ card

After adding the card and rebooting the machine, it connected via the existing USB WiFi adapter, but not the 10GbE interface. The interface is shown under ip addr as enp1s0f0 and enp1s0f1 (one interface per port), but doesn't have an address assigned -- meaning Linux recognizes and supports the card but hasn't DHCP'd on that interface. Running sudo dhclient assigns it an address.

Ubuntu uses netplan, to add a new interface which will come up and DHCP on boot, we need to add it to the config at /etc/netplan. One way to do this is via the netplan command.

To add a new dual-port 10GbE SFP+ card, we can use:

sudo netplan set "ethernets.enp1s0f0={dhcp4: true, optional: true}"
sudo netplan set "ethernets.enp1s0f1={dhcp4: true, optional: true}"

Which will generate an /etc/netplan/70-netplan-set.yaml file which looks like:

network:
  ethernets:
    enp1s0f0:
      dhcp4: true
      optional: true
    enp1s0f1:
      dhcp4: true
      optional: true

After restart, it'll pick up the new interfaces. We can see the DHCP'd addresses like so:

; ip addr
...
3: enp1s0f0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
    link/ether 10:60:4b:94:c2:90 brd ff:ff:ff:ff:ff:ff
4: enp1s0f1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 10:60:4b:94:c2:94 brd ff:ff:ff:ff:ff:ff
    inet 10.0.3.5/16 metric 100 brd 10.0.255.255 scope global dynamic enp1s0f1
       valid_lft 5063sec preferred_lft 5063sec
    ...

Only one of the ports is assigned because the other is not connected.

Testing with iperf3 shows only about 1.4 Gbps between this machine and a Fedora Linux VM on ESXi on an HP DL380 using the same card, through an IBM RackSwitch. To the pfSense VM which serves as my router, I can only get around 1 Gbps (1.4 Gbps using -P 8), which seems to be an issue with pfSense and the vmx devices. Between two Linux VMs iperf3 reports 11.1 Gbps, but only 1.03 Gbps between a Linux machine and pfSense (1.88 using -P 8).

%3optiplexDell Optiplex 770switchIBM RackSwitch G8124optiplex->switchFiberserverHP DL380G7switch->serverFiber

WiFi

I had previously configured a TP-LINK Archer T2U Plus USB WiFi adapter. To configure it, first determine the device name via ip addr (in my case, wlx984827e92b5a), then configure netplan with the SSID and password:

sudo netplan set "wifis.wlx984827e92b5a={access-points: {My SSID: {password: my-password}}, dhcp4: true, optional: true}"

Which will generate an /etc/netplan/70-netplan-set.yaml file which looks like:

network:
  wifis:
    wlx984827e92b5a:
      access-points:
        My SSID:
          password: my-password
      dhcp4: true
      optional: true