系統(tǒng)版本 rhel7.2
1洒放、首先ifconfig
看一下我們的設(shè)備名字,我查到的是eno16777736
渊额,ip是192.168.1.7
[sam@yl 桌面]$ ifconfig
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.7 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::20c:29ff:febc:1dfe prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:bc:1d:fe txqueuelen 1000 (Ethernet)
RX packets 52 bytes 9322 (9.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 91 bytes 10275 (10.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<host>
loop txqueuelen 0 (Local Loopback)
RX packets 4 bytes 340 (340.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 4 bytes 340 (340.0 B)
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:4a:d0:88 txqueuelen 0 (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
2夏志、修改我們的配置文件(首先要確定有權(quán)限,我是直接su切換到root下修改的)
:
[root@yl 桌面]# vim /etc/sysconfig/network-scripts/ifcfg-eno16777736
TYPE="Ethernet"
BOOTPROTO="dhcp"
DEFROUTE="yes"
PEERDNS="yes"
PEERROUTES="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_PEERDNS="yes"
IPV6_PEERROUTES="yes"
IPV6_FAILURE_FATAL="no"
NAME="eno16777736"
UUID="402edb11-e974-4fa5-95b1-1718af166586"
DEVICE="eno16777736"
ONBOOT="yes"
修改BOOTPROTO為static或者none童漩,這倆都是指定ip為靜態(tài)的弄贿。
然后在下面添加IP、子網(wǎng)掩碼矫膨、網(wǎng)關(guān)挎春、DNS
IPADDR=192.168.1.15
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=114.114.114.114
3、重啟(三種方式總有一款適合你)
:
1豆拨、service network restart
2直奋、systemctl restart NetworkManager
3、先關(guān)閉再啟動(dòng)
ifdown eno16777736
ifup eno16777736
動(dòng)態(tài)獲取IP :
BOOTPROTO則改為dhcp
然后去掉IP施禾、子網(wǎng)掩碼脚线、網(wǎng)關(guān)、DNS