Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Source Link

Configure Static IP For bridge connection

I am working on Raspberry pi 3B+ (Having Ethernet and wlan both).

Currently i am trying to create a bridge connection between my Ethernet port and tap which i am using for other purpose.

Below settings works fine if i want to have dhcp conenction.

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto wlan0
#allow-hotplug wlan0
iface wlan0 inet dhcp   
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

#iface default inet dhcp

auto eth0
iface eth0 inet dhcp

# bridge
auto br0
iface br0 inet dhcp
#   address 192.168.0.120
#   netmask 255.255.255.0
#   network 192.168.0.0
#   broadcast 192.168.0.255
#   gateway 192.168.0.1
#   dns-nameservers 192.168.0.1
    pre-up ip tuntap add tap0 mode tap
    pre-up brctl addbr br0
    pre-up brctl addif br0 eth0
    pre-up brctl addif br0 tap0
#   pre-up ip link set eth0 up
    pre-up ip link set tap0 up
#   post-down ip link set eth0 down
    post-down ip link set tap0 down
    post-down ip link set br0 down
    post-down brctl delif br0 eth0
    post-down brctl delif br0 tap0
    post-down brctl delbr br0
    post-down ip link del tap0
    bridge_ports eth0 tap0
    bridge_stp off
    bridge_fd 0
    bridge_maxwait 0

What i want to achieve is to have static IP address for bridge connection or Ethernet connection.

Note: If i change in above code as static ip for br0 connection then it does take static ip. But now i am not able to connect (ping) to wlan or ethernet or bridge connection. But i do able to ping to (raspberrypi.local)

sample for static code

bridge

auto br0
iface br0 inet static
    address 192.168.0.120
    netmask 255.255.255.0
    network 192.168.0.0
    broadcast 192.168.0.255
    gateway 192.168.0.1
    dns-nameservers 192.168.0.1
    pre-up ip tuntap add tap0 mode tap
    pre-up brctl addbr br0
    pre-up brctl addif br0 eth0
    pre-up brctl addif br0 tap0
#   pre-up ip link set eth0 up
    pre-up ip link set tap0 up
#   post-down ip link set eth0 down
    post-down ip link set tap0 down
    post-down ip link set br0 down
    post-down brctl delif br0 eth0
    post-down brctl delif br0 tap0
    post-down brctl delbr br0
    post-down ip link del tap0
    bridge_ports eth0 tap0
    bridge_stp off
    bridge_fd 0
    bridge_maxwait 0