Skip to content

Instantly share code, notes, and snippets.

@islander
Created February 25, 2013 12:20
Show Gist options
  • Save islander/5029481 to your computer and use it in GitHub Desktop.
Save islander/5029481 to your computer and use it in GitHub Desktop.
Windows XP NAT start
@echo off
REM В кавычках укажите имя внутреннего интерфейса, с учетом регистра
REM Лучше переименуйте интерфейсы по-английски
set int="int"
REM здесь укажите имя внешнего интерфейса
set ext="ext"
sc stop RemoteAccess > NUL
sc stop SharedAccess > NUL
sc config SharedAccess start= disabled > NUL
sc config TapiSrv start= demand > NUL
sc config RasAuto start= demand > NUL
sc config RasMan start= demand > NUL
echo Enable routing ...
echo Windows Registry Editor Version 5.00 > re.reg
echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters] >> re.reg
echo "IPEnableRouter"=dword:00000001 >> re.reg
regedit /s re.reg
del /q re.reg
echo OK.
REM Раскомментируйте в случае если ошибка "нет записей"
netsh routing ip add interface name=%int% state=enable > NUL
netsh routing ip add interface name=%ext% state=enable > NUL
echo Setting up NAT...
netsh routing ip nat uninstall > NUL
netsh routing ip nat install
echo Enable NAT on internal interface...
netsh routing ip nat add interface name=%int% Private
echo Enable NAT on external interface...
netsh routing ip nat add interface name=%ext% Full
echo Now enable Routing and Remote Access...
sc config RemoteAccess start= auto > NUL
net start RemoteAccess
netsh routing ip nat show interface
echo Setting up DNS for NAT...
netsh routing ip dnproxy uninstall > NUL
netsh routing ip dnsproxy install
netsh routing ip dnsproxy set interface %ext% mode=disable > NUL
netsh routing ip dnsproxy set interface %int% mode=enable > NUL
netsh routing ip dnsproxy show interface %int%
echo Setting up DHCP...
netsh routing ip autodhcp uninstall > NUL
netsh routing ip autodhcp install
netsh routing ip autodhcp set interface %ext% mode=disable > NUL
netsh routing ip autodhcp set interface %int% mode=enable > NUL
netsh routing ip autodhcp set global 192.168.6.0 255.255.255.0
netsh routing ip autodhcp add exclusion 192.168.6.0
for /l %%i in (1,1,32) do netsh routing ip autodhcp add exclusion 192.168.6.%%i
netsh routing ip autodhcp add exclusion 192.168.6.255
netsh routing ip autodhcp show interface %int%
echo Done.
pause
@echo off
sc stop RemoteAccess > NUL
sc stop SharedAccess > NUL
sc config SharedAccess start= disabled > NUL
sc config TapiSrv start= demand > NUL
sc config RasAuto start= demand > NUL
sc config RasMan start= demand > NUL
echo Disable routing ...
echo Windows Registry Editor Version 5.00 > re.reg
echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters] >> re.reg
echo "IPEnableRouter"=dword:00000000 >> re.reg
regedit /s re.reg
del /q re.reg
echo OK.
echo Stopping NAT...
netsh routing ip nat uninstall > NUL
echo Now disable Routing and Remote Access...
sc config RemoteAccess start= disabled > NUL
echo Stopping DNS for NAT...
netsh routing ip dnsproxy uninstall > NUL
echo Stopping DHCP...
netsh routing ip autodhcp uninstall > NUL
echo Done.
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment