While preparing the mini forensic system I hung on a problem: Let us imagine, we prepare a usb-flash booted linux for lot of diferent workstations. While setting up the network (ipv4 dhcp) we can find more than one LAN interfaces, and someone is connected, someone not, but hopefully one of them is connected into the private LAN (eg. 192.168.20.0/24), and only this interface should be set up.
Perhaps it can be solved with some udev rules, but I cannot find where they are and how they could be modified. At present I use my own /etc/rc.local script toghether with some modification of dhclient.conf (refuse network), but even though it runs somehow (better said: it walks) it is not reliable and many times it does not finish succesfully the local cifs mounts, even on the same workstation.
Can somebody show me the way how to solve it?
Details:
- the private LAN is isolated with one managable switch
- local dnsmasq server responses exclusively in this private LAN
- each workstation can have 1 - 4 (wire) NIC
- some workstations are connected not only into private LAN, but also can have some NIC configured by some other dhcp-server or can have static IP - but those interfaces should be ignored
The goal is: after the boot to get dhcp address and connect to the local network data sorage.
Thank a lot
There's no way to detect which NIC is on the private LAN without activating them.
My suggestion: activate the NIC's one by one and perform a dhcp request. If you get a timeout, that NIC is not on a dhcp LAN (static ip) and you can disable it again. If you get a response you know if that NIC is on the correct subnet, and you can leave it enabled or disable it if it is the wrong subnet.
Alternatively, you could 'reserve' an ip in the dhcp range so that it won't be handed out to other clients. Then you can assign that ip to each NIC in turn, activate them, and check if you can reach the network storage. If you can't, disable that NIC and move on to the next one. Once you've found the correct NIC, you can either keep the reserved ip (if you only have 1 of those bootable usb's in use at any time), or reconfigure the NIC to get a different ip from dhcp.