当前位置: 首页 > Linux

如何配置LinuxIP

时间:2023-04-06 20:57:17 Linux

IP地址配置rhel7/centos7新增了IP地址配置工具,旧版本没有,这里提供两种方法供参考。方法一:nmcli工具(新版系统有)Step1查看网卡名称[root@localhostDesktop]#nmcliconnection如图,NAME对应网卡名称,和DEVICE对应网卡的硬件标识,名称可以修改。vir开头的是虚拟网卡或者虚拟设备,所以这里要配置eno开头的网卡地址。步骤2配置IP地址[root@localhostDesktop]#nmcliconnectionmodify"eno16777736"ipv4.addresses"172.20.10.3/24"地址和掩码[root@localhostDesktop]#nmcliconnectionmodify"eno16777736"ipv4.gateway"172.20.10.1"gateway[root@localhostDesktop]#nmcliconnectionmodify"eno16777736"ipv4.dns"114.114.114.114"nameserver[root@localhostDesktop]#nmcliconnectionmodify"eno16777736"ipv4.methodmanual手动代替DHCP[root@localhostDesktop]#nmcliconnectionmodify"eno16777736"connection.autoconnectyesstartup[root@localhostDesktop]#nmcliconnectionup"eno16777736"打开界面Step3查看IP地址并测试方法二:通过vi编辑器编辑网卡配置文件(RHEL7以下系统)[root@localhostDesktop]#vi/etc/sysconfig/network-scripts/ifcfg-eno16777736修改下图中对应信息按i进入编辑模式按esc保存退出,按esc然后输入:q!修改完成后,通过servicenetworkrestart重启网络服务