Посмотрим информацию о всех сетевых интерфейсах нашей системы
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 00:0c:29:ce:d1:6b brd ff:ff:ff:ff:ff:ff altname enp2s1 inet 192.168.0.100/24 brd 192.168.0.255 scope global ens33 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fece:d16b/64 scope link valid_lft forever preferred_lft forever 3: ens37: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether 00:0c:29:ce:d1:75 brd ff:ff:ff:ff:ff:ff altname enp2s5 |
Здесь мы можем определить два сетевых интерфейса:
— сетевой интерфейс ens33 MAC-адресом 00:0c:29:ce:d1:6b
— сетевой интерфейс ens37 MAC-адресом 00:0c:29:ce:d1:75
1 |
$ sudo networkctl |
1 2 3 4 |
IDX LINK TYPE OPERATIONAL SETUP 1 lo loopback carrier unmanaged 2 ens33 ether routable configured 3 ens37 ether off unmanaged |
Настройка физического сетевого адаптера
1 |
$ sudo nano /etc/systemd/network/uplink.network |
1 2 3 4 5 6 |
[Match] MACAddress = 00:0c:29:ce:d1:6b MACAddress = 00:0c:29:ce:d1:75 [Network] Bridge = br0 |
Создаем мост
1 |
$ sudo nano /etc/systemd/network/br0.netdev |
1 2 3 |
[NetDev] Name = br0 Kind = bridge |
1 |
$ sudo nano /etc/systemd/network/br0.network |
1 2 3 4 5 6 7 |
[Match] Name = br0 [Network] DNS = 77.88.8.7 # DNS Yandex Address = 192.168.0.100/24 Gateway = 192.168.0.1 |
Перезагрузим сеть
1 |
$ sudo systemctl restart systemd-networkd |
1 |
$ sudo networkctl |
1 2 3 4 5 |
IDX LINK TYPE OPERATIONAL SETUP 1 lo loopback carrier unmanaged 2 ens33 ether enslaved configured 3 ens37 ether enslaved configured 4 br0 bridge routable configuring |
1 |
$ sudo ip a s |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP group default qlen 1000 link/ether 00:0c:29:ce:d1:6b brd ff:ff:ff:ff:ff:ff altname enp2s1 3: ens37: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP group default qlen 1000 link/ether 00:0c:29:ce:d1:75 brd ff:ff:ff:ff:ff:ff altname enp2s5 4: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 link/ether b2:3c:84:88:15:4b brd ff:ff:ff:ff:ff:ff inet 192.168.0.100/24 brd 192.168.0.255 scope global br0 valid_lft forever preferred_lft forever inet6 fe80::b03c:84ff:fe88:154b/64 scope link valid_lft forever preferred_lft forever |
1 |
$ sudo ip r |
1 2 |
default via 192.168.0.1 dev br0 proto static 192.168.0.0/24 dev br0 proto kernel scope link src 192.168.0.100 |