1.ifconfig
[root@centos7 ~]# yum search ifconfig
已加载插件:fastestmirror
Determining fastest mirrors
* base: mirrors.cn99.com
* extras: mirrors.cn99.com
* updates: mirror.bit.edu.cn
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/4): extras/7/x86_64/primary_db | 222 kB 00:00:00
(2/4): base/7/x86_64/group_gz | 153 kB 00:00:00
(3/4): base/7/x86_64/primary_db | 6.1 MB 00:00:03
(4/4): updates/7/x86_64/primary_db | 3.7 MB 00:00:09
================================================================================================ 匹配:ifconfig =================================================================================================
net-tools.x86_64 : Basic networking tools
[root@centos7 ~]# yum install net-tools.x86_64
2.安装vim
[root@centos7 network-scripts]# yum install vim
3.设置静态ip
2.1 查看网卡名字
[root@centos7 network-scripts]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.187.139 netmask 255.255.255.0 broadcast 192.168.187.255
inet6 fe80::7e18:c13d:e0a8:56d1 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:60:aa:10 txqueuelen 1000 (Ethernet)
RX packets 8259 bytes 11407430 (10.8 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1679 bytes 139444 (136.1 KiB)
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 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
2.2 编辑配置文件vi /etc/sysconfig/network-scripts/ifcfg-ens33你的网卡名字
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
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="ens33"
UUID="2ffdc083-6d7c-441d-a5f6-313c80b9ad74"
DEVICE="ens33"
ONBOOT="yes"
IPADDR=192.168.187.150
NETMASK=255.255.255.0
GATEWAY=192.168.187.2
DNS=8.8.8.8
2.3重启网络服务
[root@centos7 network-scripts]# service network restart
查看网关
192.168.187.2