netsh and windows 7

Sxotty

Legend
So to make this short.

I have a bunch of printers I wanted to network in a lab. The computers are a mix of laptops and desktops. The desktops have two NICs, and the laptops connect to the internet wirelessly.

I have all the ethernet run and hooked up some routers, but then discovered that windows could not tell which NIC to use for internet and which one to use for the LAN. So I turned of DHCP and then it works, but the IPs have to be assigned manually. This is no problem for desktops, but laptops leave the lab and get hooked up where they need to have the ip assigned automatically.

In the past to deal with this issue I just did the netsh stuff.


netsh -c interface dump c:\lab
netsh -f c:\lab

netsh -c interface dump c:\home
netsh -f c:\home

Made the second command into a bat file and then users could simply click the bat for home or lab. Unfortunately it doesn't seem to be working in windows 7. I did run as admin but it was no joy. I even tried more specific bat files such as

netsh interface ip set address name="Local Area Connection" static 192.168.0.1
netsh interface ip set address "Local Area Connection" dhcp

When I did this it turned off dhcp, and entered the ip address, but then it showed up as manually enter ip address with all blanks instead of turning dhcp back on for some reason. I restarted the laptop and it worked, but I don't remember netsh requiring restarts in the past.

Any advice on how to easily deal with this situation? Either to get netsh to work right, use the alternate ip config tab (which I never noticed previously) or some other idea?

Thanks guys and gals

edit: I cannot try not, but after reading about the alternate config tab it actually sounds like it may do the trick all by itself, that is epically awesome if so.
 
Well this may not be the most elegant or even correct solution for you but you can manually set the interface metric for adapters which governs which adapter is used first for routing to the internet.

You can get to it through properties on the network adapter -> ipv4 -> advanced - uncheck automatic metric and manually set a metric for both. Lower metrics will be preferred over higher ones.

Alternatively I use a program called NetRouteView to more easily change these if I want Windows to round robin packets on both of my Internet connections or to prefer one over the other.

I'm sure there's a better/more elegant/more correct way to do this. :p But that might get you by until you find a better way.

Regards,
SB
 
Thanks SB I am hopeful that between that idea, and the alternate config I can get everything up and working well.

Rude Curve: They have two NICs b/c one ethernet line goes to internet and beyond my control (through the walls to who knows where) the other ethernet line goes to a router (with dhcp turned off) and then to printers.


MfA: I had a DHCP server setup originally, but like I said the computers tried to get internet over the lan with no internet connection instead of the correct addapter (the wireless for the laptops, and the original NIC for the desktops).

I think with SB's idea I probably could have gotten that to work, but there is still the worry that the printers IP would change if someone messed about with them, so it seemed easier just to go static for everything. I do believe there is a way to make the printers have a static ip out of the range of the DHCP server, but I wasn't sure how to do it and did not want to take any more time trying to figure all this mess out.
 
it's not hard to set up the DHCP : you bind printers's MAC addresses to IPs (192.168.0.11, 192.168.0.12 etc.) then set a range for dynamic allocation (such as 192.168.0.100 to 192.168.0.199)

it's worth it. it's funny, as you're doing more complex and advanced stuff.

you may also bind MAC addresses to names in a local DNS server, and this DNS server bind the names to static IP addresses. (there's a widespread DNS server under linux/unix called "Bind" :LOL: )

for internet access you might use a proxy (if that's good enough) and ask users to set up proxy in their browser. there a single machine you own is accessing the internet on behalf of the desktops and laptops and it's simple enough.

the network segregation you're doing can also be done with VLANs (V stands for virtual). a nice complex bitch which allows to do it with one physical NIC per computer (well supported by linux, ill-supported by windows XP where it relies on NIC's driver - dunno about vista/7). router/switch complexity ensues.
 
I had a DHCP server setup originally, but like I said the computers tried to get internet over the lan with no internet connection instead of the correct addapter (the wireless for the laptops, and the original NIC for the desktops).
Then you did something wrong :p

Somehow you were pushing route 0.0.0.0 on the client.
 
You could have the router take care of the routing (through a single NIC), which is probably the easiest solution, or use "route add" to set up static routes on the Windows computers and have them do the routing themselves.
 
You can get quite tricky with batchfiles and route ... my openvp connection batch files parse nslookup output to add routes to things I want to route over VPN for instance. Also to put in a static route to my openvpn server across my physical interface, since it pushes the route for the subnet it's on (which would put the client in a nice infinite loop, took me a while to figure out what was going wrong).

That said, I still think you just did something wrong with your DHCP server setup ... do you use *nix? Does your dhcpd.conf specify "option routers"? (I don't think it should.)
 
Ok so I ended up using the alternative config and it appears to work perfectly actually. So I have no DHCP server, static IPs on the printer and in the alternative configs. Everything is happy and works. If I have to do this again though I will try some of the ideas mentioned here.

I do appreciate the help.
 
Back
Top