Set an IP address with one line in RHEL7/CentOS7

Use this line:

# nmcli con mod ens160 ipv4.method static ipv4.addresses ${IPADDR} ipv4.gateway ${GATEWAY} ipv4.dns ${DNS_SERVERS}

The DNS servers (if more than one) should be in quotes and comma-separated (i.e. "10.1.1.5,10.2.2.6")

 

You may also like...