Knowledgebase
Knowledgebase
Adding A New NIC In Ubuntu
Posted by Will Kruss on 31 May 2016 02:50 PM

If you are adding a second NIC in Ubuntu, It requires some reconfiguration of network settings within Ubuntu.

If you are adding a second NIC in Ubuntu, it's most likely that it will not automatically pick up the settings properly when you boot up the VPS. It requires some reconfiguration of network settings within Ubuntu. Firstly, you'll probably need console access as your VPS may no longer be accessible, see: https://www.vpsblocks.com.au/support/Knowledgebase/Article/View/28/0/how-can-i-get-console-access-to-my-vps

Once you have access via the console, do the following:

ifconfig -a

This will output the current NICs. Most likely you have one called eth0 and one called renameX. Keep a note of the two MAC addresses (HWaddr). If you have no network access to your VPS then the HWaddr of eth0 is the NIC you just added.

nano /etc/udev/rules.d/70-persistent-net.rules

Edit the above file using nano. If there is not a line for each NIC you need to add one:

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="05:15:5d:02:12:0d", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

The ATTR address in the line should match the NIC you just added. Give it a name such as eth1. Before you save the file make you that you have one line for each NIC, and that the ATTR address in each line matches the ATTR addresses you copied down earlier.

Save the file and exit.

nano /etc/network/interfaces

Here you need to specify each NIC by name and set the IPs appropriately, for example:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 203.143.80.2
gateway 203.143.80.1
netmask 255.255.255.0

auto eth1
iface eth1 inet static
address 10.1.245.11
netmask 255.255.255.240

Once you have done that, save the file and then type:

/etc/init.d/networking restart

This should bring up the interfaces immediately, in our example running an ifconfig should list both eth0 and eth1.

root@vps:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 05:1d:d8:b7:1f:73
          inet addr:203.143.84.80.2 Bcast:203.143.80.255  Mask:255.255.255.0
          inet6 addr: 2400:6800:ffff:2:21d:d8ff:feb7:1f73/64 Scope:Global
          inet6 addr: fe80::21d:d8ff:feb7:1f73/64 Scope:Link
          inet6 addr: 2400:6800:ffff:2:d92:a1a0:1e72:b375/64 Scope:Global
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4777 errors:0 dropped:0 overruns:0 frame:0
          TX packets:199 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:493640 (493.6 KB)  TX bytes:23365 (23.3 KB)

eth1      Link encap:Ethernet  HWaddr 05:15:5d:02:12:0d
          inet addr:10.1.245.11  Bcast:10.1.245.15  Mask:255.255.255.240
          inet6 addr: fe80::215:5dff:fe02:120d/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:137 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:9 Base address:0xec00

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

If it doesn't, you can try restarting the server. Alternatively, you may have mixed up the mac addresses and assigned the incorrect IPs to each adapter. If this is the case you can simply edit the /etc/network/interfaces file again and swap the networking information for each interface, then restart networking again.

(0 vote(s))
Helpful
Not helpful