Page tree
Skip to end of metadata
Go to start of metadata

This article was written a long time ago. It should be improved to match the tone of the rest of the website. Update this article with recent work done on secondary IP.

Traditionally most enterprise environments used static IP. This is changing somewhat due to virtualization and the concept of stateless applications. But it's not quite there yet.

For your home server environment you might want to use Bonjour name resolution instead and just go by hostname.

Assuming your existing install is picking up DHCP correctly and your network is working fine. If you are learning using virtual machine softare like VMWare, ensure your guest OS network is set to use Bridged Networking. This will not work with sharing the network.

If possible, it is advised to be sure you can reach your machine via a console mechanism or experiment on a test machine first.

ifconfig

This will list your network cards. Usually you will see eth0 as being the network card enabled. Record the highlighted entries,

eth0      Link encap:Ethernet  HWaddr 00:0c:29:35:62:69
          inet addr:192.168.0.174  Bcast:192.168.0.255  Mask:255.255.255.0

Now I don't know how to get the rest on Ubuntu quite yet (now I do), so I go to a Windows machine on the same network and type,

ipconfig /all

Again, record the Default Gateway, line item 9, for the Ethernet adapter Local Area Connection,

Connection-specific DNS Suffix  . : pham
Description . . . . . . . . . . . : Broadcom NetLink (TM) Fast Ethernet
Physical Address. . . . . . . . . : 00-15-C5-7F-D4-07
Dhcp Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
IP Address. . . . . . . . . . . . : 192.168.0.177
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.0.1
DHCP Server . . . . . . . . . . . : 192.168.0.1
DNS Servers . . . . . . . . . . . : 192.168.0.1
Lease Obtained. . . . . . . . . . : March 13, 2009 11:25:09 AM
Lease Expires . . . . . . . . . . : March 14, 2009 11:25:09 AM

Do a ping to verify that no other device is using the IP address. In this example we want to use 192.168.0.50,

ping 192.168.0.50 -c3
From 192.168.0.183 icmp_seq=1 Destination Host Unreachable
From 192.168.0.183 icmp_seq=2 Destination Host Unreachable
From 192.168.0.183 icmp_seq=3 Destination Host Unreachable

--- 192.168.0.4 ping statistics ---
3 packets transmitted, 0 received, +3 errors, 100% packet loss, time 2025ms

Next on your Ubuntu machine,

sudo cp /etc/network/interfaces /etc/network/interfaces.v0.0 # Make a backup
sudo ne /etc/network/interfaces # Where ne is your preferred text editor

The file will look like this,

# 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

# The primary network interface
auto eth0
iface eth0 inet dhcp

The area where you file might be different is eth0 may be ens3 or something similar. This changes depending on your version of Ubuntu and setup.

We modify the file and choose 192.168.0.50. Note that this ip address would never be assigned by my router as I modified the router's dhcp address range from 192.168.0.2 - 192.168.0.255 to only provide DHCP between 192.168.0.100 - 192.168.0.255. My router itself is using the ip address 192.168.0.1.

# 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

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.0.50
netmask 255.255.255.0
gateway 192.168.0.1

# Required as of Ubuntu 13.04 (in my testing, but I read 12.04 and up requires this)
dns-nameservers 192.168.0.1

 # 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
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.0.50
netmask 255.255.255.0
gateway 192.168.0.1
# Name servers are required for static entries.
dns-nameservers 192.168.0.1

If you have not already, make sure are running from the console for this step. Otherwise you will be disconnected and have to connect again with the new ip address.

Now we restart the network services,

sudo /etc/init.d/networking restart

Verify by pinging your system from another machine.

After you know things are working you may want to uninstall the dhcp package. I have read (but not experienced myself) that after a certain amount of time it will take control and you will end up with a dhcp assigned ip.

sudo apt-get remove isc-dhcp-client dhcp3-client dhcpcd

Notes

Some instructions mention you need network and broadcast, but they are automatically calculated from the address and netmask values. In fact adding the wrong ones can prevent things from working so I recommend leaving them out.


If you have more than one dns server use the format, dns-nameservers 208.78.97.155 208.75.87.250

Questions for the You Reader

Can somebody explain to me what network and broadcast are and how they are calculated?

References


  • No labels