centos环境更换IP地址为静态并且正常联网
2023-06-13 09:13:12 时间
更换IP
版本信息
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
查看ip
[root@localhost ~]# ip a
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:5b:e7:2e brd ff:ff:ff:ff:ff:ff
inet 192.168.1.132/24 brd 192.168.1.255 scope global noprefixroute dynamic ens33
valid_lft 1597sec preferred_lft 1597sec
inet6 fe80::ba16:18eb:ff2a:62f0/64 scope link noprefixroute
valid_lft forever preferred_lft forever
修改IP为静态并指定IP
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33
原文件:
修改后:
重启网络
[root@localhost ~]# systemctl restart network
验证:
[root@localhost ~]# ip a
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:5b:e7:2e brd ff:ff:ff:ff:ff:ff
inet 192.168.1.60/24 brd 192.168.1.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
inet6 fe80::ba16:18eb:ff2a:62f0/64 scope link noprefixroute
valid_lft forever preferred_lft forever
联网问题
我这个是自己创建的VMware虚拟机 已经通过网络连接连接到主机网络
但是依旧不能ping外网
[root@localhost ~]# ping www.baidu.com
ping: www.baidu.com: Name or service not known
修改/etc/resolv.conf文件 添加:
nameserver 114.114.114.114
nameserver 8.8.8.8
重启网卡
[root@localhost ~]# systemctl restart network
验证
[root@localhost ~]# ping www.baidu.com
PING www.a.shifen.com (110.242.68.4) 56(84) bytes of data.
64 bytes from 110.242.68.4 (110.242.68.4): icmp_seq=1 ttl=128 time=9.95 ms
64 bytes from 110.242.68.4 (110.242.68.4): icmp_seq=2 ttl=128 time=11.0 ms
64 bytes from 110.242.68.4 (110.242.68.4): icmp_seq=3 ttl=128 time=9.81 ms
64 bytes from 110.242.68.4 (110.242.68.4): icmp_seq=4 ttl=128 time=10.0 ms
64 bytes from 110.242.68.4 (110.242.68.4): icmp_seq=5 ttl=128 time=10.8 ms
64 bytes from 110.242.68.4 (110.242.68.4): icmp_seq=6 ttl=128 time=12.1 ms
64 bytes from 110.242.68.4 (110.242.68.4): icmp_seq=7 ttl=128 time=10.7 ms
64 bytes from 110.242.68.4 (110.242.68.4): icmp_seq=8 ttl=128 time=10.6 ms
^C
相关文章
- centos通过yum安装jdk1.8
- linux smartctl 命令,在 CentOS 7 里用 smartctl 和 hdparm 对硬盘进行基本测试
- 查看linux系统版本centos,CentOS下查看系统版本的4种方法
- centos安装mysql客户端安装_CENTOS安装MYSQL
- CentOS安装DockerCompose
- linux redis安装步骤_redis安装部署centos
- Linux – 基于CentOS搭建FTP文件服务
- 为CentOS升级OpenSSL 让Nginx支持TLS 1.2
- Linux一键重装脚本,Centos、Debain、Ubuntu随意选择
- CentOS上安装SQL Server
- CentOS安装SQL Server vNext CTP1教程
- centos安装redis详解大数据
- 发行版CentOS:开放源码的Linux发行版(centos是linux)
- 如何在CentOS 8上配置静态IP地址
- 如何在CentOS 7上安装Oracle Database 12c
- 如何在CentOS 8上安装Matomo(Piwik)Web Analytics
- CentOS与Linux:非凡之旅(centos和linux)
- 之一centos探索CentOS:Linux的另一分支(linux的分支)
- CentOS 7上完美安装Redis服务(centos7安装redis)
- 在 CentOS/RHEL 系统上生成补丁合规报告的 Bash 脚本
- CentOS系统如何连接MySQL数据库(centos连mysql)
- centos源码编译php5mcrypt模块步骤详解