EdgeRouter - Configure DHCP server on EdgeRouter

Overview


Readers will learn how to set up and configure a DHCP server as well as clients on the EdgeRouter. 

Steps for DHCP server


To configure a DHCP server, three settings are required:

  • name
  • subnet
  • range

Here is an example of how to set up a DHCP server:

set service dhcp-server shared-network-name LABNET subnet 100.0.0.0/24 start 100.0.0.10 stop 100.0.0.100
set service dhcp-server shared-network-name LABNET subnet 100.0.0.0/24 default-router 100.0.0.1
set service dhcp-server shared-network-name LABNET subnet 100.0.0.0/24 dns-server 100.0.0.1

This shows the DHCP server configuration:

dhcp-server {
 shared-network-name LABNET {
 subnet 100.0.0.0/24 {
 default-router 100.0.0.1
 dns-server 100.0.0.1
 start 100.0.0.10 {
 stop 100.0.0.100
 }
 }
 }
}

Here are examples of show dhcp commands:

ubnt@ubnt:~$ show dhcp leases
IP address Hardware Address Lease expiration Pool Client Name
---------- ---------------- ---------------- ---- -----------
100.0.0.10 00:24:e8:f7:68:80 2011/12/02 14:41:32 ETH1 Test4-PC
ubnt@ubnt:~$ show dhcp statistics
pool pool size # leased # avail
---- --------- -------- -------
ETH1 91 1 90

IP addresses can be removed with the clear commands. To clear a specific IP address:

ubnt@ubnt:~$ clear dhcp lease ip 172.16.0.10

To clear all DHCP leases:

ubnt@ubnt:~$ clear dhcp leases

Steps for DHCP client


To configure a DHCP client, use the set interfaces ethernet eth_ address command (_ is the placeholder for the Ethernet port number):

set interfaces ethernet eth_ address dhcp

Here is an example of the show dhcp client leases command:

ubnt@ubnt:~$ show dhcp client leases
interface  : eth2
ip address : 192.168.0.27 [Active]
subnet mask: 255.255.254.0
router  : 192.168.0.1
name server: 192.168.0.1
dhcp server: 192.168.0.1
lease time : 600
last update: Fri Dec 9 20:04:13 GMT 2011
expiry  : Fri Dec 09 20:14:10 GMT 2011
reason  : BOUND

Overview


Readers will learn how to bridge eth2,3 and 4 (switch0) with eth1 on the EdgeRouter-POE (5 Port).

Generally, we do not recommend bridging ports on routers, as it will reduce the overall throughput compared to non-bridged configurations.  If you require more than 3 LAN ports on the same layer 2 network, we strongly advise using a switch as it is the right tool for the job.  That being said, bridging may be acceptable in some environments. 

The following assumes your ER-POE is set to defaults and you are connected via SSH on eth0 (192.168.1.1)

Commands


 We need to make sure eth2,3 & 4 are members of swith0.

configure
set interfaces switch switch0 switch-port interface eth2
set interfaces switch switch0 switch-port interface eth3
set interfaces switch switch0 switch-port interface eth4
commit

Now we can create a new bridge (br0), add switch0 (eth2,3,4) and eth1 as bridge-group members and assign the new bridge interface an IP.  (e.g. 192.168.2.1/24)

set interfaces bridge br0
set interfaces bridge br0 address 192.168.2.1/24
set interfaces switch switch0 bridge-group bridge br0
set interfaces ethernet eth1 bridge-group bridge br0
commit
save
exit

From here you can configure your computer with an IP address in the 192.168.2.0/24 address space( e.g. 192.168.2.10) and plug into any of the ports that are members of br0.  Alternatively, you can follow the this CLI DHCP server article so you can obtain an IP address automatically via DHCP when connecting to eth1, 2, 3 & 4. 

Related Articles


Powered by Zendesk