( SPYFF | 2020. 02. 17., h - 21:49 )

Szerkesztve: 2020. 02. 17., h - 21:52

Szia! Meg lehet csinálni, már ha jól értettem a kérdésed. Jól indultál el, annyi, hogy kell még eth0-ra is mindhárom VLAN, másképp eldobja őket, meg a bridge-re is. Ha kiadod a bridge vlan-t ezt kellene lásd:

port    vlan ids
eth101   101 PVID Egress Untagged

eth102   102 PVID Egress Untagged

eth103   103 PVID Egress Untagged

eth0     101
         102
         103

bridge   101
         102
         103

Gyorsan össze is dobtam a setupodat, a h101 gép pingeli a h1-et, de alapból egyik sincs tagelve, hanem a tagger gép tageli meg h101-et, az trunkon küldi a switcher gépnek. Ez a swticher gép szintén vlan aware bridgel továbbdobja eth101 felé, leveszi a taget és h1 gép már tageletlenül kapja meg. tcpdumppal megnézheted, eth0-ás ICMP-n még ott a tag.
Setup: 

from mininet.net import Mininet
from mininet.node import Controller, RemoteController, OVSController
from mininet.node import CPULimitedHost, Host, Node
from mininet.node import OVSKernelSwitch, UserSwitch
from mininet.node import IVSSwitch
from mininet.cli import CLI
from mininet.log import setLogLevel, info
from mininet.link import TCLink, Intf
from subprocess import call
from functools import partial
import time

def start_network():
    net = Mininet()

    h101 = net.addHost('h101', ip='10.10.101.101/24')
    h102 = net.addHost('h102', ip='10.10.102.102/24')
    h103 = net.addHost('h103', ip='10.10.103.103/24')
    h1 = net.addHost('h1', ip='10.10.101.1/24')
    h2 = net.addHost('h2', ip='10.10.102.2/24')
    h3 = net.addHost('h3', ip='10.10.103.3/24')
    tagger = net.addHost('tagger')
    switcher = net.addHost('switcher')

    net.addLink(h101, tagger, intfName1='eth0', intfName2='eth101')
    net.addLink(h102, tagger, intfName1='eth0', intfName2='eth102')
    net.addLink(h103, tagger, intfName1='eth0', intfName2='eth103')
    net.addLink(h1, switcher, intfName1='eth0', intfName2='eth101')
    net.addLink(h2, switcher, intfName1='eth0', intfName2='eth102')
    net.addLink(h3, switcher, intfName1='eth0', intfName2='eth103')
    net.addLink(tagger, switcher, intfName1='trunk', intfName2='eth0')

    #setup the VLAN tagging of the hosts
    tagger.cmd('brctl addbr bridge')
    tagger.cmd('ip link set dev bridge up')
    tagger.cmd('ip link set bridge type bridge vlan_filtering 1')
    tagger.cmd('bridge vlan del vid 1 dev bridge self')
    tagger.cmd('bridge vlan del vid 1 dev trunk')
    tagger.cmd('ip link set dev trunk master bridge')
    for vlan_id in [101, 102, 103]:
        tagger.cmd('ip link set dev eth{} master bridge'.format(vlan_id))
        tagger.cmd('bridge vlan add vid {} dev bridge self'.format(vlan_id))
        tagger.cmd('bridge vlan add vid {} dev eth{} pvid untagged master'.format(vlan_id, vlan_id))
        tagger.cmd('bridge vlan del vid 1 dev eth{}'.format(vlan_id))
        tagger.cmd('bridge vlan add vid {} dev trunk'.format(vlan_id))

    #setup the main switch machine
    switcher.cmd('brctl addbr bridge')
    switcher.cmd('ip link set dev bridge up')
    switcher.cmd('ip link set bridge type bridge vlan_filtering 1')
    switcher.cmd('bridge vlan del vid 1 dev bridge self')
    switcher.cmd('ip link set dev eth0 master bridge')
    switcher.cmd('bridge vlan del vid 1 dev eth0')
    for vlan_id in [101, 102, 103]:
        switcher.cmd('ip link set dev eth{} master bridge'.format(vlan_id))
        switcher.cmd('bridge vlan add vid {} dev bridge self'.format(vlan_id))
        switcher.cmd('bridge vlan add vid {} dev eth{} pvid untagged master'.format(vlan_id, vlan_id))
        switcher.cmd('bridge vlan del vid 1 dev eth{}'.format(vlan_id))
        switcher.cmd('bridge vlan add vid {} dev eth0'.format(vlan_id))

    #setup dummy interfaces
    for vlan_id in [101, 102, 103]:
        switcher.cmd('ip link add link bridge name dummy{} type vlan id {}'.format(vlan_id, vlan_id))
        switcher.cmd('ip link set dev dummy{} up'.format(vlan_id))
        switcher.cmd('ip addr add 10.10.{}.254/24 dev dummy{}'.format(vlan_id, vlan_id))

    net.build()
    CLI(net)
    net.stop()

if __name__ == '__main__':
    setLogLevel('info')
    start_network()

Kipróbáláshoz: apt install mininet, aztán meg sudo python vlans.py (vagy amilyen néven lemented). Ez után mininet konzolban add ki az xterm h1 h101 switcher parancsot és pingelgess.