How to add second NIC

Discussion in 'Proxmox VE: Networking and Firewall' started by Emtiaz, Jan 29, 2018.

  1. Emtiaz

    Emtiaz New Member

    Joined:
    Jan 29, 2018
    Messages:
    1
    Likes Received:
    0
    I am very new in proxmox. I have 2 lan cards in the server but can not configure the second one which is in a different subnet. Please help.

    192.168.0.1/23 is my first lan block
    192.168.230.232/29 is my second lan block. only traffic from 192.168.5.0 needs to go through this card. do i need to add static route for this in proxmox or in vm?

    vmbr0 is configured for first lan block and it is working fine.
    how do i enable vmbr1 for my second nic?
     
  2. wolfgang

    wolfgang Proxmox Staff Member
    Staff Member

    Joined:
    Oct 1, 2014
    Messages:
    4,317
    Likes Received:
    276
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. Foster Banks

    Foster Banks New Member

    Joined:
    Dec 13, 2017
    Messages:
    25
    Likes Received:
    4
    Hi All,

    Im sorry, maybe this is clear and i just dont get it.
    I am not sure if this is only for CT's or also for VM's.

    I had a Centos 7 VM with a single NIC (vmbr01), then added via the Proxmox GUI the secondary NIC (vmbr1) and rebooted the VM.
    The VM came back up only with its public NIC. NO other NIC was there.

    I assumed then i had to re-install the VM, I am at the installation stage, and i can only select ONE NIC.
    I dont see anywhere, how i can add another NIC to the VM.

    Thanks,

    Foster Banks
     

    Attached Files:

    • NIC.png
      NIC.png
      File size:
      34.7 KB
      Views:
      72
  4. Foster Banks

    Foster Banks New Member

    Joined:
    Dec 13, 2017
    Messages:
    25
    Likes Received:
    4
    *****UPDATE*****
    Ok, so I think i got this working the way i wanted.

    I have been able to add the second NIC to the VM, using the second bridge of the server. You can see in the attachment, that after it was added, there is one NIC using vmbr0 and another NIC using vmbr1.

    IMPORTANT: Please note, in the Node itself, a static route must be added, so PRIVATE traffic goes OUT via the eth1 NIC. Since by default ONLY 1 Default GW can be configured, it is necessary to create a route-file named route-eth1 inside the /etc/sysconfig/network-scripts/ directory.

    nano /etc/sysconfig/network-scripts/route-eth1

    This file must contain the following information:
    ++++++++++++++++++++++++++++
    ADDRESS0=10.0.0.0
    NETMASK0=255.0.0.0
    GATEWAY0=10.100.100.1
    ++++++++++++++++++++++++++++
    This configuration assumes you want to access all the 10.0.0.0/8 network via eth1.

    Now to the Guest.
    The guest was rebooted and showed NO change whatsoever as far as NICs go. SO, this is what I did.

    1. Issue the following command: dmesg | grep eth1 | more
    This showed me there was INDEED another NIC, besides eth0 on this VM. See attachment.

    2. I then did this:
    2.1 cd /etc/sysconfig/network-scripts/
    2.2 cp ifcfg-eth0 ifcfg-eth1
    2.3 nano ifcgfg-eth1. This was done in order to change the name of the NIC as well as the MAC address. From eth0 to eth1, as well as the MAC, to the new MAC.
    The MAC adress i used was the one i got from running the dmesg command mentioned above.

    I then added the network configuration to the NIC, and ran the ifup eth1 command and YES, the NIC came UP!

    Now, this is a Centos VM, so again, static routes needs to be added to the VM itself, so it delivers the private traffic OUT via eth1.
    We proceed to do the same thing we did for the node by creating the route-eth1 file, with the appropriate values.

    We then restart the network service and YES, IT WORKS.

    This is what we get: check final results screenshot.
    As you can see, the routing table shows the GW/NIC being used for public and private traffic.

    Best Regards,

    Foster Banks
     

    Attached Files:

  5. Foster Banks

    Foster Banks New Member

    Joined:
    Dec 13, 2017
    Messages:
    25
    Likes Received:
    4
    *****UPDATE*****

    The Network Configuration for the Hardware Node is not centos, I got confused because always working on Centos.
    So, steps to configure private network in the Node:

    1. Config file should look like this:
    ++++++++++++++++++++++++++++++++++++++++++++++
    ++++++++++++++++++++++++++++++++++++++++++++++
    auto lo
    iface lo inet loopback

    iface enp1s0f0 inet manual

    allow-hotplug enp1s0f1

    auto enp1s0f1
    iface enp1s0f1 inet manual

    auto vmbr0
    iface vmbr0 inet static
    address 185.128.43.26
    netmask 255.255.255.252
    gateway 185.128.43.25
    bridge_ports enp1s0f0
    bridge_stp off
    bridge_fd 0

    auto vmbr1
    iface vmbr1 inet static
    address 10.10.2.226
    netmask 255.255.255.252
    bridge_ports enp1s0f1
    bridge_stp off
    bridge_fd 0
    #Private Traffic

    root@cloud:~#

    ++++++++++++++++++++++++++++++++++++++++++++++
    ++++++++++++++++++++++++++++++++++++++++++++++

    Then, you need to configure routing for the private traffic to leave the server via the second NIC.
    There are different ways to do this, I prefer to do it like this:

    1. Create a file:
    nano /etc/network/if-up.d/route

    2. On this file, add the following lines:
    #!/bin/sh
    route add -net 10.0.0.0/8 gw 10.10.2.225 dev enp1s0f1
    NOTE: Again, this assumes the 10.10.2.225 is my GW and enp1s0f1 is my Private NIC. Adjust as needed.

    3. Setup the proper permissions for this file by issuing:
    chmod +x /etc/network/if-up.d/route
    This will make sure this gets executed.

    4. Reboot the Node.

    After reboot, you will see the changes

    Regards,

    Foster Banks
     
    Marshalleq and Talion like this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice