- We will simply see a basic example of changing IP address to DHCP mode using “ifcfg-*” files present in network-script directory of NetworkManager Daemon service.
- First check for the existing content in the configuration file
[root@myserver2 network-scripts]# cat ifcfg-Wired_connection_3TYPE=EthernetBOOTPROTO=noneDEFROUTE=yesIPV4_FAILURE_FATAL=noIPV6INIT=noNAME=Wired_connection_3UUID=46a40de1-e50a-4b1f-90e4-413cc53a34e9DEVICE=enp0s9ONBOOT=yesHWADDR=08:00:27:B6:50:F3IPADDR=192.168.248.100PREFIX=24[root@myserver2 network-scripts]# ip a sh dev enp0s94: enp0s9: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000    link/ether 08:00:27:b6:50:f3 brd ff:ff:ff:ff:ff:ff    inet 192.168.248.100/24 brd 192.168.248.255 scope global enp0s9       valid_lft forever preferred_lft forever    inet6 fe80::a00:27ff:feb6:50f3/64 scope link       valid_lft forever preferred_lft forever
- Now time to get some changes done to the configuration file, in our example we will change the IP address so new IP
[root@myserver2 network-scripts]# vi ifcfg-Wired_connection_3[root@myserver2 network-scripts]# cat ifcfg-Wired_connection_3TYPE=EthernetBOOTPROTO=dhcpDEFROUTE=yesIPV4_FAILURE_FATAL=noIPV6INIT=noNAME=Wired_connection_3UUID=46a40de1-e50a-4b1f-90e4-413cc53a34e9DEVICE=enp0s9ONBOOT=yesHWADDR=08:00:27:B6:50:F3#IPADDR=192.168.248.100#PREFIX=24
- Post changes in the configuration file, to get those reflected get the interface down and up using ifdown and ifup commands.
[root@myserver2 network-scripts]# ifdown enp0s9[root@myserver2 network-scripts]# nmcli dev statusDEVICE   TYPE      STATE         CONNECTIONenp0s3   ethernet  connected     Wired_connection_1enp0s8   ethernet  connected     Wired_connection_2enp0s10  ethernet  disconnected  --enp0s9   ethernet  disconnected  --lo       loopback  unmanaged     --[root@myserver2 network-scripts]# ifup enp0s9Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/7)[root@myserver2 network-scripts]# nmcli dev statusDEVICE   TYPE      STATE         CONNECTIONenp0s3   ethernet  connected     Wired_connection_1enp0s8   ethernet  connected     Wired_connection_2enp0s9   ethernet  connected     Wired_connection_3enp0s10  ethernet  disconnected  --lo       loopback  unmanaged     --[root@myserver2 network-scripts]# ip a sh dev enp0s94: enp0s9: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000    link/ether 08:00:27:b6:50:f3 brd ff:ff:ff:ff:ff:ff    inet 192.168.248.203/24 brd 192.168.248.255 scope global dynamic enp0s9       valid_lft 1174sec preferred_lft 1174sec    inet6 fe80::a00:27ff:feb6:50f3/64 scope link       valid_lft forever preferred_lft forever
- Permanent changes has been made successfully to the interface using configuration files.
No comments:
Post a Comment