BBB 上的静态 IP 不会随网络/接口文件而改变

BBB 上的静态 IP 不会随网络/接口文件而改变

我正在使用多个 BBB (Rev C),使用以下命令通过 USB 从我的 Mac (OSX 10.9.3) 与它们进行通信霍恩迪斯司机。 BBB 正在运行 Debian,因此我想手动为它们分配所有不同的静态 IP。但是,我无法获得 IP 以外的任何内容192.168.7.2。更改/etc/network/interfaces文件的 ip192.168.7.10没有任何作用:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
#auto eth0
#iface eth0 inet dhcp
# Example to keep MAC address between reboots
#hwaddress ether DE:AD:BE:EF:CA:FE

auto eth0
iface eth0 inet static
address 192.168.2.2
netmask 255.255.255.0
network 192.168.2.0
broadcast 192.168.2.255
gateway 192.168.2.1

# WiFi Example
#auto wlan0
#iface wlan0 inet dhcp
#    wpa-ssid "essid"
#    wpa-psk  "password"

# Ethernet/RNDIS gadget (g_ether)
# ... or on host side, usbnet and random hwaddr
# Note on some boards, usb0 is automaticly setup with an init script
# in that case, to completely disable remove file [run_boot-scripts] from the boot partition
iface usb0 inet static
    address 192.168.7.10
    netmask 255.255.255.0
    network 192.168.7.0
    gateway 192.168.7.1

确实,boot分区有一个文件我也改了,没有结果:

#!/bin/bash

# Update /etc/network/interfaces to add virtual Ethernet port
cat >>/etc/network/interfaces <<EOF

iface usb0 inet static
  address 192.168.7.10
  netmask 255.255.255.0
  network 192.168.7.0
  gateway 192.168.7.1
EOF

# Add terminal to virtual serial port
cat >/etc/init/gadget-serial.conf <<EOF
start on stopped rc RUNLEVEL=[2345]
stop on runlevel [!2345]

respawn
exec /sbin/getty 115200 ttyGS0
EOF

# Write script to start gadget driver
cat >/usr/sbin/g-multi-load.sh <<'EOF'
#!/bin/bash
if [ "`lsmod | grep g_multi`" != "" ]; then exit 0; fi
mac_addr=/proc/device-tree/ocp/ethernet@4a100000/slave@4a100300/mac-address
eeprom=/sys/bus/i2c/devices/0-0050/eeprom

DEV_ADDR=$(perl -e 'print join(":",unpack("(H2)*",<>))' ${mac_addr})
VERSION=$(perl -e '@x=unpack("A12A4",<>); print $x[1]' ${eeprom})
SERIAL_NUMBER=$(perl -e '@x=unpack("A16A12",<>); print $x[1]' ${eeprom})
ISBLACK=$(perl -e '@x=unpack("A20A4",<>); print $x[1]' ${eeprom})

BLACK=""
if [ "${ISBLACK}" = "BBBK" ] ; then
    BLACK="Black"
fi
if [ "${ISBLACK}" = "BNLT" ] ; then
    BLACK="Black"
fi

modprobe g_multi file=/dev/mmcblk0p1 cdrom=0 stall=0 removable=1 nofua=1 iSerialNumber=${SERIAL_NUMBER} iManufacturer=Circuitco iProduct=BeagleBone${BLACK} host_addr=${DEV_ADDR}

# Enable the network interface
sleep 1
ifup usb0
EOF
chmod +x /usr/sbin/g-multi-load.sh

# Add script to rc.local
perl -i -pe 's!^exit 0!/usr/sbin/g-multi-load.sh\nexit 0!' /etc/rc.local

# Install DHCP server
sudo apt-get -y update
sudo apt-get -y install isc-dhcp-server

# Configure DHCP server
cat >/etc/ltsp/dhcp.conf <<EOF
ddns-update-style none;
subnet 192.168.7.0 netmask 255.255.255.252 {
  range 192.168.7.1 192.168.7.1;
}
EOF
perl -i -pe 's/INTERFACES=".*"/INTERFACES="usb0"/' /etc/default/isc-dhcp-server

# Start up services
/usr/sbin/g-multi-load.sh
service isc-dhcp-server start

答案1

您需要为 BeagleBone Black 更改第三个文件:/opt/scripts/boot/am335x_evm.sh

我在这里找到了它: http://ewong.me/changing-usb0-ip-address-on-the-beaglebone-black

答案2

我在我的 BBB 上尝试过,但没有成功。原来我的 Beaglebone 上的网络配置是由 connman 控制的。重新启动后,编辑 /etc/network/interfaces 和其他脚本文件没有任何效果。 (我想如果我使用了 GUI 界面,这可能会更明显。事实上,我旋转了几个小时试图弄清楚发生了什么......)我终于让它永久更改为静态输入以下命令即可配置 ip:

首先,您需要找到您的(在我的例子中是有线)连接的“服务名称”。进入:

连接服务

就我而言,我的有线连接称为“ethernet_b0d5cc8194db_cable”。您需要它来设置连接的配置。以下将我的 eth0(有线)连接设置为静态 IP 地址“192.168.1.219”:

connmanctl 配置 ethernet_b0d5cc8194db_cable ipv4 手册 192.168.1.219 255.255.255.0 192.168.1.1

添加名称服务器:

connmanctl 配置 ethernet_b0d5cc8194db_cable --nameservers 8.8.8.8

我还可以禁用 ipv6(只是我的偏好):

connmanctl 配置 ethernet_b0d5cc8194db_cable ipv6 关闭

遗憾的是我们想出了这么多不同的方法来在 Linux 上配置网络!

-约翰

相关内容