|
| 1 | +--- |
| 2 | +title: Basic Bridge Networking |
| 3 | +author: troglobit |
| 4 | +date: 2024-07-25 08:23:00 +0100 |
| 5 | +categories: [examples] |
| 6 | +tags: [cli, networking, bridge] |
| 7 | +pin: true |
| 8 | +--- |
| 9 | + |
| 10 | +This is an example of how to set up a VLAN transparent bridge with a |
| 11 | +DHCP assigned IP address. We have a system with two interfaces, or |
| 12 | +ports, named `eth0` and `eth1`. |
| 13 | + |
| 14 | +``` |
| 15 | +admin@example:/> show interfaces |
| 16 | +INTERFACE PROTOCOL STATE DATA |
| 17 | +lo ethernet UP 00:00:00:00:00:00 |
| 18 | + ipv4 127.0.0.1/8 (static) |
| 19 | + ipv6 ::1/128 (static) |
| 20 | +eth0 ethernet UP 00:c0:ff:ee:00:01 |
| 21 | + ipv6 2001:db8:0:1:2c0:ffff:feee:1/64 (link-layer) |
| 22 | + ipv6 fe80::2c0:ffff:feee:1/64 (link-layer) |
| 23 | +eth1 ethernet UP 00:c0:ff:ee:00:02 |
| 24 | + ipv6 fe80::2c0:ffff:feee:2/64 (link-layer) |
| 25 | +``` |
| 26 | + |
| 27 | +Creating a bridge and setting our interfaces as bridge ports is a |
| 28 | +straight forward operation. |
| 29 | + |
| 30 | +``` |
| 31 | +admin@example:/> configure |
| 32 | +admin@example:/config/> set interface br0 |
| 33 | +admin@example:/config/> set interface eth0 bridge-port bridge br0 |
| 34 | +admin@example:/config/> set interface eth1 bridge-port bridge br0 |
| 35 | +``` |
| 36 | + |
| 37 | +> Because it does not make much sense to have IP addresses on bridge |
| 38 | +> ports, Infix takes care to disable IPv6 SLAAC on them automatically |
| 39 | +> when we attach interfaces to a bridge. |
| 40 | +{: .prompt-tip } |
| 41 | + |
| 42 | +We can use the `diff` command to inspect the changes. Notice how the |
| 43 | +system has automatically set the bridge interface type for us. This |
| 44 | +is a feature of the CLI and not available over NETCONF or RESTCONF. |
| 45 | + |
| 46 | +```diff |
| 47 | +admin@example:/config/> diff |
| 48 | +interfaces { |
| 49 | ++ interface br0 { |
| 50 | ++ type bridge; |
| 51 | ++ } |
| 52 | + interface eth0 { |
| 53 | ++ bridge-port { |
| 54 | ++ bridge br0; |
| 55 | ++ } |
| 56 | + } |
| 57 | + interface eth1 { |
| 58 | ++ bridge-port { |
| 59 | ++ bridge br0; |
| 60 | ++ } |
| 61 | + } |
| 62 | +} |
| 63 | +``` |
| 64 | + |
| 65 | +Now we enable a DHCP client on `br0` and activate the changes. |
| 66 | + |
| 67 | +``` |
| 68 | +admin@example:/config/> set dhcp-client client-if br0 |
| 69 | +admin@example:/config/> leave |
| 70 | +admin@example:/> |
| 71 | +``` |
| 72 | + |
| 73 | +Back in admin-exec mode we inspect the changes and notice the bridge has |
| 74 | +already got a DHCP lease from the server. |
| 75 | + |
| 76 | +``` |
| 77 | +admin@example:/> show interfaces |
| 78 | +INTERFACE PROTOCOL STATE DATA |
| 79 | +lo ethernet UP 00:00:00:00:00:00 |
| 80 | + ipv4 127.0.0.1/8 (static) |
| 81 | + ipv6 ::1/128 (static) |
| 82 | +br0 bridge |
| 83 | +│ ethernet UP 00:c0:ff:ee:00:01 |
| 84 | +│ ipv4 192.168.1.161/24 (dhcp) |
| 85 | +├ eth0 bridge FORWARDING |
| 86 | +└ eth1 bridge FORWARDING |
| 87 | +
|
| 88 | +admin@example:/> |
| 89 | +``` |
| 90 | + |
| 91 | +Remember to save your changes for next boot: |
| 92 | + |
| 93 | +``` |
| 94 | +admin@infix:/> copy running-config startup-config |
| 95 | +``` |
| 96 | + |
| 97 | +> For more information about networking in Infix, see the [official |
| 98 | +> documentation][0]. |
| 99 | +{: .prompt-info } |
| 100 | + |
| 101 | +[0]: https://github.com/kernelkit/infix/blob/main/doc/networking.md |
0 commit comments