2017-04-10 967 views
0

我带了一个USB到以太网适配器,现在我将它连接到一端的树莓派3上的USB,另一端连接到以太网(这样我就可以设置两个我的pi的IP地址)。如何设置树莓派上的多个IP地址3

注:我也使用上树莓派3

我的以太网端口。如果我断开我的以太网端口只有通过USB以太网适配器连接,我无法沟通。我认为我的USB-Ethernet适配器没有任何通信发生。我想这两个IP地址在同一时间工作

然后,我已经改变了的/ etc /网络/接口文件,如下所示:

auto eth0 
allow-hotplug eth0 
iface eth0 inet static 
address 192.168.147.146 
netmask 255.255.255.0 
gateway 192.168.147.255 

auto eth0:0 
allow-hotplug eth0:0 
iface eth0:0 inet static 
address 192.168.147.145 
netmask 255.255.255.0 

allow-hotplug wlan0 
iface wlan0 inet manual 
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf 

allow-hotplug wlan1 
iface wlan1 inet manual 
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf 

这是从终端从我的ifconfig输出:

eth0  Link encap:Ethernet HWaddr b8:27:eb:0d:2b:28 
     inet addr:192.168.147.146 Bcast:192.168.147.255 Mask:255.255.255.0 
     UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 
     RX packets:71565 errors:0 dropped:928 overruns:0 frame:0 
     TX packets:17901546 errors:0 dropped:0 overruns:0 carrier:0 
     collisions:0 txqueuelen:1000 
     RX bytes:6283723 (5.9 MiB) TX bytes:1220265483 (1.1 GiB) 

eth0:0 Link encap:Ethernet HWaddr b8:27:eb:0d:2b:28 
     inet addr:192.168.147.145 Bcast:192.168.147.255 Mask:255.255.255.0 
     UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 

lo  Link encap:Local Loopback 
     inet addr:127.0.0.1 Mask:255.0.0.0 
     UP LOOPBACK RUNNING MTU:65536 Metric:1 
     RX packets:910 errors:0 dropped:0 overruns:0 frame:0 
     TX packets:910 errors:0 dropped:0 overruns:0 carrier:0 
     collisions:0 txqueuelen:1 
     RX bytes:79976 (78.1 KiB) TX bytes:79976 (78.1 KiB) 

请让我知道你的建议.....

+0

投票决定关闭 - 而不是一个编程的问题。 – tink

+0

你需要多个IP地址?根据您的需要,您不一定需要另一个适配器,因为您可以将许多不同的地址分配给同一个网络适配器。此外,树莓派3内置WiFi,所以也可以帮助你。 –

回答

-2

您的USB转以太网适配器是一个物理网络适配器,但您已将其设置为虚拟网络适配器。

尝试更改为eth0:0在你的/ etc的eth1 /网络/接口文件

您的代码应该是这个样子:

auto eth0 
allow-hotplug eth0 
iface eth0 inet static 
address 192.168.147.146 
netmask 255.255.255.0 
gateway 192.168.147.255 

auto eth1 
allow-hotplug eth1 
iface eth1 inet static 
address 192.168.147.145 
netmask 255.255.255.0 

allow-hotplug wlan0 
iface wlan0 inet manual 
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf 

allow-hotplug wlan1 
iface wlan1 inet manual 
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf