Через несколько лет.. Добавление другого ответа.
Во-первых, я не уверен, что пакет ifconfig
поддерживается в настоящее время. лучше использовать команду ip
из пакета iproute2 .
Несколько руководств поiproute2
:
http://andys.org.uk/bits/2010/02/24/iproute2-life-after-ifconfig/
https://www.tecmint.com/ifconfig-vs-ip-command-comparing-network-configuration/
https://lartc.org/howto/lartc.iproute2.html#LARTC.IPROUTE2.WHY
Во-вторых, в вашем случае я бы, вероятно, также использовал простой мост Linux . Но также важно отметить, что с 2014 года Open vSwitch (OVS)является соперник Linux Bridge.
Некоторые ссылки:
http://www.fiber-optic-transceiver-module.com/ovs-vs-linux-bridge-who-is-the-winner.html
https://devinpractice.com/2016/10/18/open-vswitch-introduction-part-1/
https://kumul.us/switches-ovs-vs-linux-bridge-simplicity-rules/
Изменить :Я покажу, как соединить два пространства имен Linux с помощью моста.
Решение #1-Использование моста Linux(Обратите внимание, -все ip
команды имеют комментарий с 3 #с сверху):
# Variables
BRIDGE=my-bridge
TAP1=Tap1
TAP1-BR=TAP1-bridge-side
TAP2=Tap2
TAP2-BR=TAP2-bridge-side
NAMESPACE1=Namespace1
NAMESPACE2=Namespace2
## Create bridge
brctl addbr $BRIDGE
### Bring it up
ip link set dev $BRIDGE up
### Create a Veth pair named Tap1 <--> TAP1-bridge-side
ip link add $TAP1 type veth peer name $TAP1-BR
## Attach one side of Tap1 to bridge
brctl addif $BRIDGE $TAP1-BR
### And the other side to namespace1
ip link set $TAP1 netns $NAMESPACE1
### Set the interface on the bridge side up
ip link set dev $TAP1-BR up
### Set the interface inside the namespace up - notice that we execute 'ip netns exec' in order to run the inside the namespace scope
ip netns exec $NAMESPACE1 ip link set dev $TAP1 up
####
# Now create another Veth and connect it to the bridge - just change $TAP1 ->$TAP2, $TAP1-BR -> $TAP2-BR and repeat the same steps..
## Now you can reach namespace1 from namespace2 and vice versa.
Решение #2.A-Настройка моста с помощью open VSwitch:
# Install the package
sudo apt-get install openvswitch-switch
# Now run the exact same commands like before just replace the CLI tool:
## brctl -> ovs-vsctl
# And replace commands:
## addbr -> add-br
## addif -> add-port
Решение #2.B-Настройка моста с использованием открытый VSwitch-замена пар Veth на внутренние порты:
# Similar to # 2.A
ovs-vsctl add-br $BRIDGE
# Similar to 2.A - Just with the addition of -- set Interface...
ovs-vsctl add-port $BRIDGE $TAP1 -- set Interface $TAP1 type=internal
### Similar #2.A (and #1)
ip link set $TAP1 netns $NAMESPACE1
### Similar #2.A (and #1)
ip netns exec $NAMESPACE1 ip link set dev $TAP1 up
# Now repeat for $TAP2...