Ubuntu – Configuring DHCP-Server using dnsmasq

dhcpdnsmasq

I can't seem to make my DHCP Server (dnsmasq) work, even though there are so many tutorials on the internet. Somehow something doesn't work out for my setup.

What I have: A computer, a laptop, a router. I want following:
Computer <– eth0 –> laptop=DHCP-Server <– wifi –> router.

Why? If this works, I can connect another device instead of the computer to the laptop's eth0 and analyze its network traffic. But I can easily use the computer to check if this works first.

What did I do until now: Basically everthing I could find 😀
The laptop is running Linux Mint 17, which uses a NetworkManager, which automatically starts some kind of dnsmasq. I disabled this, by editing /etc/NetworkManager/NetworkManager.conf to look like this:

[main]
plugins=ifupdown,keyfile,ofono
#dns=dnsmasq

no-auto-default=54:42:49:70:E5:8E,

[ifupdown]
managed=false

Using sudo apt-get install dnsmasq I installed dnsmasq and edited the /etc/dnsmasq.conf to look like this:

interface=eth0
dhcp-range=192.168.2.210,192.168.2.230,255.255.255.0,12h
dhcp-option=3,192.168.2.1
log-dhcp

My thoughts here: Router's IP is 192.168.2.1 and it's giving out IPs from 192.168.2.100 to 192.168.2.199. So the laptop can give out IPs from 192.168.2.210 to 192.168.2.230.

When connecting the computer to the laptop's eth0 the computer tries to connect, but fails.

So i checked the laptop's tcpdump and could see lines like that:

22:29:21.141599 IP 0.0.0.0.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from 6c:f0:49:0a:25:61 (oui Unknown), length 300

which shows that the computer is sending out a broadcast DHCP request, right?
But I don't see any answer to that request. Same in Wireshark: DHCP requests/discovers from computer, but no answers.

In between I also tried to do some NAT masquerading in iptables and IP forwarding. If necessary I can remove that again.

When assigning a static IP for eth0 on the computer, it connects, but cannot connect to any website (I setup this connection in NetworkManager using IP 192.168.2.75, 255.255.255.0, Gateway: 192.168.2.1 and even DNS Server: 8.8.8.8).

Any help is appreciated! Thx

Best Answer

In the end the solution was to use the NetworkManager GUI to share the eth0 interface to other computers.

edit: I did everything stated in my initial post, and then the solution was to startup the network manager and to change the ethernet connection to "Shared to other computers". You can do this by doubleclicking the ethernet connection, select tab "IPv4 Settings" and then change the Method. Save. If your NetworkManager does not state any ethernet connection, just click "Add" and add one.

Related Question