Configuring a dynamic IP address bridge

If your network configuration is controlled by a DHCP server, perform this task to configure a dynamic IP address bridge.

  1. To display the available network interfaces, enter cat /etc/network/interfaces.
    user @ubuntu:~$ cat /etc/network/interfaces
    
    # This file describes the network interfaces available on your system
    # and how to activate them. For more information, see interfaces(5).
    
    source /etc/network/interfaces.d/*
    
    # The loopback network interface
    auto lo
    iface lo inet loopback
    
    # The primary network interface
    auto ens3
    iface ens3 inet dhcp
  2. Enter ifconfig -a to verify that the Ethernet interface is up.
    user@ubuntu:~$ ifconfig -a
  3. Enter the ping command—specifying a known URL—to verify that you have internet connectivity.
    user@ubuntu:~$ ping example.com
  4. Install bridge-utils, using the following commands:
    user@ubuntu:~$ sudo apt-get update
    user@ubuntu:~$ sudo apt-get install bridge-utils
  5. Enter sudo vi /etc/network/interface to modify the interfaces file.
    user@ubuntu:~$ sudo vi /etc/network/interface
  6. Define the br0 bridge and enslave the primary network interface (ens in the following example) under br0.
    # This file describes the network interfaces available on your system
    # and how to activate them. For more information, see interfaces(5).
    
    source /etc/network/interfaces.d/*
    
    # The loopback network interface
    auto lo
    iface lo inet loopback
    
    # The primary network interface
    # We commented out the following two lines:
    #auto ens3
    #iface ens3 inet dhcp
    
    # We added the following definition of br0:
    auto br0
    iface br0 inet dhcp
            bridge_ports ens3
            bridge_stp off
            bridge_fd 0
            bridge_maxwait 0
    
  7. Save and close the file.
  8. Reboot the server.
    user@ubuntu:~$ sudo reboot
  9. After logging back in, enter ifconfig -a to verify that the IP address is now assigned to br0.
    user@ubuntu:~$ ifconfig -a
    br0       Link encap:Ethernet  HWaddr 52:55:00:d1:55:01  
              inet addr:10.0.0.110  Bcast:10.0.0.255  Mask:255.255.255.0
              inet6 addr: 2601:644:8780:2e56:e99d:2411:3c93:b7e6/64 Scope:Global
              inet6 addr: 2601:644:8780:2e56:5055:ff:fed1:5501/64 Scope:Global
              inet6 addr: fe80::5055:ff:fed1:5501/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:142 errors:0 dropped:0 overruns:0 frame:0
              TX packets:93 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:18815 (18.8 KB)  TX bytes:13887 (13.8 KB)
    
    ens3      Link encap:Ethernet  HWaddr 52:55:00:d1:55:01  
              inet6 addr: fe80::5055:ff:fed1:5501/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:142 errors:0 dropped:0 overruns:0 frame:0
              TX packets:103 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:20803 (20.8 KB)  TX bytes:14793 (14.7 KB)
    
    lo        Link encap:Local Loopback  
              inet addr:127.0.0.1  Mask:255.0.0.0
              inet6 addr: ::1/128 Scope:Host
              UP LOOPBACK RUNNING  MTU:65536  Metric:1
              RX packets:80 errors:0 dropped:0 overruns:0 frame:0
              TX packets:80 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1 
              RX bytes:5920 (5.9 KB)  TX bytes:5920 (5.9 KB)