---
# System prepended metadata

title: DHCP Server

---

# DHCP Server

## Netowrk configuration


### Computer A's Exterior Internal Network

```
auto eth0
iface eth0 inet dhcp
```
In Virtualbox, Network card is set to **NAT**

### Computer A's Interior Network
```
auto eth1
iface eth1 inet static
    address 192.168.100.254
    netmask 255.255.255.0
    gateway 192.168.100.254
```
In Virtualbox, Network card is set to **Internal Network**

### Computer B's Network
```
auto enp0s3
iface enp0s3 inet dhcp
```

In Virtualbox, Network card is set to **Internal Network**

## Installing DHCP server

``` bash
sudo apt-get install isc-dhcp-server
```
## Configuring DHCP
Configuration file: 
```
/etc/dhcp/dhcpd.conf
```
Basic setting of dhcpd.conf:

```
option domain-name "";
option domain-name-servers 8.8.8.8;
default-lease-time 6000;
max-lease-time 72000;
subnet 192.168.100.0 netmask 255.255.255.0 {
    range 192.168.100.20 192.168.100.100;
    option routers 192.168.100.254;
    option broadcast-address 192.168.100.255;
}
```
## Starting DHCP daemon
``` bash
sudo /etc/init.d/isc-dhcp-server start
```

# NAT Server
``` bash
iptables -t nat -A POSTROUTING -s 192.168.100.0/24 -o eth0 -j MASQUERADE
```
