Wednesday, May 1, 2024
16
rated 0 times [  16] [ 0]  / answers: 1 / hits: 152764  / 2 Years ago, fri, october 14, 2022, 12:36:36

Hi there is anyone familiar with the non-gui version of ubuntus network Manager?



I'd like to set up a static IP with it in virtualbox without touching the file /etc/network/interfaces.




  • IP: 192.168.56.101

  • Gateway: 102.168.1.1

  • Netmask: 255.255.255.0



Additionally I'd like to set up a second network interface with a dynamic IP to get connected to the internet with the Vbox.


More From » command-line

 Answers
5

You need to use Network Manger from the command line, this is nmcli.



First, you can list the available connections Network Manager knows about with the following, this is important to find the name, as the device id isn't used:



# nmcli con show


This will give you something like:



NAME                UUID                                  TYPE            DEVICE 
Wired connection 1 7a3b674a-f346-3cfb-8b30-ff70e6db1b60 802-3-ethernet enp0s3


You can then modify the connection with the following:



nmcli con mod "Wired connection 1"
ipv4.addresses "HOST_IP_ADDRESS/IP_NETMASK_BIT_COUNT"
ipv4.gateway "IP_GATEWAY"
ipv4.dns "PRIMARY_IP_DNS,SECONDARY_IP_DNS"
ipv4.dns-search "DOMAIN_NAME"
ipv4.method "manual"


When you enter the above use one line, I've just split it into separate lines to make it more clear.



If you want to set the connection to use DHCP, you can use the following:



nmcli con mod "Wired connection 1"
ipv4.addresses ""
ipv4.gateway ""
ipv4.dns ""
ipv4.dns-search ""
ipv4.method "auto"


You need all the empty quotes as they remove any settings they previously have.



To add a network, use:



nmcli con add ...


With similar parameters.



To make the settings active, reboot. (I tried re-starting Network Manager, but that didn't seem to activate the changes, but a reboot did.)


[#33083] Friday, October 14, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
antorchestr

Total Points: 92
Total Questions: 111
Total Answers: 120

Location: Jordan
Member since Wed, Jun 17, 2020
4 Years ago
;