I have Ubuntu 13.10, Saucy Salamander x64 running as a guest in VirtualBox (with Windows 7 as a host).
I wrote this /etc/network/interfaces
because I need to add a large number of permanent, manual static routes:
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
auto eth1
iface eth1 inet dhcp
up ip -force -b /etc/network/eth1-routes
eth1-routes
contains several lines of the form:
route add 10.0.0.0/8 via 172.x.x.x dev eth1
where 172.x.x.x
is the gateway that VBox NAT gives me.
By running netstat -nr
it appears that all of my manual routes have been successfully added, including routes to get to two DNS servers via 172.x.x.x
.
However, network manager says that both devices are "not managed". If I set /etc/NetworkManager/NetworkManager.conf
managed=true
, network manager works again but my routes are lost. So my current compromise is to set managed=false
and comment out the eth0
lines in /etc/network/interfaces
.
Is there a way to have a device be managed and still do manual routes as above?
Network Manager manages its own static routes - open network manager and select "wired connection 1". Select edit. select IPv4 tab. At the bottom of this page is a button for "Routes". That is where you add them. When done NM writes to a file with root permissions in its /etc/NetworkManager/system-connections/ directory called "Wired connection 1"
Example follows
Where 10.2.2.0 is the destination network and 10.1.1.68 is the gateway.
Network Manager does not recognize the statements you wrote in
/etc/network/interfaces
.So your can add your script
eth1-routes
as a dispatcher script for Network Manager in/etc/network/if-up.d/
. It will be run every time an interface goes up. Maybe you have to write in your script an "if clause" to only add the routes ifeth1
comes up. Like this:If you want to add a route to Ubuntu that persists reboot and does not use the default interface as the gateway then you may want to add a route statement to the NetworkManager configuration file for the specific interface.
Add a route to the /etc/NetworkManager/system-connections/"connection name" configuration file by adding the route statement to the configuration file for (assuming IPv4). The route has four parts; "the first being the destination IPv4 network or address (network byte order), the second the destination network or address prefix (1 - 32), the third being the next-hop (network byte order) if any, and the fourth being the route metric".
This is the equivalent of setting the route using the following route statement:
The route keyname is defined in Table 12 in the NetmorkManager developer documentation. Please see the following URL for more information: https://developer.gnome.org/NetworkManager/0.9/ref-settings.html