Linux IP配置

1010 人觉得有用

1 Centos6、Centos7

编辑 网卡配置文件

cd /etc/sysconfig/network-scripts 

查看网卡名:ls

打开网卡:vi ifcfg-eth0(文件名根据实际写入)  

增加内容:

=============================

IPADDR1=192.168.0.11

NETMASK1=255.255.255.0

=============================

每增加一个IP对应一组(注意序号)

成品如下

重启网卡(不通版本的Centos重启网卡命令不一样)

Centos6:

/etc/init.d/network restart

Centos7:

systemctl restart network

Centos8:

nmcli d reapply ethX   (这里的ethX是网卡名字,这里根据主机的实际情况填写)

到此完成

2 Ubuntu、Debin

安装net-tools工具

apt-get install net-tools -y

编辑网卡配置文件

vim /etc/network/interfaces

 

如下写入:

source /etc/network/interfaces.d/*

# Network is managed by Network manager

auto eth0

 

#iface eth0 inet dhcp

 

iface eth0 inet static

address 192.168.6.22

netmask 255.255.255.0

 

auto eth0:1

iface eth0:1 inet static

address 192.168.7.20

netmask 255.255.255.0

 

auto eth0:2

iface eth0:2 inet static

address 10.10.15.1

netmask 255.255.255.0

 

 

auto lo

iface lo inet loopback

 

添加好新IP信息后不要重启网卡

再手动配置新IP

ifconfig enp1s0f0:1 154.196.128.22 netmask 255.255.255.0

ifconfig enp1s0f0:2 154.196.128.23 netmask 255.255.255.0

到此完成

这篇文章有帮助吗?