I've running dnsmasq to handle my LAN DHCP and DNS needs since the days when my router was a 256MB Raspberry Pi B - these days it's a second hand ex-office PC (gigabit fibre needs a fast router) but it still runs dnsmasq to dole out the static and dynamic IP addresses on the LAN. Only the router itself and the service jails have static IPs. For the jails it's set in the jail configuration rather than being handed out by DHCP because they all use the same NIC, but I have names for them all in dnsmasq (well hosts.d/lan.hosts).
Perfectly fine if you never have to phone them ! :-)
I leave DHCP running so that 'guests' can simply log into to the wifi or plug into the Ethernet and they are up and away: Servers and printers and routers/wifipoints live in the 'static space' I have configured on the router DHCP.
So random desktops laptops phones TVs and suchlike are all on DHCP somewhere between 192.168.0.0 and 192.168.0.99
Routes and wifi points are all static and above 192.168.0.240
servers and printers live in the space between 192.168.0.100 and
192.168.0.240
I don't run a local DNS any more as the network is pretty simple these days - I went through a conscious 'box reduction' exercise a few years back. I just use host files or simply the iP addresses.
Well what is simple depends on what you are doing.
My network is there to allow me to have a central data and media server
- just the one - and one printer. These are the only 'servers' on the network.
Bridges switches and routers are also staticed, but everything else is a client. Why make things difficult expecting e.g. a visitor with a laptop set up a static IP.
I want to be able to access any file on any machine from whatever screen and keyboard I happen to be sitting in front of at the moment. But never mind, my router offers a "always give this MAC the same IP every time" setting. Guests and their phones may vary, but the number of my own machines at home is pretty constant, so no need to come back to that setting often. I have to do it once anyway, because the groups "standard" and "my computers" have different filters and use of blacklist.
On a sunny day (Tue, 15 Mar 2022 10:04:42 +0000) it happened The Natural Philosopher snipped-for-privacy@invalid.invalid wrote in <t0pobr$hkm$ snipped-for-privacy@dont-email.me:
Works perfectly here on RPi 4 8 GB: raspi99: ~ # ifconfig eth0:1 192.168.178.100 up
Why? There are no files on any machines of any interest at all - everything is on the server!
But never
The argument between 'set machines up statically' and 'assign fixed addresses by DHCP' is almost totally balanced.
- the end result is identical
- the amount of configuration required is very similar .
- neither gets rid of the need for host files or DNS.
- the DHCP case is slightly more complicated if you change a network card or motherboard.
In my case I don't change what has worked historically since really before I had internet at all - when access was via a dial up modem on a windows PC. And then ISDN on a Cisco router
Back then DHCP was almost unheard of. So a static home network was de rigeur. Then I progressed to a static home network with DHCP clients when broadband appeared.
"NEW shiny thing make everything all better, say clever science man yesterday.
Science man say shiny thing is telly and books. And good for seeing photos of you and everyone, and also naked people who do mucky things.
Science man say shiny thing ‘changes game’ and now all the other science men must go away and be sad.
Science man say: “All things everyone have are rubbish. Look! Telly and books! That will be £900 please thank you.”
Nikki, a girl who has had 27 birthdays and works in a big building, say: “Oooooooooh. It do telly. I will see telly on it and make it help me buy nice hats.
“And look! It fit in bag where I have keys and little talkie box and red goo I put on face.”
Tom, all grown-up man from busy place, say: “I very busy man who need see telly on big metal tube that take me to busy job. But look! It also play game! I play noisy game on metal tube and be happy.”
And Bill, really, really old man who sits in chair all day, say: “It make words happen by pointing at it. Oooooooooh. I will make it help me say clever words to newspaper about gypsies and Pakistan.
“AND IT DO TELLY!”
HTT the Daily Mash. 11 years ago....when smart phones were a novelty
I have a laptop that sometimes goes on the road. On the road, it gets whatever IP someone's DHCP server assigns. At home, I want it to have a static IP so I can connect to/from it locally (usually by name). Having the (static, local) IP set on my DHCP server makes transition from home to on-the-road seamless.
The laptop has a configuration option that allows me to manually switch from a home to a travelling profile. I always used to get reminded of that the hard way.
Well I never knew that. Does it just configure the OS to listen for
*incoming* connections on the temporary IP? Does traffic from the PC to an external device just get sent with the permanent IP, except in the special case where it is in response to incoming traffic addressed to the temporary IP? In other words, is Unix applying a bit on intelligence here?
Depends on the mask. The two interfaces/networks are completely equivalent but they can't have overlapping "IP masks" or "DNS masks". The network software knows where to route and what address to use by checking the address and seeing in which mask it fits. Hence the "/24" which means it's a network where the first three parts of the IPv4 address are always the same, because 3x 8 = 24 (because one part takes up 8 bits).
There may be subtleties wrong with this explanation but that's the gist.
The two (or more) IP configurations are just that multiple configurations and should be to non overlapping subnets or to individual hosts /32 so that the kernel can work out from the destination which local IP address to use when assembling the initial packet (using a /32 for multiple hosts in the same subnet is a bit of a hack - no outgoing packet will match that network so only reply packets will go out carrying it as the local address).
It occurred to me that a small explanation of IP addressing and routing might make things clearer. Those who know how to suck eggs please accept my apologies.
Every IP packet carries a source destination and a target destination. This comprises (in IPV4 land) a four octet (32 bit) IP address usually expressed as a dotted quad, and a similarly sized *port* address. Unless subject to address translation, these are preserved across an end to end connection.
The target IP address, however, is used at every router the packet transits, to select the next hop destination.
Any routing interface that receives a packet whose destination is unknown to it, either directly, or via a 'next hop' will return a 'destination unreachable' packet to the sender.
In the case of local networks, in the 192.168.*.* space, which is reserved as a *private* space for up to 256 class C (256 sized) networks, these packets are not route-able on the internet, and if you send a packet with this address to the internet - your upstream ISP - you will (should!) get a destination unreachable response.
IN a 256 sized network, two addresses have special meaning. So e.g.
192.168.0.0 refers not to a specific machine but to the *whole network*, and e.g/ 192.168.0.255 is a *broadcast address* that will be sent to every single machine on the network.
So in the context of a small private network with up to 253 machines on it, the standard configurations will be one of these class Cs, with one of the address being that of a router which connects it to the internet.
Ignoring the complexities of net masks, every machine will have, or be assigned an IP address , a net mask, and a default route, and that default route will be the internet router, so that every device on the network when trying to send to an address not in the network, will send it to the router, as the 'next hop'. In return the router will know on which Ethernet address any given IP address is to be found, so can accurately return packets from remote hosts to the correct machine.
If you wish to add another network, one way to do it is to put an extra interface on the router. The router then 'knows' where that network is, and can route packets to it.
But the issue here was simply to access a piece of kit that happened to be on a different network address - there is no need to reconfigure the router - but to simply add a volatile interface to a single machine.
It works because *all* IP stacks understand more than one interface card and more than one interface address and have a basic (static) routing function built in to them, so that e.g. a packet for a given network will always be routed via the interface (physical or virtual) that has that network address bound to it, just as packets for every unknown network (one that the system does NOT have an interface bound to) will be sent to the next hop defined in the static default route.
Multiple interfaces will have different processes bound to them, if a packet for a wrong interface or IP address is recieved, it will be discarded, if it arrives on a physical interface that has more than one IP address bound to it, it will be sent to the process which is both bound to it, and whose port is bound to the destination port of the incoming packet.
So the incoming packet algorithm is to look for a combination of IP address and IP port that corresponds to the incoming packets destination. If a process matching those exists, the packet will be passed to it. If not it will be bounced or silently discarded.
The outgoing algorithm is to select an interface that has either the default route for the packet destination address, or the interface that matches the network of the destination address.
Now consider the situation one of my engineers once encountered when two interfaces were present and *each one* of them had a default route attached to it.
Gotta love Windows NT .....not!
The exactly 50% packet loss was a but of a giveaway. ...
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.