修改Linux主机的ip地址

第一种方法(我这边尝试不行,不知道是不是我个人原因到底有没有用,就也写上)

首先,

cd /etc/sysconfig/network-scripts/
vi ifcfg-ens33
总用量 228
-rw-r--r--. 1 root root   280 827 2018 ifcfg-ens33
-rw-r--r--. 1 root root   254 13 2018 ifcfg-lo
lrwxrwxrwx. 1 root root    24 827 2018 ifdown -> ../../../usr/sbin/ifdown
-rwxr-xr-x. 1 root root   654 13 2018 ifdown-bnep
-rwxr-xr-x. 1 root root  6569 13 2018 ifdown-eth
-rwxr-xr-x. 1 root root   781 13 2018 ifdown-ippp
-rwxr-xr-x. 1 root root  4540 13 2018 ifdown-ipv6
lrwxrwxrwx. 1 root root    11 827 2018 ifdown-isdn -> ifdown-ippp
-rwxr-xr-x. 1 root root  2130 816 2018 ifdown-post
-rwxr-xr-x. 1 root root  1068 13 2018 ifdown-ppp
-rwxr-xr-x. 1 root root   870 13 2018 ifdown-routes
-rwxr-xr-x. 1 root root  1456 13 2018 ifdown-sit
-rwxr-xr-x. 1 root root  1621 318 2017 ifdown-Team
-rwxr-xr-x. 1 root root  1556 318 2017 ifdown-TeamPort
-rwxr-xr-x. 1 root root  1462 13 2018 ifdown-tunnel
lrwxrwxrwx. 1 root root    22 827 2018 ifup -> ../../../usr/sbin/ifup
-rwxr-xr-x. 1 root root 12415 13 2018 ifup-aliases
-rwxr-xr-x. 1 root root   910 13 2018 ifup-bnep
-rwxr-xr-x. 1 root root 13475 816 2018 ifup-eth
-rwxr-xr-x. 1 root root 12075 13 2018 ifup-ippp
-rwxr-xr-x. 1 root root 11893 13 2018 ifup-ipv6
lrwxrwxrwx. 1 root root     9 827 2018 ifup-isdn -> ifup-ippp
-rwxr-xr-x. 1 root root   650 13 2018 ifup-plip
-rwxr-xr-x. 1 root root  1064 13 2018 ifup-plusb
-rwxr-xr-x. 1 root root  5000 816 2018 ifup-post
-rwxr-xr-x. 1 root root  4154 13 2018 ifup-ppp
-rwxr-xr-x. 1 root root  2001 13 2018 ifup-routes
-rwxr-xr-x. 1 root root  3303 13 2018 ifup-sit
-rwxr-xr-x. 1 root root  1755 318 2017 ifup-Team
-rwxr-xr-x. 1 root root  1876 318 2017 ifup-TeamPort
-rwxr-xr-x. 1 root root  2711 13 2018 ifup-tunnel
-rwxr-xr-x. 1 root root  1836 13 2018 ifup-wireless
-rwxr-xr-x. 1 root root  5419 13 2018 init.ipv6-global
-rw-r--r--. 1 root root 19948 13 2018 network-functions
-rw-r--r--. 1 root root 31027 13 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

得到修改后的地址

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值