Hi I'm trying to configure my Raspberry PI to work as a dhcp server. Idea is that through eth0 interface I will connect switch, to which I can connect other devices. But I still want to keep ssh and internet access through the wlan0.
To achieve I have installed isc-dhcp-server and then configured it by adding configuration for the static ip address to the /etc/network/interfaces.d/eth0
allow-hotplug eth0
iface eth0 inet static
address 10.0.0.1
netmask 255.255.255.0
broadcast 10.0.0.255
gateway 10.0.0.1
Next I have added configuration for dhcp server to file /etc/dhcp/dhcpd.conf:
authorative
subnet 10.0.0.0 netmask 255.255.255.0 {
range 10.0.0.1 10.0.0.10;
option subnet-mask 255.255.255.0;
option broadcast-address 10.0.0.255;
option routers 10.0.0.1;
option domain-name "local-network";
option domain-name-servers 8.8.8.8, 8.8.4.4;
}
After that I have restarted Raspberry PI and everything seems fine I'm able to connect from my machine to it through the WiFi and other machines that are connected to switch are getting IP addresses from 10.0.0.2 to 10.0.0.10 (and I'm able to ssh to them through the configured Raspberry PI).
Biggest problem is that I'm not able to access internet from that Raspberry PI. When I type something like
ping 10.0.0.3
it works, but
ping 8.8.8.8
fails. After debugging the problem I managed to discover problem with command ip route
:
default via 10.0.0.1 dev eth0 proto dhcp src 10.0.0.2 metric 202
default via 192.168.0.1 dev wlan0 proto dhcp src 192.168.0.46 metric 303
10.0.0.0/24 dev eth0 proto dhcp scope link src 10.0.0.2 metric 202
192.168.0.0/24 dev wlan0 proto dhcp scope link src 192.168.0.46 metric 303
I have tried to remove default route via 10.0.0.1 and it helps temporary, but after sometime some process (I suspect dhcp server) recovers it. Of course I can write a daemon that will remove it all the time, but I'm looking for some better solution.
Update #1
Without dhcp server ip route
shows:
default via 192.168.0.1 dev wlan0 proto dhcp src 192.168.0.46 metric 303
10.0.0.0/24 dev eth0 proto kernel scope link src 10.0.0.1
169.254.0.0/16 dev eth0 scope link src 169.254.44.117 metric 202
192.168.0.0/24 dev wlan0 proto dhcp scope link src 192.168.0.46 metric 303
Thanks in advance
/etc/network/interfaces
or/etc/network/interfaces.d/*
containingiface eth0 inet dhcp
?