centos7静态ip设置

1、查看ip

1、ifconfig 
2、ip addr

如果 ifconfig,不存在则安装
yum -y install net-tools
执行ifconfig

enp0s9: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.107  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::a00:27ff:fea7:3824  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:a7:38:24  txqueuelen 1000  (Ethernet)
        RX packets 22879  bytes 3845858 (3.6 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 47297  bytes 42089771 (40.1 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 155788  bytes 90784182 (86.5 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 155788  bytes 90784182 (86.5 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

tunl0: flags=193<UP,RUNNING,NOARP>  mtu 1480
        inet 10.244.16.128  netmask 255.255.255.255
        tunnel   txqueuelen 1000  (IPIP Tunnel)
        RX packets 304  bytes 90648 (88.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 289  bytes 32180 (31.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

二、修改配置文件

  1. 进入目录
[root@k8smaster ~]# cd /etc/sysconfig/network-scripts/
  1. 新增或修改配置文件
[root@k8smaster ~]# vi ifcfg-enp0s9TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
# 设置为no   #不使用网络管理器,而使用配置文件,这个配置要有
NM_CONTROLLED="no"
# 设置为静态ip
BOOTPROTO="static"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="enp0s9"
DEVICE="enp0s9"
# 启动的时候加载
ONBOOT="yes"
# 设置ip,掩码,网关
IPADDR="192.168.0.107"
NETMASK="255.255.255.0"
GATEWAY="192.168.0.1"
DNS1="144.144.144.144"

三、重启网卡

systemctl restart network
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值