I am on a ubuntu 12.04 vm
I read https://help.ubuntu.com/12.04/serverguide/network-configuration.html
which says I can set the gateway with a command like:
sudo route add default gw 10.0.2.211 eth0
which works, but clears after a reboot.
I also tried to set the gateway by editing my /etc/network/interface
file:
auto eth0
iface eth0 inet dhcp
gateway 10.0.2.211
pre-up sleep 2
I just added the gateway line.
That doesn't seem to work at all though.
I tried rebooting and running:
sudo /etc/init.d/networking restart
Solution 1 [dirty]
put
crtl+O [write] and crtl+x [close nano]. And the end of boot process ubuntu read and execute rc.local
Solution 2 [clear]
crtl+O [write] and crtl+x [close nano].
Your ip and gw can not be same ip address. If you wish to set only gateway after dhcp, put only this in rc.local
crtl+O [write] and crtl+x [close nano]