0

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
  1. Start dhcpd server

sudo ./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; 
}
...
  1. Start dhclient specifying target interface and dhcp server:

sudo ./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.

3
  • Ahh, just remembered dummy interfaces don't actually route any traffic. Use network namespaces instead superuser.com/questions/1229674/…
    – hardillb
    Commented Jul 15, 2021 at 12:46
  • i change interface on tun, but it is not working
    – stupidnix
    Commented Jul 15, 2021 at 13:47
  • Use network namespaces as described in the other question, it really is the right solution
    – hardillb
    Commented Jul 15, 2021 at 13:52

1 Answer 1

0

You need to manually assign an address to at least one of the test interfaces, this is the one that the DHCP server will bind to and then hand out addresses to the other interfaces.

As it is dhcpd has no way to know which interface to bind to.

You will also need to add all the test interfaces to a bridge so they are "wired" together.

2
  • set ip for one interface ``` sudo ifconfig test_eth0 10.1.1.7 netmask 255.255.255.0 up ``` create bridge ``` sudo ifconfig sudo ip link add br0 type bridge sudo ip link set dev test_eht0 master br0 sudo ip link set dev test_eht1 master br0 sudo ip link set dev test_eht2 master br0 sudo ip link set br0 up ``` but it is still not working...
    – stupidnix
    Commented Jul 15, 2021 at 10:29
  • Edit the original question, do not try and details like this in comments.
    – hardillb
    Commented Jul 15, 2021 at 10:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .