RTNETLINK 回答:在不同子网上创建 macvlan 时添加路由时参数无效

RTNETLINK 回答:在不同子网上创建 macvlan 时添加路由时参数无效

我正在使用 Synology NAS,它通过 Eth1 上的 ip 192.168..13 链接到我的网络。现在我想在其上安装 Macvlan,以便为我的 docker 容器提供自己的 ip 和全范围的端口。

我的路由器提供 DHCP 服务器和 192.168.0.0/24 的 IP 范围。我认为我应该在 192.168.10.128/16 范围内创建 macvlan,这样就不会发生冲突。

我执行的步骤;我在 docker 中创建了一个 macvlan 网络,如下所示:

docker network create -d macvlan \
--subnet=192.168.10.0/24 \
--gateway=192.168.10.1 \
--ip-range=192.168.10.1/24 \
-o parent=eth1 macvlan_network

然后我想在 NAS 本身上添加网络路由,因此我运行了:

ip link add macvlan0 link eth1 type macvlan mode bridge
ip addr add 192.168.10.254/32 dev macvlan0
ip link set macvlan0 up
ip route add 192.168.10.1/16 dev macvlan0

然而最后一行产生了一个错误,我不明白发生了什么……:

RTNETLINK 回答:无效参数

ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN mode DEFAULT group default qlen 1
    link/sit 0.0.0.0 brd 0.0.0.0
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether 90:09:d0:0d:8e:76 brd ff:ff:ff:ff:ff:ff
4: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether 90:09:d0:0d:8e:75 brd ff:ff:ff:ff:ff:ff
5: eth1.10: <NO-CARRIER,BROADCAST,MULTICAST,MASTER,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default qlen 1000
    link/ether d6:01:12:61:47:ba brd ff:ff:ff:ff:ff:ff
6: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether 02:42:36:f2:a5:88 brd ff:ff:ff:ff:ff:ff
7: docker-f26db83e: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether 02:42:43:b8:e5:6b brd ff:ff:ff:ff:ff:ff
9: docker5aebb14@if8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP mode DEFAULT group default 
    link/ether a6:c6:a8:db:38:be brd ff:ff:ff:ff:ff:ff link-netnsid 0
26: dockerd6b68f2@if25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker-f26db83e state UP mode DEFAULT group default 
    link/ether 3a:db:86:5d:cf:79 brd ff:ff:ff:ff:ff:ff link-netnsid 1
31: macvlan0@eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1
    link/ether 96:76:fd:12:ba:0e brd ff:ff:ff:ff:ff:ff

我的适配器配置如下

cat /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
BOOTPROTO=dhcp
ONBOOT=yes
IPV6INIT=auto_dhcp
IPV6_ACCEPT_RA=1

我很难理解这个网络配置应该如何工作,我对此不是很有经验,所以我真的需要任何建议来指出我在这里做错的地方。

相关内容