centos .7 网卡配置

centos .7 网卡配置

以管理员root身份登陆虚拟机内部

查看IP地址

命令(虚拟机内部,先打开终端):
[root@localhost ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.226.128 netmask 255.255.255.0 broadcast 192.168.226.255
inet6 fe80::62db:4b8f:20d8:315a prefixlen 64 scopeid 0x20
ether 00:0c:29:6e:d6:51 txqueuelen 1000 (Ethernet)
RX packets 550949 bytes 757886036 (722.7 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 167964 bytes 91774362 (87.5 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
loop txqueuelen 1000 (Local Loopback)
RX packets 245 bytes 19632 (19.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 245 bytes 19632 (19.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:7c:80:5b txqueuelen 1000 (Ethernet)
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

修改自己的网卡信息,修改为静态地址

[root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# ls
ifcfg-ens33 ifdown-eth ifdown-isdn ifdown-sit ifup ifup-ib ifup-plip ifup-routes ifup-tunnel network-functions-ipv6
ifcfg-lo ifdown-ib ifdown-post ifdown-Team ifup-aliases ifup-ippp ifup-plusb ifup-sit ifup-wireless
ifdown ifdown-ippp ifdown-ppp ifdown-TeamPort ifup-bnep ifup-ipv6 ifup-post ifup-Team init.ipv6-global
ifdown-bnep ifdown-ipv6 ifdown-routes ifdown-tunnel ifup-eth ifup-isdn ifup-ppp ifup-TeamPort network-functions

[root@localhost network-scripts]# vim ifcfg-ens33
操作方式:
① 按”i“ 进行修改/插入
② 修改完成后,同时按住ECS
③ 然后按shift 加 :
④ 输入wq!
⑤ 回车
PS:如果你们误删了里面的配置,首先按ESC ,然后按 u
修改内容如下:
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp #把DHCP 修改为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=27bcb508-b3f8-4f8c-a551-fff3172bd740
DEVICE=ens33
ONBOOT=no #改为YES
IPADDR=192.168.226.140 #此行及以下添加,但是IP地址根据你们的网段来修改
NETMASK=255.255.255.0
GATEWAY=192.168.226.2 #在虚拟网络配置的VMware 8的NAT设置中查看网关IP以及自己的网段

重新网络服务,识别更新信息

[root@localhost network-scripts]# systemctl restart network

查看有没有修改成功

[root@localhost network-scripts]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.226.140 netmask 255.255.255.0 broadcast 192.168.226.255
inet6 fe80::50e7:af2a:fa06:33f9 prefixlen 64 scopeid 0x20
ether 00:0c:29:21:e3:09 txqueuelen 1000 (Ethernet)
RX packets 11 bytes 1599 (1.5 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 31 bytes 4198 (4.0 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
loop txqueuelen 1000 (Local Loopback)
RX packets 500 bytes 43592 (42.5 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 500 bytes 43592 (42.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:62:49:79 txqueuelen 1000 (Ethernet)
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

Xshell 连接

liunx里的
static 静态的路由
dhcp 动态的路由

写出两种使用grep命令不区分大小写过滤BOOTPROTO行判断ifcfg-ens33文件中是使用动态获取IP还是静态配置IP,要求使用两种方法写出命令。
grep -i BOOTPROTO /etc/sysconfig/network-scripts/ifcfg-ens33
cat /etc/sysconfig/network-scripts/ifcfg-ens33 |grep -i BOOTPROTO

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值