Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
add comment

5 Answers 5

up vote 2 down vote accepted

Normally i edit the file /etc/network/interfaces and mod the info to something like this:

iface eth0 inet static
address 192.168.56.101
netmask 255.255.255.0
gateway 192.168.56.1 (u had 102.168.1.1, so i guessed it was a mistake)
share|improve this answer
3  
The OP said, he didn't want to touch /etc/network/interfaces –  guntbert Jan 23 '13 at 19:40
    
You're right I would like to do it trough network manager. But since the documentation of this lacks touching the interfaces file will be ok. –  Josh Aug 7 '13 at 18:47
add comment

assuming you meant 192.168.1.1 instead of 102.168.1.1. 192.168.56.101 and 192.168.1.1 are on different networks and will not talk without help. what you need is this:

iface eth0 inet static
address 192.168.56.101
netmask 255.255.255.0
gateway 192.168.56.1

assuming you have a box(router/ layer3 switch, etc) with an ip of 192.168.56.1 to answer.

With a /24 (255.255.255.0) you need to have the first three octets match on the host and the default gateway, 192.168.56.X or 192.168.1.X.

share|improve this answer
1  
The OP said, he didn't want to touch /etc/network/interfaces. –  guntbert Jan 23 '13 at 19:40
add comment

Edit:

To add another interface that can access the internet in Vbox use the network tab of the settings menu. Then enable an additional interface and set it to NAT (as that's the easiest way to get to the internet). And in the wirtual machine add another interface with dhcp like so: allow-hotplug eth1 and after a linebreak iface eth1 inet dhcp

(For some reason my formatting went bad.)

And this way you can access the net using the host OS's connection.


The commandline "client" of network-manager is confusing and pretty much useless when compared to the standard way of managing interfaces under Linux (and most other unixes). Normally you would first take down the already enabled network-interface (if its enbled) {run ifconfig to find out}:

ifconfig eth0 down #note: I assume you want to configure eth0, replace it if not

After that edit the /etc/network/interfaces file (I prefer to use nano):

nano nano /etc/network/interfaces

And add a section along the lines of:

allow-hotplug eth0
iface eth0 inet static
address 192.168.56.101
netmask 255.255.255.0
gateway 192.168.56.1

Also be aware that you need to remove every other presence of eth0 from the file othervise the system won't be able to parse the file correctly and you won't have a network connection. And finally you'll need to re-enable the interface:

ifup eth0

And this should cause your ubuntu to automatically set up the interface with your desired parameters whenever it detects that the "cable is connected".

Also if you really want to avoid editing the interfaces file you can use:

ifconfig eth0 192.168.56.101 netmask 255.255.255.0 gateway 192.168.56.1 up

I think that this way the changes won't be permanent (you'll lose them between reboots, etc.), but I hadn't tested that myself.

share|improve this answer
    
You could have told about the command ip - ifconfig is on the decline. –  guntbert Jan 23 '13 at 19:42
add comment

For those who want the NetworkManager approach, I just went through this, taking the tack mss suggested. There's a touch of information on the Debian wiki and full documentation of the options at the GNOME developer site. (From the RHEL7 docs, it does look like their version of nmcli has add support, so hopefully that'll make it in.)

The dynamic IP is pretty simple (just doing the network config, mind, not the VBox side):

[802-3-ethernet]
auto-negotiate=true
mac-address=XX:XX:XX:XX:XX:XX

[connection]
id=Wired connection 1
uuid=xxx-xxxxxx-xxxxxx-xxxxxx-xxx
type=802-3-ethernet
timestamp=0

[ipv6]
method=disabled

[ipv4]
method=auto

Use uuidgen (package uuid-runtime) to make the uuid, and of course fill the MAC address properly. (Usually better to do that than to specify a device name.)

For the static IP (note the semicolon on the DNS array!):

[802-3-ethernet]
auto-negotiate=true
mac-address=XX:XX:XX:XX:XX:XX

[connection]
id=Wired connection 2
uuid=xxx-xxxxxx-xxxxxx-xxxxxx-xxx
type=802-3-ethernet
timestamp=0

[ipv6]
method=ignore

[ipv4]
method=manual
dns=8.8.8.8;8.8.4.4;
address1=192.168.56.101/24,192.168.1.1
share|improve this answer
add comment

Since the question is specifically about NetworkManager: I never configured a NM connection from the cli and the nmcli tool doesn't seem to have an option to create a connection. But you might want to have a look what the GUI does when you declare a connection as a system connection. It creates a file in /etc/NetworkManager/system-connections but I don't know if the file format is documented anywhere.

You should be able to enable one of those connections via nmcli con up $name.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.