系统相关
首页 > 系统相关> > 如何在Linux中设置usb / ethernet接口?

如何在Linux中设置usb / ethernet接口?

作者:互联网

me@me:~$sudo /etc/init.d/networking restart
[ ok ] Restarting networking (via systemctl): networking.service.
me@me:~$sudo service network-manager restart
me@me:~$sudo ifup eno1
Internet Systems Consortium DHCP Client 4.3.3
Copyright 2004-2015 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/eno1/34:e6:d7:0a:8f:fc
Sending on   LPF/eno1/34:e6:d7:0a:8f:fc
Sending on   Socket/fallback
DHCPDISCOVER on eno1 to 255.255.255.255 port 67 interval 3 (xid=0x162c3b49)
DHCPDISCOVER on eno1 to 255.255.255.255 port 67 interval 7 (xid=0x162c3b49)
DHCPREQUEST of 134.94.232.12 on eno1 to 255.255.255.255 port 67 (xid=0x493b2c16)
DHCPOFFER of 134.94.232.12 from 134.94.232.1
DHCPACK of 134.94.232.12 from 134.94.232.1
bound to 134.94.232.12 -- renewal in 282886 seconds.

me@me:~$ifconfig -a
eno1      Link encap:Ethernet  HWaddr 34:e6:d7:0a:8f:fc  
          inet addr:134.94.232.12  Bcast:134.94.239.255  Mask:255.255.248.0
          inet6 addr: fe80::36e6:d7ff:fe0a:8ffc/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:12414 errors:0 dropped:2 overruns:0 frame:0
          TX packets:4826 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:8676664 (8.6 MB)  TX bytes:536959 (536.9 KB)
          Interrupt:20 Memory:f7e00000-f7e20000 

enx00116b68261f Link encap:Ethernet  HWaddr 00:11:6b:68:26:1f  
          inet addr:192.168.1.21  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::1851:f4a:198:2c2f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1 errors:0 dropped:0 overruns:0 frame:0
          TX packets:44 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:64 (64.0 B)  TX bytes:6860 (6.8 KB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:3656 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3656 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:285972 (285.9 KB)  TX bytes:285972 (285.9 KB)

wlp2s0    Link encap:Ethernet  HWaddr 60:57:18:0d:ec:06  
          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)

me@me:~$sudo lshw -C network  *-network               
       description: Ethernet interface
       product: Ethernet Connection (3) I218-LM
       vendor: Intel Corporation
       physical id: 19
       bus info: pci@0000:00:19.0
       logical name: eno1
       version: 04
       serial: 34:e6:d7:0a:8f:fc
       size: 1Gbit/s
       capacity: 1Gbit/s
       width: 32 bits
       clock: 33MHz
       capabilities: pm msi bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=e1000e driverversion=3.2.6-k duplex=full firmware=0.2-3 ip=134.94.232.12 latency=0 link=yes multicast=yes port=twisted pair speed=1Gbit/s
       resources: irq:47 memory:f7e00000-f7e1ffff memory:f7e43000-f7e43fff ioport:f080(size=32)
  *-network DISABLED
       description: Wireless interface
       product: Wireless 7265
       vendor: Intel Corporation
       physical id: 0
       bus info: pci@0000:02:00.0
       logical name: wlp2s0
       version: 3b
       serial: 60:57:18:0d:ec:06
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress bus_master cap_list ethernet physical wireless
       configuration: broadcast=yes driver=iwlwifi driverversion=4.4.0-91-generic firmware=17.459231.0 latency=0 link=no multicast=yes wireless=IEEE 802.11abgn
       resources: irq:52 memory:f7c00000-f7c01fff
  *-network
       description: Ethernet interface
       physical id: 2
       logical name: enx00116b68261f
       serial: 00:11:6b:68:26:1f
       size: 1Gbit/s
       capacity: 1Gbit/s
       capabilities: ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd 1000bt 1000bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=ax88179_178a driverversion=22-Aug-2005 duplex=full firmware=ASIX AX88179 USB 3.0 Gigabit Et ip=192.168.1.21 link=yes multicast=yes port=MII speed=1Gbit/s
me@me:~$sudo ping 192.168.1.14 -c3
PING 192.168.1.14 (192.168.1.14) 56(84) bytes of data.

--- 192.168.1.14 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 1999ms

me@me:~$sudo ifup enx00116b68261f
Unknown interface enx00116b68261f

我有一个usb到以太网适配器连接到我的Linux系统.我编辑了连接信息,并在右上角的连接菜单中提供了手动ip 192.168.1.21.在上面的命令行中,我们可以看到系统上的可用连接信息.我无法为en0016b68261f建立接口.以下是我/ etc / network中的接口:

interfaces(5) file used by ifup(8) and ifdown(8)

#The loopback network interface

auto lo
iface lo inet loopback

# The primary network interface
iface eno1 inet dhcp

当我尝试ping usb另一端的端口到以太网适配器,其IP地址为192.168.1.14时,我无法ping我的开发板的这个ip地址.

如何设置usb到以太网适配器?

Traceroute显示了这个:

me@me:/$traceroute 192.168.1.21
traceroute to 192.168.1.21 (192.168.1.21), 30 hops max, 60 byte packets
 1  192.168.1.21 (192.168.1.21)  0.231 ms  0.192 ms  0.180 ms
me@me:/$traceroute 192.168.1.14
traceroute to 192.168.1.14 (192.168.1.14), 30 hops max, 60 byte packets
 1  * * *
 2  * * *
 (...)
29  * * *
30  * * *

解决方法:

有很多解决方案.主要是,您在Linux GUI上使用NetworkManager,这可能对此有用.

实际上,同一任务有两个系统:

>系统范围的网络配置脚本,它们使用/ etc / network / interfaces
>还有NetworkManager,它是同一任务的GUI工具,但它也有每用户配置.

您的配置存在冲突,您希望尝试配置它们.

这个答案解释了系统范围的启动脚本.

这里的主要问题是,USB /以太网设备不是固定设备,但您可以随时插拔.

>避免使用可怕的界面重命名USB设备并给它一个修改名称.如果描述here,怎么样.从本质上说,放线

SUBSYSTEM ==“net”,ACTION ==“add”,DRIVERS ==“?*”,ATTR {address} ==“XX:yy:XX:yy:XX:yy”,ATTR {dev_id} ==“0x0 “,ATTR {type} ==”1“,KERNEL ==”usb *“,NAME =”usb0“

进入你的/etc/udev/rules.d/70-persistent-net.rules.结果将是您的这个USB设备(由其MAC标识)将始终是usb0.

>然后你必须从NetworkManager的影响中消除这个东西.正如here所解释的那样,它很简单,它只是忽略了/ etc / network / interfaces中存在的设备.只需配置它,例如你可以给他一个静态IP,或者配置一个dhcp:

 auto usb0
 #iface usb0 inet dhcp
 #iface usb0 inet static
 #address 192.168.220.65
 #netmask 255.255.255.224
 #广播192.168.220.95

标签:linux,networking,network-interface
来源: https://codeday.me/bug/20190814/1658171.html