第一种方法(我这边尝试不行,不知道是不是我个人原因到底有没有用,就也写上)
首先,
cd /etc/sysconfig/network-scripts/
vi ifcfg-ens33
总用量 228
-rw-r--r--. 1 root root 280 8月 27 2018 ifcfg-ens33
-rw-r--r--. 1 root root 254 1月 3 2018 ifcfg-lo
lrwxrwxrwx. 1 root root 24 8月 27 2018 ifdown -> ../../../usr/sbin/ifdown
-rwxr-xr-x. 1 root root 654 1月 3 2018 ifdown-bnep
-rwxr-xr-x. 1 root root 6569 1月 3 2018 ifdown-eth
-rwxr-xr-x. 1 root root 781 1月 3 2018 ifdown-ippp
-rwxr-xr-x. 1 root root 4540 1月 3 2018 ifdown-ipv6
lrwxrwxrwx. 1 root root 11 8月 27 2018 ifdown-isdn -> ifdown-ippp
-rwxr-xr-x. 1 root root 2130 8月 16 2018 ifdown-post
-rwxr-xr-x. 1 root root 1068 1月 3 2018 ifdown-ppp
-rwxr-xr-x. 1 root root 870 1月 3 2018 ifdown-routes
-rwxr-xr-x. 1 root root 1456 1月 3 2018 ifdown-sit
-rwxr-xr-x. 1 root root 1621 3月 18 2017 ifdown-Team
-rwxr-xr-x. 1 root root 1556 3月 18 2017 ifdown-TeamPort
-rwxr-xr-x. 1 root root 1462 1月 3 2018 ifdown-tunnel
lrwxrwxrwx. 1 root root 22 8月 27 2018 ifup -> ../../../usr/sbin/ifup
-rwxr-xr-x. 1 root root 12415 1月 3 2018 ifup-aliases
-rwxr-xr-x. 1 root root 910 1月 3 2018 ifup-bnep
-rwxr-xr-x. 1 root root 13475 8月 16 2018 ifup-eth
-rwxr-xr-x. 1 root root 12075 1月 3 2018 ifup-ippp
-rwxr-xr-x. 1 root root 11893 1月 3 2018 ifup-ipv6
lrwxrwxrwx. 1 root root 9 8月 27 2018 ifup-isdn -> ifup-ippp
-rwxr-xr-x. 1 root root 650 1月 3 2018 ifup-plip
-rwxr-xr-x. 1 root root 1064 1月 3 2018 ifup-plusb
-rwxr-xr-x. 1 root root 5000 8月 16 2018 ifup-post
-rwxr-xr-x. 1 root root 4154 1月 3 2018 ifup-ppp
-rwxr-xr-x. 1 root root 2001 1月 3 2018 ifup-routes
-rwxr-xr-x. 1 root root 3303 1月 3 2018 ifup-sit
-rwxr-xr-x. 1 root root 1755 3月 18 2017 ifup-Team
-rwxr-xr-x. 1 root root 1876 3月 18 2017 ifup-TeamPort
-rwxr-xr-x. 1 root root 2711 1月 3 2018 ifup-tunnel
-rwxr-xr-x. 1 root root 1836 1月 3 2018 ifup-wireless
-rwxr-xr-x. 1 root root 5419 1月 3 2018 init.ipv6-global
-rw-r--r--. 1 root root 19948 1月 3 2018 network-functions
-rw-r--r--. 1 root root 31027 1月 3 2018 network-functions-ipv6
[root@localhost network-scripts]# vi ifcfg-ens33
然后再里面直接修改IPADDR=xxxxxxxxxxxx
不过这个方法在我这里不行
下面的办法:
可以:
首先
ifconfig
查看硬件信息
这里可以看到你的IP地址信息和其他信息
然后
ping xxxxxxxx//(ip地址)
看看是否能通
按
crt+c
跳出
如果不通,就是被占用
然后
sudo ifconfig ens33 xxxxxxxxxxxxx//ip地址
会让你输入密码,如果ip地址存在,那么就会直接更改
然后重新调用
ip addr
得到修改后的地址