-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset_static_ip.bat
More file actions
50 lines (42 loc) · 1.19 KB
/
set_static_ip.bat
File metadata and controls
50 lines (42 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
:: MotionNode POE: Set static ip script
:: This script will ssh in to a network connected MotionNode POE device
:: and set a new network configuration with a static ip address,
:: optionally also setting a gateway and dns resolver ip address.
::
:: Usage
::
:: set_static_ip.bat <host> <ip_address> <gateway> <dns_resolver>
::
:: set_static_ip.bat motionnode.local 192.168.1.100 192.168.1.1 192.168.1.1
::
:: # example without gateway or dns resolver:
::
:: set_static_ip.bat motionnode.local 192.168.1.100
@echo off
set "is_exit=0"
if [%1]==[] (
echo host address not provided.
set "is_exit=0"
)
if [%2]==[] (
echo static ip address not provided.
set "is_exit=0"
)
if is_exit==0 exit /b
set "host=%1"
set "ip=%2"
set "gateway=%3"
set "dns=%4"
echo.
echo Host: %host%
echo Static IP: %ip%
echo Static Gateway: %gateway%
echo Static DNS: %dns%
echo.
echo Setting Static IP...
set "cmd1=sudo rm /etc/netplan/*.yaml"
set "cmd2=sudo nmcli connection modify \"Wired connection 1\" ipv4.addresses \"%ip%/24\" ipv4.gateway \"%gateway%\" ipv4.dns \"%dns%\" ipv4.method manual"
set "cmd_ssh=ssh -t remote@%host% %cmd1%; %cmd2%"
%cmd_ssh%
echo.
echo After running, please power cycle the MotionNode POE device.