rhel7 IP/default gateway/DNS configuration, static route take effect permanently

1. Use the nmcli command to generate a network card configuration file. This file is saved in the path /etc/sysconfig/network-scripts/ifcfg-lan1

nmcli conn add con-name lan1 type ethernet autoconnect yes ifname eno16777736 ip4 10.1.128.10/16 gw4 10.1.128.2

2、用nmcli添加dns
nmcli conn modify lan1 ipv4.dns 202.96.128.86
nmcli conn modify lan1 +ipv4.dns 202.96.128.166

3. Add permanent static gateway
vim /etc/sysconfig/network-scripts/route-lan1
10.2.0.0/16 via 10.1.128.3 dev eno16777736
10.3.0.0/16 via 10.1.128.3 dev eno16777736

4. Restart the network service to take effect immediately
systemctl restart network

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324815706&siteId=291194637