How to set up a bridge with "bridge_ports none" on Debian Stretch in /etc/network/interfaces?

196

Setting the default gateway to your own IP address doesn't make much sense thus isn't accepted:

$ sudo ifup -v br0

ifup: configuring interface br0=br0 (inet)
/bin/run-parts --exit-on-error --verbose /etc/network/if-pre-up.d
run-parts: executing /etc/network/if-pre-up.d/bridge

Waiting for br0 to get ready (MAXWAIT is 32 seconds).
run-parts: executing /etc/network/if-pre-up.d/vde2
run-parts: executing /etc/network/if-pre-up.d/wpasupplicant
/bin/ip addr add 10.0.10.1/255.255.255.0 broadcast 10.0.10.254    dev br0 label br0
/bin/ip link set dev br0   up
 /bin/ip route add default via 10.0.10.1  dev br0 onlink 
RTNETLINK answers: Invalid argument
ifup: failed to bring up br0

Your broadcast setting is suspicious as well, the customary value would be 10.0.10.255, which you wouldn't even need to specify. Just use modern syntax:

iface br0 inet static
    address      10.0.10.1/24
    bridge_ports none
Share:
196

Related videos on Youtube

jott19
Author by

jott19

Updated on September 18, 2022

Comments

  • jott19
    jott19 over 1 year

    I have name/value pairs I want to pipe as objects to an Advanced Function.

    I'm starting with an OrderedDictionary that looks like this:

    $jobs = [ordered]@{0='job0';1='job1';2='job2';3='job3';4='job4'; 5='job5';6='job6';}
    

    Console output looks like this:

    $jobs
    Name                           Value                                                                                                                                                                
    ----                           -----                                                                                                                                                                
    0                              job0                                                                                                                                                                 
    1                              job1                                                                                                                                                                 
    2                              job2                                                                                                                                                                 
    3                              job3                                                                                                                                                                 
    4                              job4                                                                                                                                                                 
    5                              job5                                                                                                                                                                 
    6                              job6 
    

    The function looks like this:

    Function Process-Jobs {
       [cmdletbinding()]
       Param (
            [Parameter(ValueFromPipeline=$true)][hashtable]$jobs
       )
        Begin {
            Write-Output '--> begin block <--'
        }
        Process {
            Write-Output $_.Name
            Write-Output $_.Value
        }
        End {
            Write-Output '--> end block <--'
        }
    }
    $jobs = [ordered]@{0='job0';1='job1';2='job2';3='job3';4='job4'; 5='job5';6='job6';}
    $jobs | Process-Jobs
    

    The above code does not work and returns this to the console:

    --> begin block <--
    --> end block <--
    

    I tried making the hash table a custom object like this:

    $jobs = [PSCustomObject][ordered]@{0='job0';1='job1';2='job2';3='job3';4='job4'; 5='job5';6='job6';}
    

    Console output looks like this:

    $jobs
    0 : job0
    1 : job1
    2 : job2
    3 : job3
    4 : job4
    5 : job5
    6 : job6
    

    If I modify the function...

    Function Process-Jobs {
       [cmdletbinding()]
       Param (
            [Parameter(ValueFromPipeline=$true)][PSCustomObject]$jobs
       )
        Begin {
            Write-Output '--> begin block <--'
        }
        Process {
            $i = 0
            Write-Output $jobs.Name
            Write-Output $jobs.$i
        }
        End {
            Write-Output '--> end block <--'
        }
    }
    
    $jobs = [PSCustomObject][ordered]@{0='job0';1='job1';2='job2';3='job3';4='job4'; 5='job5';6='job6';}
    $jobs | Process-Jobs
    

    Console output looks like this:

    --> begin block <--
    job0
    --> end block <--
    

    It seems I've lost the ability to reference the Name property.

    How do I access the Name property of the $jobs object?

    I start with the OrderedDictionary because I need it for processing elsewhere in the function.

    Is there a better way to pipe name/value pairs to an Advanced Function?

    Should I use something like this:

    $jobs = New-Object –TypeName PSCustomObject
    $jobs | Add-Member –MemberType NoteProperty –Name 'Name' –Value 0
    $jobs | Add-Member –MemberType NoteProperty –Name 'Value' –Value 'job0'
    ...
    $jobs | Process-Jobs
    

    will need additional code to loop and sort...