Quantcast
Channel: Open Source Software Development » media-server
Viewing all articles
Browse latest Browse all 11

Ubuntu web gateway – DHCP server

$
0
0

In order for devices to be available on the network, they must have an IP Address.

DHCP is a protocol that all devices support, in order to connect to a network. A DHCP Server can provide automatic configuration of IP addresses. This post will describe how to setup a DHCP server under Ubuntu.

As per part 1 of the ubuntu web gateway, new network devices on the local network will be automatically assigned a 10.1.1.0/24 address (the DHCP server is hard-coded for address 10.1.1.1, as per /etc/network/interfaces).

Run the following command to install a DHCP server

sudo apt-get install isc-dhcp-server

Modify the configuration file (1) /etc/default/isc-dhcp-server, to specify the network device where the DHCP service will be listening:

INTERFACES="eth0"

Modify the configuration file (2) /etc/dhcp/dhcpd.conf, to define DHCP settings:

option domain-name "local";
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
subnet 10.1.1.0 netmask 255.255.255.0 {
 range 10.1.1.10 10.1.1.20;
 option routers 10.1.1.1;
 option subnet-mask 255.255.255.0;
 option broadcast-address 10.1.1.254;
 option domain-name-servers 10.1.1.1;
 option domain-name-servers 192.168.0.1;
 option ntp-servers 10.1.1.1;
 option netbios-name-servers 10.1.1.1;
 option netbios-node-type 8;
}

Note the following settings:

  • router – a gateway that is connected to the internet. All the internet traffic will be routed through to the specified address. This provides the automatic gateway configuration for new devices on the network
  • domain-name-servers – provides a list of DNS servers on the network. The address 192.168.0.1 is my router, which is both a gateway for internet traffic and a cache of DNS entries
  • range – a range of IP addresses that can be assigned to devices. The range of 10.1.1.1010.1.1.20 (10 addresses) can be assigned

Start the DHCP service with new configuration:

sudo service isc-dhcp-server restart

If, for some reason, the service does not start, refer to /var/log/syslog. You can find outputs by running the following:

cat /var/log/syslog | grep dhcpd

As a new device connects onto the network, its IP address will be automatically assigned by this DHCP server. Here’s the proof after running ifconfig on another host:

eth0 Link encap:Ethernet HWaddr XX:XX:XX:XX:XX:XX
 inet addr:10.1.1.10 Bcast:10.1.1.254 Mask:255.255.255.0

By running the route command, can see the path that packets will take (to the gateway):

Destination Gateway Genmask Flags Metric Ref Use Iface
default 10.1.1.1 0.0.0.0 UG 100 0 0 eth0
10.1.1.0 * 255.255.255.0 U 0 0 0 eth0
link-local * 255.255.0.0 U 1000 0 0 eth0

Give this setup a go and let me know what you think… will you have access to the internet?


Viewing all articles
Browse latest Browse all 11

Trending Articles