RHEL7.0 配置网络IP的三种方法

来源:互联网 发布:单片机温度控制程序 编辑:程序博客网 时间:2024/06/05 19:58
导读RHEL7里面的网卡命名方式从eth0,1,2的方式变成了enoXXXXX的格式。 en代表的是enthernet (以太网),o 代表的是onboard (内置),那一串数字是主板的某种索引编号自动生成,以便保证其唯一性。和原先的命名方式对比,这种新的方式比较长,难以记忆,不过优点在于编号唯一,做系统迁移的时候不容易出错。
1.修改/etc/sysconfig/network-scripts/eno16777736

查看你的网卡名称(本机是eno16777736):

[root@linuxprobe Desktop]# ifconfigeno16777736: flags=4163  mtu 1500        inet 192.168.1.100  netmask 255.255.255.0  broadcast 192.168.1.255        inet6 fe80::20c:29ff:feb8:2b07  prefixlen 64  scopeid 0x20        inet6 fde0:b912:e3a9:0:20c:29ff:feb8:2b07  prefixlen 64  scopeid 0x0        ether 00:0c:29:b8:2b:07  txqueuelen 1000  (Ethernet)        RX packets 37  bytes 5428 (5.3 KiB)        RX errors 0  dropped 0  overruns 0  frame 0        TX packets 62  bytes 8269 (8.0 KiB)        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0lo: flags=73  mtu 65536        inet 127.0.0.1  netmask 255.0.0.0        inet6 ::1  prefixlen 128  scopeid 0x10        loop  txqueuelen 0  (Local Loopback)        RX packets 134  bytes 10928 (10.6 KiB)        RX errors 0  dropped 0  overruns 0  frame 0        TX packets 134  bytes 10928 (10.6 KiB)        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0[root@linuxprobe Desktop]# 

编辑ifcfg-eno16777736 文件:
ifconfig_eno16777736
红色为需要修改或者添加的内容,保存并退出。
部分释义:

TYPE=Ethernet        #网络接口类型BOOTPROTO=static     #动态为dhcpDEFROUTE=yesIPV4_FAILURE_FATAL=yesIPV6INIT=yes          #是否支持IPV6       IPV6_AUTOCONF=yes    IPV6_DEFROUTE=yesIPV6_FAILURE_FATAL=noNAME=eno16777736    #网卡名称UUID=72cf53fd-534c-4765-912b-3df575a10a7dONBOOT=yes          #开启自动启用网络连接IPADDRO=192.168.1.20  #设置IP地址GATEWAY0=192.168.1.1  #设置网关PREFIX0=24           #设置子网掩码DNS1=192.168.1.1     #设置DNSHWADDR=00:0C:29:B8:2B:07PEERDNS=yes PEERROUTES=yesIPV6_PEERDNS=yesIPV6_PEERROUTES=yes

重启网卡并测试网络:

[root@linuxprobe Desktop]# systemctl restart network

ping1

2.图形工具nmtui

在终端执行命令:

[root@linuxprobe Desktop]# nmtui

nmtui1
nmtui2
你依然需要重启网卡才能生效,并测试网络。
ping2

3.图形工具nm-connection-editor

终端执行命令:

[root@linuxprobe Desktop]# nm-connection-editor

nm-connection-editor
nm-connection-editor1
nm-connection-editor3
三种方法只要会一种就可以上网,配置你所需要的服务,是不是非常简单啊!


本文转载自:http://www.linuxprobe.com/rhel7-configure-network/

免费提供最新Linux技术教程书籍,为开源技术爱好者努力做得更多更好:http://www.linuxprobe.com/
0 0