Sample Header Ad - 728x90

How to setup dhcp server and client on linux local virtual network interfaces

0 votes
1 answer
2124 views
For my task i need to dump dhcp client-server exchange in local linux machine. 1. First of all i clone and build dhcp server and client from ISC dhcp sources - https://github.com/isc-projects/dhcp . 2. Create and setup tap interfaces in bridge for my experiments:
sudo ip link add test_eth0 type tap
sudo ip link add test_eth1 type tap
sudo ip link add test_eth2 type tap

sudo ifconfig test_eth0 up
sudo ifconfig test_eth1 up
sudo ifconfig test_eth2 up

sudo ifconfig test_eth0 10.1.1.7 netmask 255.255.255.0 up

sudo ip link add test_br0 type bridge
sudo ip link set dev test_eht0 master test_br0
sudo ip link set dev test_eht1 master test_br0
sudo ip link set dev test_eht2 master test_br0
sudo ip link set test_br0 up
3. Start dhcpd server
./dhcpd -d -f # start dhcp daemon in foreground mode
with dhcpd.conf:
...
subnet 10.1.1.0 netmask 255.255.255.0 {
  range 10.1.1.3 10.1.1.254;
  option routers 10.1.1.1; 
}
...
4. Start dhclient specifying target interface and dhcp server:
./dhclient -lf ./dhclient.leases test_eth1 -s 10.1.1.0 -v
client output:
...
DHCPDISCOVER on test_eht1 to 10.1.1.0 port 67 interval 3
DHCPDISCOVER on test_eht1 to 10.1.1.0 port 67 interval 6
DHCPDISCOVER on test_eht1 to 10.1.1.0 port 67 interval 11
...
I expected that after starting the client, it will detect a running server, which will give a dynamic address to the test_eth1 interface and i can dump it with dhcpdump, but i'm not so good in networking as in my imagine.
Asked by stupidnix (1 rep)
Jul 15, 2021, 07:23 AM
Last activity: May 13, 2025, 02:02 AM