networking in command line, Ubuntu 12.04 server

I created a virtual machine in vSphere to become a syslog server. I got the virtual machine created, the Ubuntu 12.04 Server iso attached and the OS installed.

The next step was to created a network interface, attach it to the virtual switch and get networking (route, dns) to come up and function… I tested the IP address by bringing it up on eth0 and testing with

ifconfig eth0 192.168.117.28 netmask 255.255.255.0 up

The worked, and adding a default route also worked…

route add default gw 192.168.117.1

But just editing /etc/network/networking and adding

root@mbo1-log01:~# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# eth0
auto eth0
iface eth0 inet static
     address 192.168.117.28
     netmask 255.255.255.0
     gateway 192.168.117.1
     dns-nameservers 63.251.129.1 63.251.129.33

…wasn’t enough – restarting networking at this point failed…

The additional steps are:

    edit the following:

  • /etc/network/interfaces as above
  • /etc/hosts, add the interface IP address and hostname (DNS doesn’t work here yet because of firewall – that may be why this was required…)
  • echo [hostname] > /etc/hostname
  • restart hostname service – /etc/init.d/hostname restart
  • restart networking – /etc/init.d/networking restart

Then go through and verify all is well…

root@mbo1-log01:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0c:29:0f:bb:78
          inet addr:192.168.117.28  Bcast:192.168.117.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe0f:bb78/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:270 errors:0 dropped:0 overruns:0 frame:0
          TX packets:278 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:24957 (24.9 KB)  TX bytes:29391 (29.3 KB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:154 errors:0 dropped:0 overruns:0 frame:0
          TX packets:154 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:12046 (12.0 KB)  TX bytes:12046 (12.0 KB)

root@mbo1-log01:~# hostname
mbo1-log01
root@mbo1-log01:~# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.117.1   0.0.0.0         UG    100    0        0 eth0
192.168.117.0   0.0.0.0         255.255.255.0   U     0      0        0 eth0
root@mbo1-log01:~# cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 63.251.129.1
nameserver 63.251.129.33
root@mbo1-log01:~#

 

—doug