I am currently studying for the RHCSA and my practice exams are asking me to configure the IP address, gateway ip address and nameserver ip.
What are the commands for achieving this and/or what are the manual ways of achieving this. Or is just best doing it with nmcli only?
Thank you for your help.
I'm new to studying myself, so I can just tell you what I've learned thus far. You can always just navigate to /etc/sysconfig/network-scripts/. This location will have the network interface profile file. Use VIM to edit the file to change the IP information. Then ESC, :wq to write changes. Now, I am not sure, but I think you might have to actually reboot the box for these changes to take effect. I could be wrong, someone please correct me if that is the case.
Also, you can use the nmcli as you mentioned. The documentation is located here - https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/networking_guide/sec-c...
Besides restarting the system, you can also stop/start the affected network configuration with "nmcli connection down 'TheConectionName' ; nmcli connection up 'TheConecctionName'" or alternatively restarting network-manager with systemctl restart NetworkManager . Hardly ever you need to restart a system to make network changes -- that'd be difficult to address in a production scenario.
RH's official docs (under access.redhat.com) aren't available during exams, and the OP is studying for RHCSA; so even though I do like that doc, it won't help come exam time (unless someone has a photographic memory :)
Some folks have replied rather obtusely about this (ex: "only docs shipped with product are available") -- I find it best to just be blunt about this, say "no online docs", and reference man pages if the OP is asking about an exam.
Also, I cannot remember all the VARS needed in the ./network-scripts/ dir ... so folks suggesting manually editing files, I ask: can folks really remember all those VARS?
There's actually a LOT of examples in the man pages:
Besides editing files directly and using nmcli, you can also use nmtui -- the text user interface that allows easier configuration. You need to know how to navigate the tool, anyhow.
At exam time I stick to manually editing the ifcfg-xxx config files. nmcli might be a useful tool for some, or even for the majority, but I find its syntax of building the final command string out of blocks of options unweildy during the exam. It's feedback when used for inspection of network setup is unnecessarily verbose, another turnoff. nmtui might be another useful tool to handle network setup during an exam, allegedly it is deprecated, but in lieu of graphical tools, and for the exam, it is good enough.
Edit ifcfg-xxx files and then nmcli dev dis enxxx nmcli con some_connection up and your settings take effect instantly. No need to reboot or reset NetworkManager.
Outside of the exam scope and when in a need to configure network, I prefer graphical tools, the Network part of the Settings menu (quickly accessed from the upper right corner by the Power button) offers plenty of what I need.
Based on my experience I would recommend to use nmtui
From the exam perspective you will provide jus one command and then choose proper options to set all the options required for network configuration as well as to easily change the hostname if required.
With nmtui you will be able to set the ip address, subnet mask, default gateway and DNS server in one tool which comparing to nmcli will be long command to modify the existing connection
nmcli connection modify CONNECTION_NAME ipv4.method manual ipv4.address A.B.C.D/MASK_IN_BIT_NOTATION ipv4.dns A.B.C.D
or to create new one
nmcli connection add type ethernet ifname INTERFACE_NAME ipv4.method manual ipv4.address A.B.C.D/MASK_IN_BIT_NOTATION ipv4.dns A.B.C.D connection.id CONNECTION_NAME
after this you will nedd to brint the connection up
nmcli connection up CONNECTION_NAME
and to verify the settings manually, moreover you can easily forget to add something where in nmtui you have all the options avaiable opn one screen.
I'll practice on nmtui.
I've never given these console UIs much love ... but you make a case for their value in a timed exam.