Доступ к USB-адаптеру Ethernet в LXC - PullRequest
0 голосов
/ 23 октября 2019

Я создал контейнер LXC в Ubuntu 18.04. Физически на хост-компьютере подключен адаптер USB-Ethernet. После запуска контейнера LXC, как получить доступ к USB-адаптеру Ethernet? Есть ли какие-нибудь конфигурации для LXC?

Информация на хост-компьютере:

rui@rui-desktop:~$ ifconfig 
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
    inet6 fe80::f763:92fe:8145:163  prefixlen 64  scopeid 0x20<link>
    ether 00:0e:c6:c9:1a:18  txqueuelen 1000  (Ethernet)
    RX packets 1  bytes 46 (46.0 B)
    RX errors 0  dropped 0  overruns 0  frame 0
    TX packets 158  bytes 29470 (29.4 KB)
    TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1430
    inet 173.39.202.159  netmask 255.255.255.128  broadcast 173.39.202.255
    inet6 fe80::2e0:4cff:fe68:12c  prefixlen 64  scopeid 0x20<link>
    ether 00:e0:4c:68:01:2c  txqueuelen 1000  (Ethernet)
    RX packets 1911906  bytes 851840909 (851.8 MB)
    RX errors 0  dropped 0  overruns 0  frame 0
    TX packets 350546  bytes 25613552 (25.6 MB)
    TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    device interrupt 149  base 0xd000  

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
    inet 127.0.0.1  netmask 255.0.0.0
    inet6 ::1  prefixlen 128  scopeid 0x10<host>
    loop  txqueuelen 1  (Local Loopback)
    RX packets 35420  bytes 2918763 (2.9 MB)
    RX errors 0  dropped 0  overruns 0  frame 0
    TX packets 35420  bytes 2918763 (2.9 MB)
    TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lxcbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
    inet 10.0.3.1  netmask 255.255.255.0  broadcast 0.0.0.0
    inet6 fe80::216:3eff:fe00:0  prefixlen 64  scopeid 0x20<link>
    ether 00:16:3e:00:00:00  txqueuelen 1000  (Ethernet)
    RX packets 859  bytes 86124 (86.1 KB)
    RX errors 0  dropped 0  overruns 0  frame 0
    TX packets 831  bytes 88890 (88.8 KB)
    TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

rndis0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
    ether be:86:e5:ee:9a:ed  txqueuelen 1000  (Ethernet)
    RX packets 0  bytes 0 (0.0 B)
    RX errors 0  dropped 0  overruns 0  frame 0
    TX packets 0  bytes 0 (0.0 B)
    TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

usb0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
    ether be:86:e5:ee:9a:ef  txqueuelen 1000  (Ethernet)
    RX packets 0  bytes 0 (0.0 B)
    RX errors 0  dropped 0  overruns 0  frame 0
    TX packets 0  bytes 0 (0.0 B)
    TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0 - это интерфейс, к которому я хочу получить доступ, и вывод из lsusb -

rui@rui-desktop:~$ lsusb
Bus 002 Device 002: ID 0bda:0411 Realtek Semiconductor Corp. 
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
**Bus 001 Device 015: ID 0b95:7720 ASIX Electronics Corp. AX88772**
Bus 001 Device 002: ID 0bda:5411 Realtek Semiconductor Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Информация о контейнере LXC:

Last login: Sat Feb 24 17:40:28 UTC 2018 on pts/0
Welcome to Ubuntu 18.04.3 LTS (GNU/Linux 4.9.140-tegra aarch64)

* Documentation:  https://help.ubuntu.com
* Management:     https://landscape.canonical.com
* Support:        https://ubuntu.com/advantage

cisco@ul:~$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
   valid_lft forever preferred_lft forever
inet6 ::1/128 scope host 
   valid_lft forever preferred_lft forever
40: eth0@if41: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 00:16:3e:d6:9b:38 brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 10.0.3.194/24 brd 10.0.3.255 scope global dynamic eth0
   valid_lft 3586sec preferred_lft 3586sec
inet6 fe80::216:3eff:fed6:9b38/64 scope link 
   valid_lft forever preferred_lft forever

1 Ответ

0 голосов
/ 05 ноября 2019

Добавление этих настроек в / var / lib / lxc / ul / config заставит их работать.

lxc.net.1.type = phys lxc.net.1.link = eth0 lxc.net.1.flags = up lxc.net.1.hwaddr = 00:0e:c6:c9:1a:18

...