如何从 Busybox shell(ash)手动设置网络连接?

如何从 Busybox shell(ash)手动设置网络连接?

运行 Linux 版本 2.6.26.5、ARM Linux 内核的嵌入式设备。Busybox v1.10.2 shell (ash),我在 Busybox shell 中。我想建立嵌入式设备和计算机之间的连接。是否可以从 Busybox shell 手动设置网络连接?我安装了主虚拟文件系统 (proc、sysfs、tmpfs、/dev/pts),然后输入命令来设置网络,但没有成功。我猜,可能是某些模块或驱动程序未在此 shell 模式下加载,但我不确定。

BusyBox v1.10.2 (2017-08-02 14:07:25 CST) built-in shell (ash)
Enter 'help' for a list of built-in commands.

/bin/sh: can't access tty; job control turned off
# mount -t proc proc /proc
# mount -t sysfs sysfs /sys
# mount -t tmpfs tmpfs /tmp
# mount -t tmpfs tmpfs /dev
# mkdir /dev/pts
# mount -t devpts devpts /dev/pts
# mdev -s
# ifconfig lo 127.0.0.1
# ifconfig eth0 hw ether 88:75:56:05:6D:28
# ifconfig eth0 192.168.15.1 netmask 255.255.255.0 broadcast 192.168.15.255
# ifconfig eth0 up
# route add -net 192.168.15.0/24 eth0
# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 88:75:56:05:6D:28  
          inet addr:192.168.15.1  Bcast:192.168.15.255  Mask:255.255.255.0
          UP BROADCAST RUNNING 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:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:22 

# ping 192.168.15.100
PING 192.168.15.100 (192.168.15.100): 56 data bytes
From 192.168.15.100 icmp_seq=0 timed out

编辑:ifconfig eth0Ubuntu 计算机上的输出:

$ ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 20:47:47:49:bc:75  
          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:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

答案1

Busybox 软件包中包含 ip 命令。这样您就可以向这样的接口添加 ip 地址。(将 <examples> 替换为您的值)

ip addr add <10.128.55.2> dev <eth0>

它还包括路线和链接配置选项。以下是文档:https://linux.die.net/man/8/ip

相关内容