nmcli & virtual NIC
FedoraForum.org - Fedora Support Forums and Community
Results 1 to 11 of 11
  1. #1
    Join Date
    Aug 2019
    Location
    estonia
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question nmcli & virtual NIC

    Please, does anybody know, how to create secondary (software) NIC in a way, that it works with NetworkManager.

    I know, how to do it in a "old-fashion-way", but unfortunately NM does not understand that and therefore some other programs do not work.
    I have tryied for several times and searched Internet without success.

    1. Sometimes I have secondary NIC, which exists in ifconfig, but nmcli shows only primary one with both addresses. Therefore I can not address them in a different way.
    2. I can create secondary "connection" with nmcli, but then I must chose, which one is active, if they both rely on the same real NIC or the second one does not work at all if I rename other NIC everywhere to something like eht0:0.
    3. I switched NetworkManager at all off and installed old networking service, but those applications, which used to ask from NM, do not work. NM seems to be so natural part of Fedora networking, that I need to use nmcli or chose another OS.

    Is there any way at all to make it work?

  2. #2
    Join Date
    Jun 2004
    Location
    Maryland, US
    Posts
    7,663
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Re: nmcli & virtual NIC

    From your desktop, go to the NetworkManager widget it uses and select the primary nic, select the "Restrict to Device" from the 'Wi-Fi' tab which will have a pull down menu listing all the MAC addresses that Fedora sees. Pick the MAC address that matches the one for the primary nic. Next use the widget to make a new interface, give it some name you want like "virtual-secondary", and set the Restrict to Device to the MAC for the MAC address on the secondary nic.

    You can use the command line command "ip link" to see all the available mac addresses, they are just right of the "link/ether" label

    After this is done you should be able to select one I/F or the other from the NM widget. The instructions I put here are for the NetworkManager widget in KDE but gnome should have a similar one up in the upper right corner.
    Last edited by marko; 16th August 2019 at 03:44 AM.

  3. #3
    Join Date
    Aug 2019
    Location
    estonia
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: nmcli & virtual NIC

    Thank you, but tere is no KDE or any desktip widget -- it's VPS and nmcli. Only. Also there is no WiFi. It has to be done on command-line.

  4. #4
    Join Date
    Jun 2004
    Location
    Maryland, US
    Posts
    7,663
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Re: nmcli & virtual NIC

    Well, I meant just using NM widget the one time to setup the interfaces, then you could use nmcli from then on. You mean the host is so bare there's no GUI desktop?

    Okay, are your connections static or DHCP? I'll show both below:


    I've not tested this but I think you'd do this:

    I just noticed you may be using wired i/f so you'd switch the "wifi" strings below with "ethernet" and the interface names would not start with "wl"

    1) create the interfaces, replace the ifname value with the i/f names of your wireless's.
    I used wlp6s0 wlp6s2 for examples

    if DHCP:
    Code:
    sudo nmcli con add type wifi con-name primary ifname wlp6s0
    sudo nmcli con add type wifi con-name secondary ifname wlp6s2
    OR create the interfaces like below if static. The example is 192.168.0.100,101 at gateway 192.168.1.1 so replace with your addresses
    Code:
    sudo nmcli con add type wifi con-name primary ifname wlp6s0 ip4 192.168.1.100/24 gw4 192.168.1.1/24
    sudo nmcli con add type wifi con-name secondary ifname wlp6s2 ip4 192.168.1.101/24 gw4 192.168.1.1/24
    Sanity check that this worked by viewing the two new ifcfg files (using a grep trick to cat the files out with each line labeled)
    Code:
    cd /etc/sysconfig/network-scripts
    grep . ifcfg-{primary,secondary}
    review the two file listings

    2) allow your user duneyrr (changed to whatever it is) to control the interfaces:
    Code:
    sudo nmcli con mod primary connection.permissions duneyrr
    sudo nmcli con mod secondary connection.permissions duneyrr
    so you don't have to use "sudo" forever

    3) now pick one to run (put up primary)
    Code:
    nmcli con down secondary ; nmcli con up primary
    or
    Code:
    nmcli con down primary ; nmcli con up secondary
    From now on your user would only need to run one or the other of the step 3 commands (nmcli con up or down)
    Since those two commands are a pain to type each time, make a pair of aliases in your ~/.bashrc file


    edit ~/.bashrc and add:
    Code:
    alias primaryup='nmcli con down secondary ; nmcli con up primary'
    alias primarydown='nmcli con down primary ; nmcli con up secondary'
    alias bothdown='nmcli con down primary ; nmcli con down secondary'
    save the file and load the change:
    Code:
    source ~/.bashrc
    to load the change to your shell (just necessary once, all logins will source that)

    so from now on just run one of "primaryup" or "primarydown" or "bothdown" to control

    Note that I used as a reference:
    https://www.tecmint.com/configure-ne...tool-in-linux/

    Another option you could try is the "nmtui" text interface to NM
    Last edited by marko; 16th August 2019 at 02:32 PM.

  5. #5
    Join Date
    Aug 2019
    Location
    estonia
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: nmcli & virtual NIC

    Unfortunately, not yet.
    Just for background, as rented virtual private server, it has ethernet and static IP-s. And... if I do something wrong, then I'm again out of ssh-connection, which is not too funny. :-)
    What I need, is NOT two alternative connections but two PARALLEL connections with different addresses and tow different interface names (not only one interface with 2 addresses).
    I know, how to create just one new connection, but when I create 2 new connections based on the same NIC then, nmcli switches previous off, if I activate new one.
    I know also, how to clone existing one -- on that case nmcli does NOT show two interfaces, but there's one one interface with two addresses.
    If I try to create new connection with modified IF-name like eth0 -> eth0:0, then nmcli's response is, that it can't do it, there is no such device.
    I just feel... out of gunpowder.

  6. #6
    Join Date
    Aug 2019
    Location
    estonia
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: nmcli & virtual NIC

    Oh, and there is no nmtui in Fedora 30 server edition -- don't know, why. Just nmcli.

    For example:

    [root@xoxo ~]# nmcli con
    NAME UUID TYPE DEVICE
    ens3 8a166131-d49f-4103-a265-5ed9afb4dec0 ethernet ens3
    ens3-0 7e28f76c-bbfe-4ab5-924d-cbe6506066ff ethernet --
    [root@xoxo ~]# nmcli con up ens3-0
    Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/5)
    [root@rudis ~]# nmcli con
    NAME UUID TYPE DEVICE
    ens3-0 7e28f76c-bbfe-4ab5-924d-cbe6506066ff ethernet ens3
    ens3 8a166131-d49f-4103-a265-5ed9afb4dec0 ethernet --

    ... and so all the time.
    Last edited by duneyrr; 16th August 2019 at 02:58 PM.

  7. #7
    Join Date
    Jun 2004
    Location
    Maryland, US
    Posts
    7,663
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Re: nmcli & virtual NIC

    Nmtui can be installed

    dnf install nmtui

    Maybe this page would help you


    https://fedoraproject.org/wiki/Networking/CLI

    This is about adding aliases

    https://ma.ttias.be/how-to-add-secon...rhel-centos-7/
    Last edited by marko; 16th August 2019 at 08:47 PM.

  8. #8
    Join Date
    Aug 2019
    Location
    estonia
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: nmcli & virtual NIC

    I have seen this ma.ttias page as well -- that's why I know, that there is no nmtui and it can't be installed in that way. I have tried this already. I suspect it was part of some other packet and has been removed.

  9. #9
    Join Date
    Jun 2004
    Location
    Maryland, US
    Posts
    7,663
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Re: nmcli & virtual NIC

    Code:
    dnf provides \*/nmtui
    Code:
    Last metadata expiration check: 0:01:21 ago on Fri 16 Aug 2019 09:19:12 PM EDT.
    NetworkManager-tui-1:1.16.0-1.fc30.x86_64 : NetworkManager curses-based UI
    Repo        : fedora
    Matched from:
    Filename    : /usr/bin/nmtui
    
    NetworkManager-tui-1:1.16.4-1.fc30.x86_64 : NetworkManager curses-based UI
    Repo        : updates
    Matched from:
    Filename    : /usr/bin/nmtui
    So my assumption on the package name was wrong (I had no Fedora box to test on at the time), the package is "NetworkManager-tui" as found by 'dnf provides <path>'
    Last edited by marko; 17th August 2019 at 10:26 PM.

  10. #10
    Join Date
    Aug 2019
    Location
    estonia
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: nmcli & virtual NIC

    Yes, you are right. Somehow I missed that name.
    Unfortunately nmtui does not help either. As soon as I activate the second NIC, first connection becomes inactive.

  11. #11
    Join Date
    Nov 2016
    Location
    USA (Oregon)
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: nmcli & virtual NIC

    This is by design in the kernel. Permiscuous mode is blocked. It is consider a security hole.

Similar Threads

  1. But to change DNS with NMCLI for WiFi??
    By xzj8b3 in forum Using Fedora
    Replies: 1
    Last Post: 23rd May 2018, 12:55 AM
  2. F23: openvpn with nmcli not working
    By MikeBerger in forum Servers & Networking
    Replies: 2
    Last Post: 26th January 2016, 02:59 AM
  3. [SOLVED]
    nmcli fails to connect
    By tuxor in forum Servers & Networking
    Replies: 4
    Last Post: 4th April 2013, 04:36 PM
  4. Fedora 14, wireless nmcli
    By Tycnes in forum Servers & Networking
    Replies: 0
    Last Post: 10th August 2011, 08:44 AM
  5. nmcli is whence?
    By zaitcev in forum F16 Development
    Replies: 2
    Last Post: 11th March 2010, 07:04 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •