DE10 Nano开发板(Debian系统)以太网联网异常:路由表为空无法获取默认网关
Hey there, let's dig into why your route table is coming up empty and you can't get a default gateway on your DE10 Nano running Debian. Looking at the info you shared, here's what's going on and how to fix it:
First, let's spot the key clue from your ifconfig output: your eth0 interface only has an IPv6 link-local address (fe80::4c0:3fff:fe00:d85f) but no IPv4 address at all. Without an IPv4 address assigned, your system can't get a default gateway (since gateways are tied to your IP's network segment), which explains the empty route table from route -ne.
Now let's go through possible fixes based on your setup (direct Ethernet cable to host PC):
Check if your host PC's Ethernet sharing is enabled
Since you're connecting directly to your host, your PC needs to act as a DHCP server and share its internet connection with the DE10 Nano. On Windows, this is under "Network Connections" > right-click your active internet adapter (like WiFi) > "Properties" > "Sharing" tab, then enable sharing for the Ethernet adapter connected to the board. On Linux, you can use tools likednsmasqto set up a DHCP server on your host's Ethernet interface, or use NetworkManager's connection sharing feature.Verify DHCP is working on the DE10 Nano
Your/etc/network/interfacesis set to use DHCP foreth0, but maybe the DHCP client isn't running or failed to get an address. Try these steps:- Manually trigger a DHCP request with:
Check if this gives you an IPv4 address (rundhclient eth0ifconfigagain to verify). If you get errors here, it means the board can't reach a DHCP server (most likely your host PC isn't set up to provide one). - Check if the DHCP client service is running:
If it's inactive, start it and enable auto-start on boot:systemctl status dhcpcdsystemctl start dhcpcd systemctl enable dhcpcd
- Manually trigger a DHCP request with:
Fallback to static IP configuration
If setting up DHCP sharing on your host is tricky, you can manually assign static IPs to both your host's Ethernet interface and the DE10 Nano:- On your host PC, set its Ethernet interface to a static IP like
192.168.1.1with subnet mask255.255.255.0. - Edit
/etc/network/interfaceson the DE10 Nano to replace the DHCP line with static config:iface eth0 inet static address 192.168.1.2 netmask 255.255.255.0 gateway 192.168.1.1 dns-nameservers 8.8.8.8 8.8.4.4 - Restart the network service to apply changes:
systemctl restart networking
After this, run
route -neagain and you should see your default gateway (192.168.1.1) listed.- On your host PC, set its Ethernet interface to a static IP like
Double-check physical connections
Even thoughifconfigshowseth0is UP, it's worth swapping the Ethernet cable or re-seating both ends to rule out a faulty cable or loose connection.
备注:内容来源于stack exchange,提问作者programmer25

