netsh and windows 7

Discussion in 'General Discussion' started by Sxotty, Mar 25, 2011.

  1. Sxotty

    Veteran

    Joined:
    Dec 11, 2002
    Messages:
    4,870
    Likes Received:
    330
    Location:
    PA USA
    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.
     
  2. Silent_Buddha

    Legend

    Joined:
    Mar 13, 2007
    Messages:
    16,046
    Likes Received:
    4,994
    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
     
  3. MfA

    MfA
    Legend

    Joined:
    Feb 6, 2002
    Messages:
    6,744
    Likes Received:
    469
    Why not just setup a DHCP server for your lab?
     
  4. RudeCurve

    Banned

    Joined:
    Jun 1, 2008
    Messages:
    2,831
    Likes Received:
    0
    Why do the computers need two NICs?:???:
     
  5. Sxotty

    Veteran

    Joined:
    Dec 11, 2002
    Messages:
    4,870
    Likes Received:
    330
    Location:
    PA USA
    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.
     
  6. Blazkowicz

    Legend Veteran

    Joined:
    Dec 24, 2004
    Messages:
    5,607
    Likes Received:
    256
    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" :lol2: )

    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.
     
  7. MfA

    MfA
    Legend

    Joined:
    Feb 6, 2002
    Messages:
    6,744
    Likes Received:
    469
    Then you did something wrong :p

    Somehow you were pushing route 0.0.0.0 on the client.
     
  8. Frank

    Frank Certified not a majority
    Veteran

    Joined:
    Sep 21, 2003
    Messages:
    3,187
    Likes Received:
    59
    Location:
    Sittard, the Netherlands
    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.
     
  9. MfA

    MfA
    Legend

    Joined:
    Feb 6, 2002
    Messages:
    6,744
    Likes Received:
    469
    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.)
     
  10. Sxotty

    Veteran

    Joined:
    Dec 11, 2002
    Messages:
    4,870
    Likes Received:
    330
    Location:
    PA USA
    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.
     
Loading...

Share This Page

  • About Us

    Beyond3D has been around for over a decade and prides itself on being the best place on the web for in-depth, technically-driven discussion and analysis of 3D graphics hardware. If you love pixels and transistors, you've come to the right place!

    Beyond3D is proudly published by GPU Tools Ltd.
Loading...