IP地址配置方法

临时配置IP地址:

[root@Allen ~]# ifconfig eth0 192.168.0.5   #电脑重起后失效

 配置永久的IP地址:

1.修改配置文件------>   /etc/sysconfig/network-scripts/ifcfg-eth0

2.通过nmcil命令

[root@Allen ~]# nmcli connection show 查看网卡设备系统名称
名称         UUID                                  类型            设备 
System eth0  5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03  802-3-ethernet  eth0 
[root@Allen ~]# nmcli connection modify 'System eth0'                         
  ipv4.method manual       ##ipv4.method 如果dhcp给其分的就是auto、是管理员指定就是manual                                                
  ipv4.addresses '172.25.0.166/24 172.25.0.254'                    
  connection.autoconnect yes  ##默认启动激活
[root@Allen ~]# nmcli connection up 'System eth0'  #重新激活被修改接口,此命名执行成功后终端将会断开,需用新地址连接

3. [root@server0 ~]# nmtui    ####类似setup类图形界面

  a.选择>Edit a connection  
                                                                                  ┌─┤ NetworkManager TUI ├──┐
                                                                                  │                         │ 
                                                                                  │ Please select an option │ 
                                                                                  │                         │ 
                                                                                  │ Edit a connection       │ 
                                                                                  │ Activate a connection   │ 
                                                                                  │ Set system hostname     │ 
                                                                                  │                         │ 
                                                                                  │ Quit                    │ 
                                                                                  │                         │ 
                                                                                  │                    <OK> │ 
                                                                                  │                         │ 
                                                                                  └─────────────────────────

b.选择 System eth0

Ethernet       ↑ │ <Add>     │ 

 │ │   System eth0 

c. 将IPv4 CONFIGURATION <Automatic>       参数选择为 --Manual (手动配置)                                           
d. 根据实际情况添加IP地址,网关                                                                     │ 
                                                          │ ╤ IPv4 CONFIGURATION <Manual>                                 <Hide>    │ 
                                                          │ │          Addresses _________________________ <Remove>                 │ 
                                                          │ │                    <Add...>                                           │ 
                                                          │ │            Gateway _________________________                          │ 
                                                          │ │        DNS servers <Add...>                                           │ 
                                                          │ │     Search domains <Add...>                                 

e.记得将此两项(空格)勾选 Requideire IPv4 addressing for this connection     #利用IPv4进行激活 

Automatically connect     #每次开机自动激活配置  

f.退出保存,并重新激活端口

# nmcli  connection  up  'System eth0'

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值