Vì ở cty và ở nhà mình đều dùng IP tĩnh để kết nối LAN, nhưng ở cty và ở nhà dùng 2 dãy IP khác nhau nên việc chuyển đổi qua lại bằng tay rất mất công, mình mày mò và phát hiện ra một cách thiết lập IP một cách nhanh chóng thông qua lệnh netsh trên Windows (Trên Linux thì dùng ifconfig).

Đầu tiên tạo ra file iphome.txt (c:\iphome.txt) để thiết lập IP cho mạng ở nhà tương tự như sau:

# ———————————-# Interface IP Configuration# ———————————-pushd interface ip
# Interface IP Configuration for "Local Area Connection"
set address name="Local Area Connection" source=static addr=192.168.1.252 mask=255.255.255.0
set address name="Local Area Connection" gateway=192.168.1.1 gwmetric=0
set dns name="Local Area Connection" source=static addr=192.168.1.1 register=PRIMARY
set wins name="Local Area Connection" source=static addr=none
popd
# End of interface IP configuration

Mở cửa sổ Command Prompt (Window Key + R) và gõ vào lệnh:

netsh -f c:\iphome.txt

Ta thu được kết quả như sau:

Làm tương tự cho mạng ở cty.

Nếu “làm biếng” ta có thể tạo ra file setHomeIp.bat như sau, rồi sau đó chỉ việc click vào nó :D

<code>
@echo offecho Start Interface IP Configuration…
netsh -f c:iphome.txt
echo End of interface IP configuration!
</code>
 

Theo doquocduy.wordpress.com