هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.
$ مستخدم عادي# بصلاحية root (أو مع sudo)
المهارات في هذا الفصل
- ضبط عنوان ثابت واسم مضيف باستخدام nmcli
Know devices and connection profiles
A device is the card (enp1s0). A connection (profile) is a set of settings. One device has one active profile at a time.
nmcli device status
DEVICE TYPE STATE CONNECTION
enp1s0 ethernet connected enp1s0
lo loopback connected (externally) lo
nmcli connection show
NAME UUID TYPE DEVICE
enp1s0 4f1c2e3a-0b9d-4c6e-8a7f-2d3e4f5a6b7c ethernet enp1s0
nmcli connection show --active
nmcli connection show enp1s0 | grep -E '^ipv4\.(method|addresses|gateway|dns)'
ipv4.method: auto
ipv4.addresses: --
ipv4.gateway: --
ipv4.dns: --ipv4.method auto means DHCP. manual means a fixed address.
Set a fixed IPv4 address
Change the existing profile: method manual, the address with prefix, the gateway and DNS. Then activate the profile again.
nmcli connection modify enp1s0 \
ipv4.method manual \
ipv4.addresses 192.168.122.10/24 \
ipv4.gateway 192.168.122.1 \
ipv4.dns 192.168.122.1 \
ipv4.dns-search example.com
nmcli connection up enp1s0انتبه
Changing the address of the card you are connected to over SSH cuts your session. Work on the console, or make sure the new address is right before nmcli connection up.
نصيحة للامتحان
nmcli connection modify only saves. The change works after nmcli connection up NAME (or a reboot).
Add or remove one setting
A + before a setting adds a value, a - removes one. Without them, the value is replaced.
Set an IPv6 address
IPv6 works the same way with ipv6.* settings.
nmcli con mod enp1s0 ipv6.method manual \
ipv6.addresses 2001:db8:10::10/64 \
ipv6.gateway 2001:db8:10::1 \
ipv6.dns 2001:db8:10::1
nmcli con up enp1s0
ip -6 -br a show enp1s0
ping -6 -c 2 2001:db8:10::1ipv6.method auto uses router advertisements (SLAAC) and DHCPv6. disabled turns IPv6 off on that profile.
Make a new profile
You can keep two profiles for one card (for example "office" with DHCP and "lab" with a fixed address) and switch between them.
Use nmtui or the web console
nmtui is a text menu for the same settings — easy when you do not remember the nmcli names.
Use the arrow keys and Tab, <Edit…> a profile, <OK> to save. After the edit, deactivate and activate the profile in "Activate a connection" (or run nmcli con up enp1s0).
In the web console (https://server1:9090) the Networking page shows the cards, the traffic, and lets you edit addresses.
Know where the profiles are saved
RHEL 10 saves profiles as keyfiles in /etc/NetworkManager/system-connections/. The old ifcfg files in /etc/sysconfig/network-scripts/ are no longer supported.
ls /etc/NetworkManager/system-connections/
enp1s0.nmconnection
cat /etc/NetworkManager/system-connections/enp1s0.nmconnection[connection]
id=enp1s0
type=ethernet
interface-name=enp1s0
[ipv4]
method=manual
address1=192.168.122.10/24,192.168.122.1
dns=192.168.122.1;
dns-search=example.com;انتبه
If you edit a keyfile by hand, it must be owned by root with rights 600, and you must run nmcli connection reload. Using nmcli is safer.
Set the host name
The static host name is saved in /etc/hostname. Set it with hostnamectl.
hostnamectl hostname server1.example.com
hostnamectl
hostname
server1.example.com
hostname -s
server1
cat /etc/hostname
server1.example.comThe prompt shows the new name after you log in again.
Make names work without DNS
For a few machines, or before DNS is ready, put names into /etc/hosts. It is read before DNS.
127.0.0.1 localhost localhost.localdomain
::1 localhost localhost.localdomain
192.168.122.10 server1.example.com server1
192.168.122.20 server2.example.com server2تذكّر
The order is IP address, full name, short name. The search order (hosts file first, then DNS) is set by the hosts: line in /etc/nsswitch.conf.