acassis commented on issue #18566:
URL: https://github.com/apache/nuttx/issues/18566#issuecomment-5232652892

   @Acfboy I got ClauCoDillo working on NuttX:
   
   <img width="723" height="665" alt="Image" 
src="https://github.com/user-attachments/assets/a1ef333d-d039-4804-9faa-afca49ae381d";
 />
   
   The source code is here:
   
   https://github.com/acassis/nuttx-apps/tree/claucodillo
   https://github.com/acassis/incubator-nuttx/tree/claucodillo
   
   Few free to try it and let me know if it worked to you.
   
   Remember to give permission to ./nuttx :
   
   ```
   $ sudo setcap cap_net_admin+eip ./nuttx
   ```
   
   And setup the network, I use this script:
   
   ```
   setup-tap-net.sh
   #!/bin/bash
   # Run this with sudo AFTER ./nuttx is already running in the background
   # (it creates its own tap<N> interface on startup via CAP_NET_ADMIN).
   # Finds that interface, brings it up with the gateway IP ClauCoDillo's
   # NuttX side expects (10.0.1.1, matching CONFIG_NETINIT_DRIPADDR),
   # and NATs the 10.0.1.0/24 subnet out through the host's real default
   # route interface so NuttX gets real internet access.
   set -euo pipefail
   
   HOST_IF=$(ip route show default | awk '{print $5; exit}')
   if [ -z "$HOST_IF" ]; then
     echo "Could not determine host default-route interface" >&2
     exit 1
   fi
   
   TAP_IF=$(ip -o link show type tun 2>/dev/null | awk -F': ' '{print $2}' | 
grep '^tap' | tail -1)
   if [ -z "$TAP_IF" ]; then
     echo "No tap<N> interface found -- is ./nuttx running?" >&2
     exit 1
   fi
   
   echo "Host default-route interface: $HOST_IF"
   echo "NuttX sim tap interface:      $TAP_IF"
   
   ip addr add 10.0.1.1/24 dev "$TAP_IF" 2>/dev/null || true
   ip link set "$TAP_IF" up
   
   sysctl -w net.ipv4.ip_forward=1 >/dev/null
   
   # Idempotent: -C (check) first, only -A (append) if the rule isn't
   # already there, so re-running this script after a nuttx restart is
   # safe.
   iptables -t nat -C POSTROUTING -s 10.0.1.0/24 -o "$HOST_IF" -j MASQUERADE 
2>/dev/null || \
     iptables -t nat -A POSTROUTING -s 10.0.1.0/24 -o "$HOST_IF" -j MASQUERADE
   
   iptables -C FORWARD -i "$TAP_IF" -o "$HOST_IF" -j ACCEPT 2>/dev/null || \
     iptables -A FORWARD -i "$TAP_IF" -o "$HOST_IF" -j ACCEPT
   
   iptables -C FORWARD -i "$HOST_IF" -o "$TAP_IF" -m state --state 
RELATED,ESTABLISHED -j ACCEPT 2>/dev/null || \
     iptables -A FORWARD -i "$HOST_IF" -o "$TAP_IF" -m state --state 
RELATED,ESTABLISHED -j ACCEPT
   
   echo "Done. $TAP_IF is up at 10.0.1.1/24, NAT via $HOST_IF enabled."
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to