centos7 修改ip和dns
Posted 三天泪
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos7 修改ip和dns相关的知识,希望对你有一定的参考价值。
RHEL7、CentOS7默认安装之后是没有启动网络连接!(我们就不按6的方试设置IP了,用命令方试添加IP、网关和DNS)
一、设置IP地址、网关和DNS
#nmcli connection add type ethernet autoconnect yes con-name eht0 ifname eth0 ip4 192.168.99.2 gw4 192.168.99.1 #添加IP地址和网站
#nmcli connection modify eth0 ipv4.dns 8.8.8.8 #添加DNS
#systemctl restart network #重新启动网络
#ip a #查看IP
[[email protected] ~]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000 link/ether 18:66:da:eb:15:cc brd ff:ff:ff:ff:ff:ff inet 192.168.99.2/24 brd 192.168.99.255 scope global eth0 valid_lft forever preferred_lft forever
#ping -c4 www.baidu.com
二、修改IP地址、网关和DNS
# nmcli connection modify eth0 ipv4.addresses 192.168.0.11/24 # nmcli connection modify eth0 ipv4.method manual #nmcli connection modify eth0 ipv4.dns 9.9.9.9 #systemctl restart network
#ip a 也可通过 #nmcli show dev
[[email protected] ~]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000 link/ether 18:66:da:eb:15:cc brd ff:ff:ff:ff:ff:ff inet 192.168.0.11/24 brd 192.168.0.255 scope global eth0 valid_lft forever preferred_lft forever
#man nmcli 可以通过查看网卡帮助文件有更详细的说明
至此:RHEL7、CentOS7添加网卡和修改网卡IP、DNS 已完成
以上是关于centos7 修改ip和dns的主要内容,如果未能解决你的问题,请参考以下文章