Tim antarmuka jaringan diperkenalkan dari CentOS/RHEL 7 sebagai alternatif yang lebih dapat diperluas dan skalabel untuk ikatan jaringan. Postingan ini menjelaskan cara mengonfigurasi kerja sama jaringan di CentOS/RHEL 7/8.
Contoh yang diberikan didasarkan pada sistem Oracle Linux 8.2 (mesin virtual tamu Oracle VirtualBox 6.1) dengan dua antarmuka jaringan menggunakan NetworkManager.
Secara khusus, Antarmuka Baris Perintah Manajer Jaringan (nmcli) terutama digunakan dengan opsi yang ditentukan dalam disingkat/dipendekkan formulir.
1. Konfigurasi Pra-Tim Asli
Berikut ini menunjukkan konfigurasi jaringan pra-tim asli:
# dnf list | grep team | grep anaconda NetworkManager-team.x86_64 1:1.22.8-4.el8 @anaconda libteam.x86_64 1.29-1.el8 @anaconda teamd.x86_64 1.29-1.el8 @anaconda
# lspci | grep -i eth 00:03.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 02) 00:08.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 02)
# nmcli dev DEVICE TYPE STATE CONNECTION enp0s3 ethernet connected enp0s3 enp0s8 ethernet connected enp0s8 lo loopback unmanaged --
# nmcli con NAME UUID TYPE DEVICE enp0s3 XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX ethernet enp0s3 enp0s8 XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX ethernet enp0s8
# ls -l /etc/sysconfig/network-scripts/* -rw-r--r-- 1 root root 334 Aug 21 13:29 /etc/sysconfig/network-scripts/ifcfg-enp0s3 -rw-r--r-- 1 root root 334 Aug 21 13:30 /etc/sysconfig/network-scripts/ifcfg-enp0s8
# cat /etc/sysconfig/network-scripts/ifcfg-enp0s3 1 MACADDR=[MAC_ADDR1] 2 MTU=1500 3 TYPE=Ethernet 4 PROXY_METHOD=none 5 BROWSER_ONLY=no 6 BOOTPROTO=dhcp 7 DEFROUTE=yes 8 IPV4_FAILURE_FATAL=no 9 IPV6INIT=yes 10 IPV6_AUTOCONF=yes 11 IPV6_DEFROUTE=yes 12 IPV6_FAILURE_FATAL=no 13 IPV6_ADDR_GEN_MODE=stable-privacy 14 NAME="enp0s3" 15 UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX 16 DEVICE=enp0s3 17 ONBOOT=yes
# cat /etc/sysconfig/network-scripts/ifcfg-enp0s8 1 MACADDR=[MAC_ADDR2] 2 MTU=1500 3 TYPE=Ethernet 4 PROXY_METHOD=none 5 BROWSER_ONLY=no 6 BOOTPROTO=dhcp 7 DEFROUTE=yes 8 IPV4_FAILURE_FATAL=no 9 IPV6INIT=yes 10 IPV6_AUTOCONF=yes 11 IPV6_DEFROUTE=yes 12 IPV6_FAILURE_FATAL=no 13 IPV6_ADDR_GEN_MODE=stable-privacy 14 NAME="enp0s8" 15 UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX 16 DEVICE=enp0s8 17 ONBOOT=yes
# ip addr ... 2: enp0s3:mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether brd ff:ff:ff:ff:ff:ff inet /24 brd scope global dynamic noprefixroute enp0s3 valid_lft 86059sec preferred_lft 86059sec inet6 fe80::ca99:46d3:1765:f02b/64 scope link noprefixroute valid_lft forever preferred_lft forever 3: enp0s8: mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether brd ff:ff:ff:ff:ff:ff inet /24 brd scope global dynamic noprefixroute enp0s8 valid_lft 86121sec preferred_lft 86121sec inet6 fe80::36d0:6bd3:5152:83dc/64 scope link noprefixroute valid_lft forever preferred_lft forever
2. Hapus koneksi jaringan yang ada
Hapus koneksi enp0s3 dan enp0s8 yang ada sebagai berikut. Ini dibuat kembali sebagai budak tim dalam langkah-langkah berikut.
# nmcli con show NAME UUID TYPE DEVICE enp0s3 XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX ethernet enp0s3 enp0s8 XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX ethernet enp0s8
# nmcli con del XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX Connection 'enp0s3' (XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX) successfully deleted. # nmcli con del XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX Connection 'enp0s8' (XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX) successfully deleted.
# nmcli dev DEVICE TYPE STATE CONNECTION enp0s3 ethernet disconnected -- enp0s8 ethernet disconnected -- lo loopback unmanaged --
# ls -l /etc/sysconfig/network-scripts/ total 0 #
3. Buat koneksi tim master
Buat koneksi tim master. Misalnya:
# nmcli con add type team con-name team0 ifname team0 config '{"runner": {"name": "activebackup"}, "link_watch": {"name": "ethtool"}}' Connection 'team0' (XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX) successfully added.
Di atas, mode team running (runner) adalah activebackup dan team link monitor/watcher (link_watch) adalah ethtool. Nilai pelari alternatif dan link_watch meliputi:
- pelari :loadbalance, roundrobin, lap, broadcast, random.
- link_watch :arp_ping, nsna_ping
NetworkManager membuat file konfigurasi antarmuka berikut:
# cat /etc/sysconfig/network-scripts/ifcfg-team0 1 TEAM_CONFIG="{\"runner\": {\"name\": \"activebackup\"}, \"link_watch\": {\"name\": \"ethtool\"}}" 2 PROXY_METHOD=none 3 BROWSER_ONLY=no 4 BOOTPROTO=dhcp 5 DEFROUTE=yes 6 IPV4_FAILURE_FATAL=no 7 IPV6INIT=yes 8 IPV6_AUTOCONF=yes 9 IPV6_DEFROUTE=yes 10 IPV6_FAILURE_FATAL=no 11 IPV6_ADDR_GEN_MODE=stable-privacy 12 NAME=team0 13 UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX 14 DEVICE=team0 15 ONBOOT=yes 16 DEVICETYPE=Team
# nmcli con NAME UUID TYPE DEVICE team0 XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX team team0
# nmcli dev DEVICE TYPE STATE CONNECTION team0 team connecting (getting IP configuration) team0 enp0s3 ethernet disconnected -- enp0s8 ethernet disconnected -- lo loopback unmanaged
4. Secara opsional, tetapkan alamat IP statis ke tim
Secara opsional, tetapkan alamat IP statis, gateway, DNS, dll. ke koneksi tim. Misalnya:
# nmcli con mod team0 ipv4.addresses [IP3]/24 # nmcli con mod team0 ipv4.gateway [IP4] # nmcli con mod team0 ipv4.dns [IP5] # nmcli con mod team0 ipv4.method manual # nmcli con mod team0 connection.autoconnect yes
NetworkManager memodifikasi file konfigurasi antarmuka tim berikut:
# cat /etc/sysconfig/network-scripts/ifcfg-team0 1 TEAM_CONFIG="{\"runner\": {\"name\": \"activebackup\"}, \"link_watch\": {\"name\": \"ethtool\"}}" 2 PROXY_METHOD=none 3 BROWSER_ONLY=no 4 BOOTPROTO=none 5 DEFROUTE=yes 6 IPV4_FAILURE_FATAL=no 7 IPV6INIT=yes 8 IPV6_AUTOCONF=yes 9 IPV6_DEFROUTE=yes 10 IPV6_FAILURE_FATAL=no 11 IPV6_ADDR_GEN_MODE=stable-privacy 12 NAME=team0 13 UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX 14 DEVICE=team0 15 ONBOOT=yes 16 DEVICETYPE=Team 17 IPADDR=[IP3] 18 PREFIX=24 19 GATEWAY=[IP4] 20 DNS1=[IP5]
Tim akan menggunakan DHCP jika tidak ada alamat IP statis yang ditetapkan.
5. Konfigurasi dan tambahkan budak ke tim
Konfigurasi dan tambahkan budak ke tim. Misalnya:
# nmcli con add type team-slave con-name team0-slave0 ifname enp0s3 master team0 Connection 'team0-slave0' (XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX) successfully added. # nmcli con add type team-slave con-name team0-slave1 ifname enp0s8 master team0 Connection 'team0-slave1' (XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX) successfully added.
# nmcli conn NAME UUID TYPE DEVICE team0 XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX team team0 team0-slave0 XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX ethernet enp0s3 team0-slave1 XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX ethernet enp0s8
# nmcli dev DEVICE TYPE STATE CONNECTION team0 team connected team0 enp0s3 ethernet connected team0-slave0 enp0s8 ethernet connected team0-slave1 lo loopback unmanaged --
NetworkManager membuat file konfigurasi antarmuka budak tim berikut:
# cat /etc/sysconfig/network-scripts/ifcfg-team0-slave0 1 NAME=team0-slave0 2 UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX 3 DEVICE=enp0s3 4 ONBOOT=yes 5 TEAM_MASTER=team0 6 DEVICETYPE=TeamPort
# cat /etc/sysconfig/network-scripts/ifcfg-team0-slave1 1 NAME=team0-slave1 2 UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX 3 DEVICE=enp0s8 4 ONBOOT=yes 5 TEAM_MASTER=team0 6 DEVICETYPE=TeamPort
Ketika setidaknya satu budak ditambahkan ke tim, antarmuka (tim0) dibawa dan dapat diakses.
# ip addr ... 2: enp0s3: [BROADCAST,MULTICAST,UP,LOWER_UP] mtu 1500 qdisc fq_codel master team0 state UP group default qlen 1000 link/ether [MAC1] brd ff:ff:ff:ff:ff:ff 3: enp0s8: [BROADCAST,MULTICAST,UP,LOWER_UP] mtu 1500 qdisc fq_codel master team0 state UP group default qlen 1000 link/ether [MAC1] brd ff:ff:ff:ff:ff:ff 6: team0: [BROADCAST,MULTICAST,UP,LOWER_UP] mtu 1500 qdisc noqueue state UP group default qlen 1000 link/ether [MAC1] brd ff:ff:ff:ff:ff:ff inet [IP3]/24 brd [IP6] scope global dynamic noprefixroute team0 valid_lft 86045sec preferred_lft 86045sec inet6 fe80::5b1f:554a:1928:8575/64 scope link noprefixroute valid_lft forever preferred_lft forever
Perhatikan bahwa semua antarmuka tim/tim menggunakan alamat MAC yang sama yaitu alamat MAC dari anggota slave tim pertama.
6. Mulai ulang tim
Mulai ulang tim agar alamat IP statis, dll. diterapkan. Misalnya:
# nmcli con down team0 && nmcli con up team0
7. Identifikasi antarmuka budak aktif/tidak aktif saat ini
Identifikasi antarmuka budak aktif dan tidak aktif saat ini menggunakan teamdctl(8). Misalnya:
# teamdctl team0 state setup: runner: activebackup ports: enp0s3 link watches: link summary: up instance[link_watch_0]: name: ethtool link: up down count: 0 enp0s8 link watches: link summary: up instance[link_watch_0]: name: ethtool link: up down count: 0 runner: active port: enp0s3
8. Aktifkan mode promiscuous untuk antarmuka jaringan
Beberapa teknologi virtualisasi, seperti Oracle VM VirtualBox, memerlukan mode promiscuous untuk diaktifkan pada antarmuka jaringan yang ditetapkan untuk tamu, serta di dalam tamu agar failover/failback slave berperilaku dengan benar. Mengaktifkan mode promiscuous pada antarmuka jaringan pada sistem fisik juga mungkin diperlukan.
Untuk Oracle VM VirtualBox, mode promiscuous dapat diaktifkan untuk antarmuka tamu sebagai berikut:
– Oracle VM VirtualBox Manager> [GUEST]> Settings> Network> Adapter 1|… ] Advanced ] Promiscuous Mode:Allow All
Mode promiscuous dapat diaktifkan dalam sistem CentOS/RHEL 7 secara dinamis dan statis menggunakan layanan kustom sebagai berikut:
Dinamis, tidak persisten:
# ip link set enp0s3 promisc on # ip link set enp0s8 promisc on
Statis, persisten:
Buat file unit sistem khusus dengan konten berikut, mis.:
# cat /usr/lib/systemd/system/promiscuous.service 1 [Unit] 2 Description=Bring up network interfaces in promiscuous mode upon boot 3 After=network.target 4 5 [Service] 6 Type=oneshot 7 ExecStart=/usr/sbin/ip link set dev enp0s3 promisc on 8 ExecStart=/usr/sbin/ip link set dev enp0s8 promisc on 9 ExecStop=/usr/sbin/ip link set dev enp0s3 promisc off 10 ExecStop=/usr/sbin/ip link set dev enp0s8 promisc off 11 TimeoutStartSec=0 12 RemainAfterExit=yes 13 14 [Install] 15 WantedBy=default.target
Beri tahu systemd tentang layanan baru. Misalnya:
# systemctl daemon-reload
Aktifkan dan mulai layanan/unit baru mis.:
# systemctl enable promiscuous Created symlink /etc/systemd/system/default.target.wants/promiscuous.service → /usr/lib/systemd/system/promiscuous.service.
# systemctl start promiscuous
# systemctl status promiscuous ● promiscuous.service - Bring up network interfaces in promiscuous mode upon boot Loaded: loaded (/usr/lib/systemd/system/promiscuous.service; enabled; vendor preset: disabled) Active: active (exited) since Fri 2020-08-21 16:14:53 AEST; 17s ago Process: 8088 ExecStart=/usr/sbin/ip link set dev enp0s8 promisc on (code=exited, status=0/SUCCESS) Process: 8086 ExecStart=/usr/sbin/ip link set dev enp0s3 promisc on (code=exited, status=0/SUCCESS) Main PID: 8088 (code=exited, status=0/SUCCESS) Aug 21 16:14:53 [HOST] systemd[1]: Starting Bring up network interfaces in promiscuous mode upon boot... Aug 21 16:14:53 [HOST] systemd[1]: Started Bring up network interfaces in promiscuous mode upon boot.
Pastikan mode promiscuous diaktifkan pada semua antarmuka budak. Misalnya:
# ip addr | grep enp 2: enp0s3: [BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP] mtu 1500 qdisc fq_codel master team0 state UP group default qlen 1000 3: enp0s8: [BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP] mtu 1500 qdisc fq_codel master team0 state UP group default qlen 1000
9. Menguji ketahanan konektivitas jaringan Tim – failover/failback slave
A. Dari klien jarak jauh, mulai ping terus menerus (8) dari server yang jaringannya telah dikonfigurasi, mis.:
[CLIENT]$ ping [SERVER] PING [IP3] ([IP3]) 56(84) bytes of data. 64 bytes from [IP3]: icmp_seq=1 ttl=64 time=0.025 ms 64 bytes from [IP3]: icmp_seq=2 ttl=64 time=0.034 ms 64 bytes from [IP3]: icmp_seq=3 ttl=64 time=0.039 ms ...
B. Putuskan koneksi budak tim yang sedang aktif.
Putuskan sementara kabel jaringan fisik yang terhubung ke antarmuka slave mis. enp0s3. Perhatikan bahwa menonaktifkan antarmuka secara terprogram tidak meniru hilangnya konektivitas tautan fisik yang sebenarnya.
# teamdctl team0 state setup: runner: activebackup ports: enp0s3 link watches: link summary: down instance[link_watch_0]: name: ethtool link: down down count: 1 enp0s8 link watches: link summary: up instance[link_watch_0]: name: ethtool link: up down count: 0 runner: active port: enp0s8
Setelah terputus, teamdctl menunjukkan antarmuka budak enp0s3 sebagai down dan mantan budak cadangan enp0s8 sekarang menjadi budak aktif saat ini. Meskipun slave failover, ping(8) dari klien jarak jauh terus berlanjut tanpa gangguan.
Menjalankan perintah ip(8) selanjutnya mengkonfirmasi semua lalu lintas jaringan ke tim terjadi melalui budak aktif baru enp0s8 yaitu:
# ip -s link ... 2: enp0s3: [BROADCAST,MULTICAST,PROMISC] mtu 1500 qdisc fq_codel master team0 state DOWN mode DEFAULT group default qlen 1000 link/ether [MAC1] brd ff:ff:ff:ff:ff:ff RX: bytes packets errors dropped overrun mcast 3007606561 5014092 0 27008 0 91263 TX: bytes packets errors dropped carrier collsns 787749 7568 0 0 0 0 3: enp0s8: [BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP] mtu 1500 qdisc fq_codel master team0 state UP mode DEFAULT group default qlen 1000 link/ether [MAC1] brd ff:ff:ff:ff:ff:ff RX: bytes packets errors dropped overrun mcast 3829373093 6116137 0 26680 0 111948 TX: bytes packets errors dropped carrier collsns 179163 1337 0 0 0 0 7: team0: [BROADCAST,MULTICAST,UP,LOWER_UP] mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000 link/ether [MAC1] brd ff:ff:ff:ff:ff:ff RX: bytes packets errors dropped overrun mcast 2106463511 1969187 0 49615 0 60559 TX: bytes packets errors dropped carrier collsns 176341 1378 0 0 0 0
C. Putuskan hubungan budak tim baru yang aktif saat ini.
Putuskan sementara kabel jaringan fisik yang terhubung ke antarmuka slave aktif yang baru dipromosikan, mis. enp0s8. Setelah terputus, teamdctl menunjukkan kedua antarmuka slave enp0s3 dan enp0s8 sebagai down yaitu:
# teamdctl team0 state setup: runner: activebackup ports: enp0s3 link watches: link summary: down instance[link_watch_0]: name: ethtool link: down down count: 1 enp0s8 link watches: link summary: down instance[link_watch_0]: name: ethtool link: up down count: 1 runner: active port:
Pada titik ini, dengan kedua budak tim terputus, ping(8) dari klien jarak jauh berhenti mis.
... 64 bytes from [IP3]: icmp_seq=1253 ttl=64 time=0.207 ms 64 bytes from [IP3]: icmp_seq=1254 ttl=64 time=0.131 ms 64 bytes from [IP3]: icmp_seq=1255 ttl=64 time=0.227 ms 64 bytes from [IP3]: icmp_seq=1256 ttl=64 time=0.218 ms 64 bytes from [IP3]: icmp_seq=1257 ttl=64 time=0.198 ms From [IP3] icmp_seq=1258 Destination Host Unreachable From [IP3] icmp_seq=1259 Destination Host Unreachable ...
D. Hubungkan kembali slave yang terputus
Sambungkan kembali kabel jaringan fisik ke salah satu antarmuka slave mis. enp0s3. Setelah terhubung kembali, teamdctl menunjukkan antarmuka budak enp0s3 sebagai up yaitu:
# teamdctl team0 state setup: runner: activebackup ports: enp0s3 link watches: link summary: up instance[link_watch_0]: name: ethtool link: up down count: 1 enp0s8 link watches: link summary: down instance[link_watch_0]: name: ethtool link: down down count: 1 runner: active port: enp0s3
Pada titik ini, dengan enp0s3 budak aktif saat ini, ping(8) dari klien jarak jauh dilanjutkan mis.
... From [IP3] icmp_seq=1392 Destination Host Unreachable From [IP3] icmp_seq=1393 Destination Host Unreachable From [IP3] icmp_seq=1394 Destination Host Unreachable From [IP3] icmp_seq=1395 Destination Host Unreachable 64 bytes from [IP3]: icmp_seq=1396 ttl=64 time=1258180 ms 64 bytes from [IP3]: icmp_seq=1397 ttl=64 time=1257180 ms 64 bytes from [IP3]: icmp_seq=1398 ttl=64 time=1256181 ms 64 bytes from [IP3]: icmp_seq=1399 ttl=64 time=1255181 ms ...
E. Hubungkan kembali budak yang tersisa yang terputus.
Sambungkan kembali kabel jaringan fisik ke antarmuka slave yang tersisa, mis. enp0s8. Setelah terhubung kembali, teamdctl menunjukkan antarmuka budak yang tersisa enp0s8 sebagai up yaitu:
# teamdctl team0 state setup: runner: activebackup ports: enp0s3 link watches: link summary: up instance[link_watch_0]: name: ethtool link: up down count: 1 enp0s8 link watches: link summary: up instance[link_watch_0]: name: ethtool link: up down count: 1 runner: active port: enp0s3