emux icon indicating copy to clipboard operation
emux copied to clipboard

NETGEAR, 2nd NIC

Open kevthehermit opened this issue 3 years ago • 5 comments

Trying to emulate a NETGEAR XR500, have the physical device as well so was able to get the firmware and nvram settings all copied over in to a template easily.

Mostly it's working,

Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:22222           0.0.0.0:*               LISTEN      
tcp        0      0 0.0.0.0:53              0.0.0.0:*               LISTEN      
tcp        0      0 0.0.0.0:631             0.0.0.0:*               LISTEN      
tcp        0      0 192.168.100.2:22222     192.168.100.1:39488     ESTABLISHED 
tcp        0      0 192.168.100.2:22222     192.168.100.1:39484     ESTABLISHED 
tcp        0      0 192.168.100.2:747       192.168.100.1:2049      ESTABLISHED 
tcp        0      0 :::548                  :::*                    LISTEN      
tcp        0      0 :::22222                :::*                    LISTEN      
tcp        0      0 :::53                   :::*                    LISTEN      
udp        0      0 127.0.0.1:2313          0.0.0.0:*                           
udp        0      0 0.0.0.0:53              0.0.0.0:*                           
udp        0      0 127.0.0.1:46420         127.0.0.1:2313          ESTABLISHED 
udp        0      0 127.0.0.1:44405         127.0.0.1:2313          ESTABLISHED 
udp        0      0 127.0.0.1:47995         127.0.0.1:2313          ESTABLISHED 
udp        0      0 127.0.0.1:40326         127.0.0.1:53            ESTABLISHED 
udp        0      0 127.0.0.1:47831         127.0.0.1:2313          ESTABLISHED 
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           
udp        0      0 :::53                   :::*                                
udp        0      0 :::5353                 :::*       
/ $ ps w
  PID  Uid     VmSize Stat Command
    1 root        116 S   init       
    2 root            SW  [kthreadd]
    3 root            SW  [ksoftirqd/0]
    5 root            SW< [kworker/0:0H]
    6 root            SW  [kworker/u2:0]
    7 root            SW  [rcu_sched]
    8 root            SW  [rcu_bh]
    9 root            SW  [migration/0]
   10 root            SW< [khelper]
   11 root            SW  [kdevtmpfs]
   12 root            SW  [kworker/u2:1]
   14 root            SW  [khungtaskd]
   17 root            SW< [writeback]
   18 root            SW< [kintegrityd]
   20 root            SW< [bioset]
   22 root            SW< [kblockd]
   23 root            SW< [ata_sff]
   25 root            SW  [khubd]
   32 root            SW< [rpciod]
   33 root            SW  [kworker/0:1]
   35 root            SW  [kswapd0]
   37 root            SW< [vmstat]
   39 root            SW  [fsnotify_mark]
   40 root            SW< [nfsiod]
  396 root            SW< [kpsmoused]
  550 root            SW  [kworker/0:2]
  552 root            SW  [mmcqd/0]
  565 root            SW< [ipv6_addrconf]
  568 root            SW< [deferwq]
  634 root        260 S   /sbin/klogd -n 
  656 root        612 S   dcron -L /dev/null 
  660 root        804 S   /usr/sbin/dropbear -p 22222 -R 
  664 root        164 S   /sbin/agetty -p -L ttyAMA0 115200 vt100 
 1069 root         68 S   /usr/sbin/dropbear -p 22222 -R 
 1070 root       1100 S   -sh 
 1093 root       1972 S   /bin/bash ./run-init 
 2415 root        340 S   /bin/sh /.armx/armxinit 
 2418 root        136 S   /bin/sh /etc/init.d/rcS S boot 
 2419 root        952 S   /bin/sh 
 2421 root        340 S   logger -s -p 6 -t sysinit 
 2443 root         84 S   klogd 
 2446 root        608 S   /bin/datalib 
 2479 root            SW  [kworker/0:0]
 2671 root        640 S   /sbin/hotplug2 --override --persistent --set-rules-file /etc/hotplug2.rules --set-coldplug-cmd /sbin/udevt
 3541 root        264 S   /sbin/ubusd 
 3585 root         52 S   /usr/bin/detcable 2 
 4543 root         60 S   /usr/sbin/ntpclient 
 4633 root         56 S   /usr/bin/hd-idle -i 1800 
 4714 root        296 S   /sbin/KC_BONJOUR 
 4715 root        316 S   /sbin/KC_PRINT 
 4834 root         68 S   /usr/sbin/ntgrddns -c /tmp/ntgrdns.conf 
 4851 root       1016 S   /bin/sh /etc/openvpn/client/ovpn_sync_configs.sh 
 4886 root       1928 S   curl -s --retry 5 https://http.fw.updates1.netgear.com/sw-apps/vpn-client/xr500/providerlist.json -o /tmp/
 4922 root         80 S   /usr/sbin/dnsmasq --except-interface=lo -u root -r /tmp/resolv.conf 
 5042 root         88 S   syslogd -m 0 -T GMT-0 -c 7679 
 5187 root       1028 S   /bin/sh /usr/sbin/netconn.sh 
 5443 root        344 S   /bin/sh /sbin/check_status.sh 
 5504 root        124 S   /usr/sbin/dbus-daemon --system 
 5542 root       1144 S   avahi-daemon: running [XR500.local]             
 5547 root        160 S   inetd 
 5636 root       1316 S   /usr/bin/lua /dumaos/ngcompat/main.lua 
 5663 root        280 S   /usr/bin/arpwatch -i -p 5640 -d 
 5685 root        492 S   atd 
 5829 root        172 S   /usr/sbin/ra_check 
 5999 root       1020 S   /bin/sh /sbin/11k_scan -f 
 6014 root       1760 S N /usr/sbin/afpd -F /etc/netatalk/afpd.conf -P /var/run/afpd.pid -c 7 
 6023 root        344 S   sleep 120 
 6037 root        344 S   /bin/sh /usr/sbin/check_time_machine 
 6039 root        344 S   sleep 60 
 6046 root       4552 S   lua /dumaos/api/cli.lua -p /dumaos/apps/system/com.netdumasoftware.procmanager backend 
 6120 root         68 S   /usr/sbin/dropbear -p 22222 -R 
 6121 root       1100 S   -sh 
 6143 root       1864 S   /bin/bash ./run-binsh 
 6155 root        344 S   /bin/sh /.armx/armxshell 
 6156 root        344 S   /bin/sh 
 6698 root       1716 S   /usr/bin/lua /dumaos/api/cli.lua -p /dumaos/apps/system//com.netdumasoftware.networkmonitor backend 
 6701 root       1644 S   /usr/bin/lua /dumaos/api/cli.lua -p /dumaos/apps/system//com.netdumasoftware.neighsync backend 
 6704 root       2916 S   /usr/bin/lua /dumaos/api/cli.lua -p /dumaos/apps/system//com.netdumasoftware.devicemanager backend 
 6707 root       1328 S   /usr/bin/lua /dumaos/api/cli.lua -p /dumaos/apps/system//com.netdumasoftware.neighwatch backend 
 6710 root       1328 S   /usr/bin/lua /dumaos/api/cli.lua -p /dumaos/apps/system//com.netdumasoftware.systeminfo backend 
 6719 root       3716 S   /usr/bin/lua /dumaos/api/cli.lua -p /dumaos/apps/system//com.netdumasoftware.desktop backend 
 6722 root       2716 S   /usr/bin/lua /dumaos/api/cli.lua -p /dumaos/apps/system//com.netdumasoftware.rappstore backend 
 6725 root       2832 S   /usr/bin/lua /dumaos/api/cli.lua -p /dumaos/apps/usr//com.netdumasoftware.hybridvpn backend 
 6769 root        344 S   /bin/sh -c opkg update 
 6772 root       2196 S   opkg update 
 7789 root        344 S   sleep 60 
 7817 root        260 S   /bin/sh -c sleep 10; /root/test-eth0.sh >/dev/null 2>&1 
 7818 root        260 S   /bin/sh -c sleep 20; /root/test-eth0.sh >/dev/null 2>&1 
 7819 root        260 S   /bin/sh -c sleep 30; /root/test-eth0.sh >/dev/null 2>&1 
 7820 root        260 S   /bin/sh -c sleep 40; /root/test-eth0.sh >/dev/null 2>&1 
 7821 root        260 S   /bin/sh -c sleep 50; /root/test-eth0.sh >/dev/null 2>&1 
 7822 root        260 S   sleep 40 
 7823 root        260 S   sleep 50 
 7824 root        260 S   sleep 10 
 7825 root        260 S   sleep 30 
 7826 root        260 S   sleep 20 
 7842 root         72 S   /usr/sbin/uhttpd -D -I ndindex.html -h /www -r XR500 -x /cgi-bin -l /apps -L /www/cgi-bin/url-routing.lua 
 7846 root         52 S   ntgrcryptwd 
 7851 root        344 S   sleep 3 
 7855 root        344 R   ps w 

a lot of the services have started, however it looks like the device needs a 2nd NIC

RawEthLan=eth1
RawEthWan=eth0

ifconfig $RawEthLan hw ether $wandefmac
ifconfig $RawEthWan hw ether $wandefmac
ifconfig $BondEth hw ether $wandefmac
ifconfig $BondEth up
vconfig add $BondEth 1 && ifconfig $BondEth.1 down
vconfig add $BondEth 2 && ifconfig $BondEth.2 down
ip link set dev $BondEth.1 name ethlan
ip link set dev $BondEth.2 name ethwan
brctl addif br0 ethwan

Without it, br0 is never created and most network service like httpd are never started.

I think this is done by adding a new entry to qemuopts but can not figure it out.

Any advice?

kevthehermit avatar Jul 15 '21 00:07 kevthehermit

I have been thinking of creating a second tap device for quite some time. It will require three things:

a) Adding another tap device in the container itself. This can be done via /etc/local.d/10-tun-network.start b) Adding options to qemuopts, basically for both tap devices c) Some network config in the hostfs as well

I'll ponder this.

therealsaumil avatar Jul 15 '21 06:07 therealsaumil

Happy to help with any prototyping or testing.

kevthehermit avatar Jul 15 '21 09:07 kevthehermit

I'll take you up on that! Meanwhile it does look quite similar to the Netgear R6700v3 that I recently emulated. And it works with br0 without a second ethernet:

# ifconfig
br0       Link encap:Ethernet  HWaddr 52:F3:C3:EE:D4:5C
          inet addr:192.168.100.2  Bcast:192.168.255.255  Mask:255.255.0.0
          inet6 addr: fe80::120c:6bff:fe20:2f9d/64 Scope:Link
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

eth0      Link encap:Ethernet  HWaddr 10:0C:6B:20:2F:9E
          inet addr:192.168.100.2  Bcast:192.168.100.255  Mask:255.255.255.0
          inet6 addr: fe80::120c:6bff:fe20:2f9e/64 Scope:Link
          UP BROADCAST RUNNING PROMISC ALLMULTI MULTICAST  MTU:1500  Metric:1
          RX packets:52289 errors:0 dropped:0 overruns:0 frame:0
          TX packets:40243 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:54656414 (52.1 MiB)  TX bytes:4647430 (4.4 MiB)
          Interrupt:47

And httpd is running. Would you be so kind and DM/Email me please? saumil -at- saumil -dot- net

therealsaumil avatar Jul 15 '21 12:07 therealsaumil

Email sent with more detail

kevthehermit avatar Jul 15 '21 16:07 kevthehermit

@kevthehermit Do you have more information on how you have emulated this device? Can I contact you?

WizardsOfTheInternet avatar Aug 20 '22 07:08 WizardsOfTheInternet