|
When you disconnect the external network, your server host cannot give itself an IP address through DHCP: that would be a bit of a Catch-22. It might be easier to configure this if the server had two network interfaces: one for the internet connection and another for the local network that contains the clients. Then you could configure the first NIC to get its IP address with DHCP, and the other with a static private IP address and dnsmasq serving any clients through it. If you have just one network interface, you'll need to have two configuration sets: one for when the server has internet connectivity and gets its own IP address with DHCP from the router, and another for when it's acting as a server for the clients. The latter configuration would include a static private IP address for the server's network interface.
|
# ¿ Jul 9, 2016 18:51 |
|
|
# ¿ May 11, 2024 11:22 |
|
Hummer Driving human being posted:I can see how the server can't give itself an address through DHCP but it should be able to have a static IP address if it were running dnsmasq and not connected the the internet, correct? Sure it can, and I would almost say it _must_ have that. The server needs to have a valid IP address configuration for itself before it can serve others, even just for DHCP. It is generally recommended that DHCP servers should always have a static IP address, no matter what the OS. If a DHCP server's address changes while there are DHCP clients relying on it, those clients usually can no longer smoothly update their address leases, and once the leases expire, they will have to start the DHCP process from scratch. As a result, the clients will be without an IP address for a while, and may receive an address that is different from before, so their on-going TCP sessions will be cut off. That tends to make users unhappy.
|
# ¿ Jul 13, 2016 09:35 |
|
Hummer Driving human being posted:Can the server, not connected to the internet, assign itself an IP address if it's not connected to the internet or router? But you can just set a static IP address to the server's interface in that case. Just make sure it's excluded from the range of IP addresses the DHCP server software will offer to the clients. For example, if you decide to use IP address range 192.168.99.[1..254] for your private network, then the netmask would be 255.255.255.0: broadcast address would be 192.168.99.255 and "network address", in the rare case something needs it explicitly specified, will be 192.168.99.0. Then you decide to put the server as 192.168.99.1. On Debian-style systems including Ubuntu, you can do this by putting the following lines into /etc/network/interfaces: code:
Now any time the server detects a link on network interface eth0, it will automatically configure the interface as 192.168.99.1, whether dnsmasq or any other DHCP server is running or not. When configuring dnsmasq, you now know 192.168.99.1 is occupied by definition (that's the server you're running dnsmasq on). So the maximal range of IP addresses you can give to your DHCP clients is 192.168.99.[2 .. 254]. In dnsmasq configuration, that is: code:
Hummer Driving human being posted:The setup I'm trying to work out isn't connected to the internet at all. I'll download the necessary packages to the server with an internet connection then relocate the server to a location without internet access where the server will need to have an IP address and lease IP addresses to clients located on this internet-less LAN. Will dnsmasq do this? Yes. But when the server starts up, it will set up network interfaces before starting up any network services like dnsmasq. In that phase, the system cannot ask dnsmasq what its IP address should be because dnsmasq is not running yet at that point. And if you configure dnsmasq to start up before network interfaces, it will just go "oh look, there are no network interfaces running, so I cannot start up a DHCP service" and either abort with an error message, or just sit on its virtual rear end waiting for at least one network interface to become fully configured before it can start up a DHCP server on it. Background: When a DHCP server gives an IP address to a DHCP client, it will also tell the client: "This IP address is yours for the next <lease time> seconds. Once half of that is gone, call me again at <server's IP address> and I'll extend that lease for you." If the server does not know its own IP address yet, it cannot give this answer, and so cannot successfully act as a DHCP server. (Sorry about not going into details earlier - I was phoneposting.)
|
# ¿ Jul 13, 2016 20:22 |