How to restore /etc/config/network for NETGEAR R7800

Hi,

I'm running OpenWRT 21.02.0 on a NETGEAR R7800 and, due to me being stupid while trying to backup the file, I accidentally deleted /etc/config/network. As you might have guessed, I have no backup of said file but I can still SSH into the router (however, the router is not physically located near me). Note that I do have a full OpenWRT backup, downloaded from LuCI, after I realized what happend.

I was able to run ubus list network.interface.* and ifstatus <all interfaces> as I thought they might help restoring /etc/config/network. Here is their output, respectively.

ubus list network.interface.*

network.interface.lan
network.interface.loopback
network.interface.wan
network.interface.wan6
network.interface.wgnet

ifstatus <all interfaces>
{
	"up": true,
	"pending": false,
	"available": true,
	"autostart": true,
	"dynamic": false,
	"uptime": 60546,
	"l3_device": "br-lan",
	"proto": "static",
	"device": "br-lan",
	"updated": [
		"addresses",
		"routes"
	],
	"metric": 0,
	"dns_metric": 0,
	"delegation": true,
	"ipv4-address": [
		{
			"address": "192.168.0.1",
			"mask": 24
		}
	],
	"ipv6-address": [
		
	],
	"ipv6-prefix": [
		
	],
	"ipv6-prefix-assignment": [
		{
			"address": "fdc8:1a50:cfb1::",
			"mask": 60,
			"local-address": {
				"address": "fdc8:1a50:cfb1::1",
				"mask": 60
			}
		}
	],
	"route": [
		{
			"target": "0.0.0.0",
			"mask": 0,
			"nexthop": "192.168.0.254",
			"source": "0.0.0.0/0"
		}
	],
	"dns-server": [
		
	],
	"dns-search": [
		
	],
	"neighbors": [
		
	],
	"inactive": {
		"ipv4-address": [
			
		],
		"ipv6-address": [
			
		],
		"route": [
			
		],
		"dns-server": [
			
		],
		"dns-search": [
			
		],
		"neighbors": [
			
		]
	},
	"data": {
		
	}
}
{
	"up": true,
	"pending": false,
	"available": true,
	"autostart": true,
	"dynamic": false,
	"uptime": 60552,
	"l3_device": "lo",
	"proto": "static",
	"device": "lo",
	"updated": [
		"addresses"
	],
	"metric": 0,
	"dns_metric": 0,
	"delegation": true,
	"ipv4-address": [
		{
			"address": "127.0.0.1",
			"mask": 8
		}
	],
	"ipv6-address": [
		
	],
	"ipv6-prefix": [
		
	],
	"ipv6-prefix-assignment": [
		
	],
	"route": [
		
	],
	"dns-server": [
		
	],
	"dns-search": [
		
	],
	"neighbors": [
		
	],
	"inactive": {
		"ipv4-address": [
			
		],
		"ipv6-address": [
			
		],
		"route": [
			
		],
		"dns-server": [
			
		],
		"dns-search": [
			
		],
		"neighbors": [
			
		]
	},
	"data": {
		
	}
}
{
	"up": true,
	"pending": false,
	"available": true,
	"autostart": true,
	"dynamic": false,
	"uptime": 60562,
	"l3_device": "eth0.2",
	"proto": "dhcp",
	"device": "eth0.2",
	"metric": 0,
	"dns_metric": 0,
	"delegation": true,
	"ipv4-address": [
		{
			"address": "192.168.1.206",
			"mask": 24
		}
	],
	"ipv6-address": [
		
	],
	"ipv6-prefix": [
		
	],
	"ipv6-prefix-assignment": [
		
	],
	"route": [
		{
			"target": "0.0.0.0",
			"mask": 0,
			"nexthop": "192.168.1.254",
			"source": "192.168.1.206/32"
		}
	],
	"dns-server": [
		"192.168.1.254"
	],
	"dns-search": [
		
	],
	"neighbors": [
		
	],
	"inactive": {
		"ipv4-address": [
			
		],
		"ipv6-address": [
			
		],
		"route": [
			
		],
		"dns-server": [
			
		],
		"dns-search": [
			
		],
		"neighbors": [
			
		]
	},
	"data": {
		"leasetime": 86400
	}
}
{
	"up": true,
	"pending": false,
	"available": true,
	"autostart": true,
	"dynamic": false,
	"uptime": 60550,
	"l3_device": "eth0.2",
	"proto": "dhcpv6",
	"device": "eth0.2",
	"metric": 0,
	"dns_metric": 0,
	"delegation": true,
	"ipv4-address": [
		
	],
	"ipv6-address": [
		{
			"address": "2001:b07:5d29:e1e9:7ad2:94ff:fe52:27ff",
			"mask": 64
		}
	],
	"ipv6-prefix": [
		
	],
	"ipv6-prefix-assignment": [
		
	],
	"route": [
		{
			"target": "2001:b07:5d29:e1e9::",
			"mask": 64,
			"nexthop": "::",
			"metric": 256,
			"source": "::/0"
		},
		{
			"target": "::",
			"mask": 0,
			"nexthop": "fe80::7a29:edff:fe32:2593",
			"metric": 640,
			"valid": 1397,
			"source": "2001:b07:5d29:e1e9:7ad2:94ff:fe52:27ff/64"
		}
	],
	"dns-server": [
		"2001:b07:5d29:e1e9:7a29:edff:fe32:2593"
	],
	"dns-search": [
		
	],
	"neighbors": [
		
	],
	"inactive": {
		"ipv4-address": [
			
		],
		"ipv6-address": [
			
		],
		"route": [
			
		],
		"dns-server": [
			
		],
		"dns-search": [
			
		],
		"neighbors": [
			
		]
	},
	"data": {
		"passthru": "0017001020010b075d29e1e97a29edfffe322593"
	}
}
{
	"up": true,
	"pending": false,
	"available": true,
	"autostart": true,
	"dynamic": false,
	"uptime": 53574,
	"l3_device": "wgnet",
	"proto": "wireguard",
	"updated": [
		"addresses",
		"routes"
	],
	"metric": 0,
	"dns_metric": 0,
	"delegation": true,
	"ipv4-address": [
		{
			"address": "10.0.0.1",
			"mask": 24
		}
	],
	"ipv6-address": [
		
	],
	"ipv6-prefix": [
		
	],
	"ipv6-prefix-assignment": [
		
	],
	"route": [
		{
			"target": "10.0.0.2",
			"mask": 32,
			"nexthop": "0.0.0.0",
			"source": "0.0.0.0/0"
		},
		{
			"target": "10.0.0.3",
			"mask": 32,
			"nexthop": "0.0.0.0",
			"source": "0.0.0.0/0"
		},
		{
			"target": "10.0.0.4",
			"mask": 32,
			"nexthop": "0.0.0.0",
			"source": "0.0.0.0/0"
		}
	],
	"dns-server": [
		
	],
	"dns-search": [
		
	],
	"neighbors": [
		
	],
	"inactive": {
		"ipv4-address": [
			
		],
		"ipv6-address": [
			
		],
		"route": [
			
		],
		"dns-server": [
			
		],
		"dns-search": [
			
		],
		"neighbors": [
			
		]
	},
	"data": {
		
	}
}

Before doing any further damage, could you please assist me in restoring said file? Thanks a lot!

Here is what I've came up with:
/etc/config/network

config interface 'loopback'
        option device 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config interface 'lan'
        option device 'br-lan'
        option type 'bridge'
        option proto 'static'
        option ipaddr '192.168.0.1'
        option netmask '255.255.255.0'

config interface 'wan'
        option device 'eth0.2'
        option proto 'dhcp'

config interface 'wan6'
        option device 'eth0.2'
        option proto 'dhcpv6'

I'm not sure what you're asking to "restore".

It seems you're saying that you have to rebuild from your running config...

There's no tool...I think you may have to start rebuilding...from your current ifstatus....oh my...

It's good you made a copy of that and have not rebooted! :sweat:

Instead of manually building the config from scratch, I’d load a factory image from scratch and start over. If you have SSH - it takes 5 mins to tftp flash a new factory image (turn router off, paper clip hold the reset button on the back, turn the router on, wait until router light is flashing white, let go of your reset button).

cd to the directory with your factory image you want to load
tftp 192.168.1.1
binary
put *factory.bin

This will load all the defaults and it should be easy to configure from there.

In the future you can back up your config like you like it. Another technique is saving a script for your config settings. I have a lengthy script that I can run once and it loads my entire setup. Here is a snip of the wireless portion:


uci set wireless.default_radio0.ieee80211v=1; uci set wireless.default_radio0.ieee80211k=1; uci set wireless.default_radio0.bss_transition=1; uci set wireless.default_radio0.wnm_sleep_mode=1; uci set wireless.default_radio0.time_advertisement=2; uci set wireless.default_radio0.time_zone=CST6CDT,M3.2.0,M11.1.0; uci commit

:warning:

(Hopefully, the OP has all other configs except network - they can backup that now.)

I'm not sure what you're asking to "restore".

I'm sorry, I should have been more clear (English is not my first language). I want to restore /etc/config/network.

It seems you're saying that you have to rebuild from your running config...

Exactly!

I think you may have to start rebuilding...from your current ifstatus....oh my...

Yeah that is what I thought. I am still able to access LuCI, but I guess it is not that helpful now..

it takes 5 mins to tftp flash a new factory image

Many thanks for your suggestion! I'd have preferred a more remote friendly option since I'd have to coordinate with a family member on how to do that, because I'm not physically near the router. Nonetheless, I think I'll do that.

Hopefully, the OP has all other configs except network

Yes I think I do since, as mentioned earlier, I was able to download the .tar.gz backup from LuCI. It should be an exact snapshot of all my current configurations, right?

Another technique is saving a script for your config settings

Thanks for the heads up!

Thank you all for replying :slight_smile:

SSH

firstboot -> yes

reboot -f

at this time you have the good default configuration

1 Like

No need to use "factory" image. Functionally and configwise sysupgrade and factory images are the same. ( Factory image has a header to make it compatible with OEM flash routines, plus it has padding between kernel and rootfs to make one unified long image)

1 Like

As /etc/config/network is created from a recipe at the first boot, there is no copy in /rom, like there is for most config files.

If you have access to the router, the easiest way to obtain a default file with the default setting is just to reboot without that file... No need to flash.
If the file is missing, it will be created at the boot.
The same holds true also for /etc/config/system and wireless.

Just

  • rm /etc/config/network
  • reboot
1 Like

Your contents in the first message are missing the switch statements, the IPv6 ULA SLAAC address (mostly random) and the ip6assign option. Otherwise pretty ok.

Here is the R7800 default /etc/network/config for you (with the default 192.168.1.1 as the IP):

root@router1:/etc/config# cat network

config interface 'loopback'
        option device 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'fd1b:ad0a:3bce::/48'

config device
        option name 'br-lan'
        option type 'bridge'
        list ports 'eth1.1'

config interface 'lan'
        option device 'br-lan'
        option proto 'static'
        option ipaddr '192.168.1.1'
        option netmask '255.255.255.0'
        option ip6assign '60'

config interface 'wan'
        option device 'eth0.2'
        option proto 'dhcp'

config interface 'wan6'
        option device 'eth0.2'
        option proto 'dhcpv6'

config switch
        option name 'switch0'
        option reset '1'
        option enable_vlan '1'

config switch_vlan
        option device 'switch0'
        option vlan '1'
        option ports '1 2 3 4 6t'

config switch_vlan
        option device 'switch0'
        option vlan '2'
        option ports '5 0t'
1 Like

Thank you all again for your fast replies!

I ended up running fastboot -y && reboot now and restoring the tar.gz backup I had. Now I have to reinstall a few packages (adblock, wireguard, etc.) and I'm all set! :). I'll mark F5BJR's answer as solution since it is pretty much what I ended up doing.

Cheers!

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.