PG1X WIKI

My Knowledge Base

User Tools

Site Tools


tech:network:cisco:dhcp-relay-agent:dhcp-relay-agent

DHCP Relay Agent

configure terminal
!
service dhcp
!
interface FastEthernet 0/0
 ip address 10.0.8.254 255.255.255.0
 no shutdown
 ! prevent WOL packet
 no ip directed-broadcast
 ! forward local broadcast
 ip helper-address 10.0.12.193
exit
!
interface FastEthernet 0/1
 ip address 10.0.12.254 255.255.255.0
 no shutdown
exit
!
no ip forward-protocol udp tftp
no ip forward-protocol udp nameserver
no ip forward-protocol udp domain
no ip forward-protocol udp time
no ip forward-protocol udp netbios-ns
no ip forward-protocol udp netbios-dgm
ip forward-protocol udp mobile-ip
!
end

Install DHCP Server on Ubuntu Server 18.04 LTS (Bionic)

Ubuntu 18.04 LTS : DHCPサーバーの設定 : Server World

sudo apt -y install isc-dhcp-server
/etc/dhcp/dhcpd.conf
option domain-name "pg1x.net";
option domain-name-servers 8.8.8.8, 8.8.4.4, 1.1.1.1;
 
authoritative;
 
# NOP provide topology informatin only
subnet 10.0.4.0 netmask 255.255.255.0 {
}
 
# NOP provide topology informatin only
subnet 10.0.12.0 netmask 255.255.255.0 {
}
 
subnet 10.0.8.0 netmask 255.255.255.0 {
  range 10.0.8.1 10.0.8.191;
  option routers 10.0.8.254;
  option subnet-mask 255.255.255.0;
}
root@kozue:~# diff -u /root/orig/etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf 
--- /root/orig/etc/dhcp/dhcpd.conf      2019-05-06 22:00:01.000000000 +0900
+++ /etc/dhcp/dhcpd.conf        2019-07-19 07:48:36.042596229 +0900
@@ -7,8 +7,8 @@
 #
 
 # option definitions common to all supported networks...
-option domain-name "example.org";
-option domain-name-servers ns1.example.org, ns2.example.org;
+option domain-name "pg1x.net";
+option domain-name-servers 8.8.8.8, 8.8.4.4, 1.1.1.1;
 
 default-lease-time 600;
 max-lease-time 7200;
@@ -21,7 +21,7 @@
 
 # If this DHCP server is the official DHCP server for the local
 # network, the authoritative directive should be uncommented.
-#authoritative;
+authoritative;
 
 # Use this to send dhcp log messages to a different log file (you also
 # have to hack syslog.conf to complete the redirection).
@@ -109,3 +109,19 @@
 #    range 10.0.29.10 10.0.29.230;
 #  }
 #}
+
+# NOP provide topology informatin only
+subnet 10.0.4.0 netmask 255.255.255.0 {
+}
+
+# NOP provide topology informatin only
+subnet 10.0.12.0 netmask 255.255.255.0 {
+}
+
+subnet 10.0.8.0 netmask 255.255.255.0 {
+  range 10.0.8.1 10.0.8.191;
+  option routers 10.0.8.254;
+  option subnet-mask 255.255.255.0;
+}
+
+
sudo systemctl restart isc-dhcp-server
root@kozue:~# sudo systemctl status isc-dhcp-server
● isc-dhcp-server.service - ISC DHCP IPv4 server
   Loaded: loaded (/lib/systemd/system/isc-dhcp-server.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2019-07-18 07:59:02 JST; 6s ago
     Docs: man:dhcpd(8)
 Main PID: 2804 (dhcpd)
    Tasks: 1 (limit: 4285)
   CGroup: /system.slice/isc-dhcp-server.service
           └─2804 dhcpd -user dhcpd -group dhcpd -f -4 -pf /run/dhcp-server/dhcpd.pid -cf /etc/dhcp/dhcpd.conf

Jul 18 07:59:02 kozue dhcpd[2804]: PID file: /run/dhcp-server/dhcpd.pid
Jul 18 07:59:02 kozue sh[2804]: Wrote 0 leases to leases file.
Jul 18 07:59:02 kozue dhcpd[2804]: Wrote 0 leases to leases file.
Jul 18 07:59:02 kozue dhcpd[2804]: Listening on LPF/eno2/4c:52:62:27:6a:99/10.0.4.0/24
Jul 18 07:59:02 kozue sh[2804]: Listening on LPF/eno2/4c:52:62:27:6a:99/10.0.4.0/24
Jul 18 07:59:02 kozue sh[2804]: Sending on   LPF/eno2/4c:52:62:27:6a:99/10.0.4.0/24
Jul 18 07:59:02 kozue sh[2804]: Sending on   Socket/fallback/fallback-net
Jul 18 07:59:02 kozue dhcpd[2804]: Sending on   LPF/eno2/4c:52:62:27:6a:99/10.0.4.0/24
Jul 18 07:59:02 kozue dhcpd[2804]: Sending on   Socket/fallback/fallback-net
Jul 18 07:59:02 kozue dhcpd[2804]: Server starting service.

Configure Ubuntu Server 18.04 Netplan Network configuration.

Ubuntu Networking

/etc/netplan/01-netcfg.yaml
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    eno2:
      dhcp4: yes
/etc/netplan/01-netcfg.yaml
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    eno2:
      dhcp4: no
      dhcp6: no
      addresses: [ 10.0.4.193/24 ]
      gateway4: 10.0.4.1
      nameservers:
        addresses: [ 8.8.8.8, 8.8.4.4, 1.1.1.1 ]
    enp1s0f0:
      dhcp4: no
      dhcp6: no
      addresses: [ 10.0.12.193/24 ]
      routes:
        - to: 10.0.8.0/24
          via: 10.0.12.254
          metric: 0
root@kozue:~# diff -u /root/orig/etc/netplan/01-netcfg.yaml /etc/netplan/01-netcfg.yaml
--- /root/orig/etc/netplan/01-netcfg.yaml       2019-07-18 06:08:34.453268041 +0900
+++ /etc/netplan/01-netcfg.yaml 2019-07-19 07:08:38.860083310 +0900
@@ -5,4 +5,18 @@
   renderer: networkd
   ethernets:
     eno2:
-      dhcp4: yes
+      dhcp4: no
+      dhcp6: no
+      addresses: [ 10.0.4.193/24 ]
+      gateway4: 10.0.4.1
+      nameservers:
+        addresses: [ 8.8.8.8, 8.8.4.4, 1.1.1.1 ]
+    enp1s0f0:
+      dhcp4: no
+      dhcp6: no
+      addresses: [ 10.0.12.193/24 ]
+      routes:
+        - to: 10.0.8.0/24
+          via: 10.0.12.254
+          metric: 0
+

following command will lost network connection.

sudo netplan apply
journalctl --unit=isc-dhcp-server
sudo tcpdump -nni enp1s0f0 port 67 or port 68
tail -f /var/log/syslog
ip address show
systemd-resolve --status
Jul 19 07:48:44 kozue dhcpd[2728]: Internet Systems Consortium DHCP Server 4.3.5
Jul 19 07:48:44 kozue sh[2728]: Internet Systems Consortium DHCP Server 4.3.5
Jul 19 07:48:44 kozue dhcpd[2728]: Copyright 2004-2016 Internet Systems Consortium.
Jul 19 07:48:44 kozue sh[2728]: Copyright 2004-2016 Internet Systems Consortium.
Jul 19 07:48:44 kozue dhcpd[2728]: All rights reserved.
Jul 19 07:48:44 kozue sh[2728]: All rights reserved.
Jul 19 07:48:44 kozue dhcpd[2728]: For info, please visit https://www.isc.org/software/dhcp/
Jul 19 07:48:44 kozue sh[2728]: For info, please visit https://www.isc.org/software/dhcp/
Jul 19 07:48:44 kozue dhcpd[2728]: Config file: /etc/dhcp/dhcpd.conf
Jul 19 07:48:44 kozue sh[2728]: Config file: /etc/dhcp/dhcpd.conf
Jul 19 07:48:44 kozue sh[2728]: Database file: /var/lib/dhcp/dhcpd.leases
Jul 19 07:48:44 kozue sh[2728]: PID file: /run/dhcp-server/dhcpd.pid
Jul 19 07:48:44 kozue dhcpd[2728]: Database file: /var/lib/dhcp/dhcpd.leases
Jul 19 07:48:44 kozue dhcpd[2728]: PID file: /run/dhcp-server/dhcpd.pid
Jul 19 07:48:44 kozue sh[2728]: Wrote 0 leases to leases file.
Jul 19 07:48:44 kozue dhcpd[2728]: Wrote 0 leases to leases file.
Jul 19 07:48:44 kozue dhcpd[2728]: Listening on LPF/eno2/4c:52:62:27:6a:99/10.0.4.0/24
Jul 19 07:48:44 kozue sh[2728]: Listening on LPF/eno2/4c:52:62:27:6a:99/10.0.4.0/24
Jul 19 07:48:44 kozue sh[2728]: Sending on   LPF/eno2/4c:52:62:27:6a:99/10.0.4.0/24
Jul 19 07:48:44 kozue dhcpd[2728]: Sending on   LPF/eno2/4c:52:62:27:6a:99/10.0.4.0/24
Jul 19 07:48:44 kozue dhcpd[2728]: Listening on LPF/enp1s0f0/00:1b:21:31:13:9b/10.0.12.0/24
Jul 19 07:48:44 kozue sh[2728]: Listening on LPF/enp1s0f0/00:1b:21:31:13:9b/10.0.12.0/24
Jul 19 07:48:44 kozue sh[2728]: Sending on   LPF/enp1s0f0/00:1b:21:31:13:9b/10.0.12.0/24
Jul 19 07:48:44 kozue sh[2728]: Sending on   Socket/fallback/fallback-net
Jul 19 07:48:44 kozue dhcpd[2728]: Sending on   LPF/enp1s0f0/00:1b:21:31:13:9b/10.0.12.0/24
Jul 19 07:48:44 kozue dhcpd[2728]: Sending on   Socket/fallback/fallback-net
Jul 19 07:48:44 kozue dhcpd[2728]: Server starting service.
Jul 19 07:49:13 kozue dhcpd[2728]: DHCPDISCOVER from 4c:52:62:26:e0:b5 via 10.0.8.254
Jul 19 07:49:14 kozue dhcpd[2728]: DHCPOFFER on 10.0.8.1 to 4c:52:62:26:e0:b5 (hotaru) via 10.0.8.254
Jul 19 07:49:14 kozue dhcpd[2728]: DHCPREQUEST for 10.0.8.1 (10.0.12.193) from 4c:52:62:26:e0:b5 (hotaru) via 10.0.8.254
Jul 19 07:49:14 kozue dhcpd[2728]: DHCPACK on 10.0.8.1 to 4c:52:62:26:e0:b5 (hotaru) via 10.0.8.254
Jul 19 07:52:17 kozue kernel: [ 9440.728187] device enp1s0f0 left promiscuous mode
tech/network/cisco/dhcp-relay-agent/dhcp-relay-agent.txt · Last modified: 2019/07/19 07:56 by wnoguchi