Set static IP connection type via command line

Post new topic   Reply to topic    DD-WRT Forum Index -> General Questions
Author Message
jstrbbt
DD-WRT Novice


Joined: 18 May 2023
Posts: 2

PostPosted: Thu May 18, 2023 6:08    Post subject: Set static IP connection type via command line Reply with quote
Hello everyone. I hope you're doing well. The title is very straight forward. I would like to know what is the command to use via the command line to change the connection type to a specific static IP, including the subnet and gateway. I couldn't find anything related to this in the forum. The reason why I want to do this is because I want to save time every time I need to set this. Here's a screenshot of what I mean. Thank you for your attention and help.

Sponsor
Alozaros
DD-WRT Guru


Joined: 16 Nov 2015
Posts: 6440
Location: UK, London, just across the river..

PostPosted: Thu May 18, 2023 7:01    Post subject: Reply with quote
nvram set wan_ipaddr=192.168.1.200 -----or what ever you have for those 3 lines
nvram set wan_gateway=192.168.1.201
nvram set wan_netmask=255.255.255.0
nvram commit

the last command saves it to the nvram...

p.s. same commands for the local interface but instead of wan use lan Wink

_________________
Atheros
TP-Link WR740Nv1 ---DD-WRT 55630 WAP
TP-Link WR1043NDv2 -DD-WRT 55723 Gateway/DoT,Forced DNS,Ad-Block,Firewall,x4VLAN,VPN
TP-Link WR1043NDv2 -Gargoyle OS 1.15.x AP,DNS,QoS,Quotas
Qualcomm-Atheros
Netgear XR500 --DD-WRT 55779 Gateway/DoH,Forced DNS,AP Isolation,4VLAN,Ad-Block,Firewall,Vanilla
Netgear R7800 --DD-WRT 55819 Gateway/DoT,AD-Block,Forced DNS,AP&Net Isolation,x3VLAN,Firewall,Vanilla
Netgear R9000 --DD-WRT 55779 Gateway/DoT,AD-Block,AP Isolation,Firewall,Forced DNS,x2VLAN,Vanilla
Broadcom
Netgear R7000 --DD-WRT 55460 Gateway/SmartDNS/DoH,AD-Block,Firewall,Forced DNS,x3VLAN,VPN
NOT USING 5Ghz ANYWHERE
------------------------------------------------------
Stubby DNS over TLS I DNSCrypt v2 by mac913
jstrbbt
DD-WRT Novice


Joined: 18 May 2023
Posts: 2

PostPosted: Thu May 18, 2023 7:50    Post subject: Reply with quote
Alozaros wrote:
nvram set wan_ipaddr=192.168.1.200 -----or what ever you have for those 3 lines
nvram set wan_gateway=192.168.1.201
nvram set wan_netmask=255.255.255.0
nvram commit

the last command saves it to the nvram...

p.s. same commands for the local interface but instead of wan use lan Wink


Thank you so much. Sorry to bother you. Is there any way to switch from PPOE to Static IP using these commands? For some reason it doesn't change. I have to go to the UI and switch to Static IP, I see the info I put is there and then I have to click "Apply Changes".

Edit: I found out how to do it. Just adding "rc restart" at the end of the whole thing. I also added something extra to switch the router between protocols.

Final command is the following:

Code:
nvram set wan_proto='static' && nvram set wan_ipaddr=192.168.1.200 && nvram set wan_gateway=192.168.1.201 && nvram set wan_netmask=255.255.255.0 && nvram commit && rc restart


If someone needs to switch from Static to PPPOE use the following:

Code:
nvram set wan_proto='pppoe' && nvram set pppoe_passwd='yourpassword' && nvram set pppoe_username='yourusername' && nvram commit && rc restart
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> General Questions All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum