Skip to content

Instantly share code, notes, and snippets.

@greenpeas
Last active August 8, 2018 04:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save greenpeas/0c06d49ad138ceda89376830ec4bc88a to your computer and use it in GitHub Desktop.
Save greenpeas/0c06d49ad138ceda89376830ec4bc88a to your computer and use it in GitHub Desktop.
Add route for host
@echo off
setlocal EnableDelayedExpansion
set myServer=google.ru
for /f "tokens=1,2 delims=[]" %%a IN ('ping -n 1 -w 0 !myServer!') DO (
if "%%b" NEQ "" set ip=%%b
)
rem echo %myServer% ip is %ip%
route delete %ip% MASK 255.255.255.255 192.168.137.1
route add %ip% MASK 255.255.255.255 192.168.137.1
rem pause
#!/bin/bash
# dig +short yandex.ru
# getent hosts yandex.ru | awk '{ print $1 }'
IP=`host yandex.ru | awk '{ print $4 }'`
echo $IP
sudo route add -net $IP netmask 255.255.255.255 gw 192.168.137.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment