0

I'm working on an NSIS-based installer that deploys software which uses a LAN9512-based USB-to-ethernet NIC.

When I attach said NIC to a new system, it's possible that Windows will automagically find its drivers, but on some Win10 systems, I've observed a failure to find the drivers, so I install the official vendor drivers as part of the procedure, prior to connecting the device.

Once the device drivers are installed, Windows configures the NIC for DHCP by default. I would like it to have a static IP address instead, as the first configuration it ever uses.

Is it possible to provide an additional file, or modify something ( eg. the .INF file that sometimes accompanies driver bundles ) in order to tell Windows to pre-configure the device with a static IP?

The installation will occur with elevated privileges as an NSIS-based installer is executed, but if the user doesn't have the device available to plug in, the NIC won't yet appear on the system, so assume it won't be possible to use 'netsh' to configure it during installation, and in future, when the device is plugged in ( after the installer has run, and elevation has been rescinded ), it will be too late to do it without elevating again ( which I'm trying to avoid ).

Target systems are unlikely to need reconfiguration, and USB-based NICs keep their configurations between replugs, so pre-configuration is key here.

  • Configuration of DHCP/IP settings is independent of the driver. The driver is just the piece that lets the kernel talk to the card, the IP stack is in the kernel. I'm not a big windows person, but I imagine netsh scripting will do the trick: technet.microsoft.com/en-us/library/bb490939.aspx – MaQleod Jan 9 '18 at 5:31
  • Agreed, 'netsh' will work to assign a static IP, but it will need elevation again once the device has been plugged in. The goal here is a one-time elevation when installing the entire software suite, before the hardware is available. ;-) But I'm also curious about the way to pull off this feat in GNU/Linux and other *nix:likes ( I suspect it's easier ); if you are more familiar with such, what technique would you use to achieve the goal ( pre-configured static IP for USB-ethernet NIC based on VID+PID )? – bernz Jan 9 '18 at 16:37
  • Oh, since I didn't state it in the question, I'm also trying to avoid adding regular users to special groups like "Network Configuration Operators" ( because it's only a one-time change that's needed, and better to not let users muck about with stuff if they don't absolutely need to ). – bernz Jan 9 '18 at 16:39
  • On nix you'd just need a script that gets elevated via sudo. So you'd write your script in bash or in python and include the driver installation as well as network config commands, and once elevated, the script would have the permissions it needed to run what it needed to configure a network adapter with a given IP and update the routing table accordingly. Exactly what commands you use would be more platform specific. – MaQleod Jan 9 '18 at 18:15
  • Yeah, I was thinking of bootstrapping the customization via udev, and a low-effort search revealed this somewhat-related article: monblocnotes.com/node/1895 ...it isn't a solution, but a good starting point for this type of task. – bernz Jan 10 '18 at 16:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.