0

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

schweik
  • 253
  • 2
  • 8
  • Why 4 nic per computer? you dont wanted to use inter vlan routing? – yagmoth555 Oct 10 '17 at 12:29
  • I did not compose all the workstations, but one reason the new NIC was added was the migration to 10Gbit, some workstations has second NIC to be alterantively connected to other LAN or Internet, on one motherboard the integrated NIC crashed but is stil detected besides the added NIC. Simply: so is the situation. – schweik Oct 10 '17 at 16:36

1 Answers1

0

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.

jvdmr
  • 136
  • 4
  • That is what I already try to do: – schweik Oct 10 '17 at 16:01
  • That is what I already try to do: 1. get all interface name except 'lo'; 2. set each interface UP; 3. test if the interface remains in the '... state UP ...'; 4. these 'state UP' interfaces I try with dhclient (while filtering on 'reject 10.0.0.0/8' and other possible wrong net); 5. skipping 'rejected' intefaces I get the best candidate interface. All the steps are timeouted and limited in repetition. In principle it shall work well, but somtimes it goes, sometimes not. I hope, that with udev, one can better automate some part of this complex work and can use the hot plug event detection. – schweik Oct 10 '17 at 16:22