Linux网卡配置详解

网卡配置文件

[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eno16777736

TYPE=Ethernet 类型=以太网

BOOTPROTO=dhcp 协议=dhcp (手动表示static)

DEFROUTE=yes

PEERDNS=yes

PEERROUTES=yes

IPV4_FAILURE_FATAL=no

IPV6INIT=yes

IPV6_AUTOCONF=yes

IPV6_DEFROUTE=yes

IPV6_PEERDNS=yes

IPV6_PEERROUTES=yes

IPV6_FAILURE_FATAL=no

NAME=eno16777736   

UUID=98c42a89-363f-46f6-9dd4-344c371330fb

DEVICE=eno16777736  设备名

ONBOOT=no 

二.使用nmcli

1.如何添加一个网络设置

[root@localhost ~]# nmcli device show查看

[root@localhost ~]# nmcli connection edit eno16777736

nmcli> goto ipv4             【method manual方法手工】

Linux网卡配置详解_第1张图片

配置后:

Linux网卡配置详解_第2张图片

[root@localhost ~]# nmcli connection up eno16777736【激活会话】

得到地址inet 192.168.91.140/24 brd 192.168.91.255 scope global eno16777736

启用某个会话

[root@localhost ~]# nmcli connection up +【名称】

--------------------连接

 

2.添加第二个地址:

如何更改网络配置

--------------------------

1一次性配置

[root@localhost ~]# nmcli connection modify eno16777736 +ipv4.addresses 192.168.91.139/24 ipv4.gateway 192.168.91.254 ipv4.dns 114.114.114.114 connection.autoconnect  yes

2逐条配置

[root@localhost ~]# nmcli connection modify eno16777736 +ipv4.addresses 192.168.91.13

9/24

[root@localhost ~]# nmcli connection modify eno16777736 ipv4.gateway 192.168.91.254

[root@localhost ~]# nmcli connection modify eno16777736 ipv4.dns 114.114.114.114

[root@localhost ~]# nmcli connection modify eno16777736 connection.autoconnect  yes

-------------------------

[root@localhost ~]# nmcli connection up eno16777736  【激活会话】

3.设置多会话的网络

添加会话

[root@localhost ~]# nmcli connection add con-name home ifname eno16777736 type ethernet

成功添加的连接 'home'(01e12304-c51e-41d6-836b-b361dff2143b)。

[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-home

Linux网卡配置详解_第3张图片

获取地址方式dhcp

 

 

[root@localhost ~]# nmcli connection show

[root@localhost ~]# nmcli connection up home [激活]

设置IP地址信息

nmcli connection modify home ipv4.addresses “192.168.91.1/24”

更改ip地址获取方式(静态

nmcli connection modify home ipv3.method manual

dhcp方式设置

nmcli connection modify home ipv3.method auto

--------------

启用会话 #nmcli connection up work

 

##图形工具nmtui

##图形工具nm-connection-editor

你可能感兴趣的:(Linxu)