Linux相关2023-12-18 · 约 2 分钟

VMWare虚拟机Centos7设置固定ip和访问外网 Linux

暮色陈陈17 阅读0 赞0 评论最后更新 2026-09-16

一、编辑网卡配置

shell 复制代码
vi /etc/sysconfig/network-scripts/ifcfg-ens33

修改内容

shell 复制代码
## BOOTPROTO=dhcp表示动态获取ip地址
BOOTPROTO=dhcp 修改成 BOOTPROTO=static      
ONBOOT=no 修改成 ONBOOT=yes

增加内容

shell 复制代码
IPADDR=192.168.1.2      #分配ip
NETMASK=255.255.255.0   #掩码
GATEWAY=192.168.1.1     #这里对于自己的网关
DNS1=8.8.8.8
DNS2=114.114.114.114
DNS3=192.168.1.1

二、重启网卡

shell 复制代码
systemctl restart network

三、ping一下京东

shell 复制代码
[root@localhost network-scripts]# ping www.jd.com
PING www.a.shifen.com (14.215.177.38) 56(84) bytes of data.
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=1 ttl=57 time=8.15 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=2 ttl=56 time=11.9 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=3 ttl=56 time=10.8 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=4 ttl=56 time=13.0 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=5 ttl=56 time=8.65 ms
觉得有用就点个赞吧
评论 0 条
0 / 300
还没有评论,来说第一句吧