Linux 7 配置網路卡(nmcli)
作業系統版本:
[root@cjcos01 network-scripts]# cat /etc/redhat-release Red Hat Enterprise Linux Server release 7.5 (Maipo)
檢視網路卡、IP等資訊:
[root@cjcos01 ~]# ifconfig enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.1.90 netmask 255.255.255.0 broadcast 192.168.1.255 inet6 fe80::e07:b869:9f7b:792a prefixlen 64 scopeid 0x20<link> ether 08:00:27:bc:de:5e txqueuelen 1000 (Ethernet) RX packets 929 bytes 1120691 (1.0 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 759 bytes 68662 (67.0 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 ether 08:00:27:93:03:0a txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 enp0s9: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 ether 08:00:27:de:7f:38 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 enp0s10: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 ether 08:00:27:56:39:b6 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 0 (Local Loopback) RX packets 166 bytes 17894 (17.4 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 166 bytes 17894 (17.4 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255 ether 52:54:00:45:70:b3 txqueuelen 0 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
檢視配置資訊
[root@cjcos01 network-scripts]# ls -l ifcfg-* -rw-r--r-- 1 root root 472 Sep 16 10:23 ifcfg-enp0s3 -rw-r--r--. 1 root root 254 Jan 3 2018 ifcfg-lo
檢視nmcli命令
[root@cjcos01 network-scripts]# man -k nmcli nmcli (1) - command-line tool for controlling NetworkManager nmcli-examples (7) - usage examples of nmcli
[root@cjcos01 network-scripts]# man nmcli 7 CONNECTION MANAGEMENT COMMANDS nmcli connection {show | up | down | modify | add | edit | clone | delete | monitor | reload | load | import | export} [ARGUMENTS...]
新增網路卡
[root@cjcos01 network-scripts]# nmcli connection add con-name enp0s8 type ethernet ifname enp0s8 ipv4.method manual ipv4.addresses 192.100.100.10/24 connection.autoconnect yes Connection 'enp0s8' (f81306db-bac5-4b2c-ac52-b42c0ca52621) successfully added.
[root@cjcos01 network-scripts]# nmcli connection add con-name enp0s9 type ethernet ifname enp0s9 ipv4.method manual ipv4.addresses 192.100.100.20/24 connection.autoconnect yes Connection 'enp0s9' (587e0d6b-c4af-4273-9c48-bd2f66fbbc84) successfully added.
檢視網路卡配置
[root@cjcos01 network-scripts]# cat ifcfg-enp0s8 TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=none IPADDR=192.100.100.10 PREFIX=24 DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=enp0s8 UUID=f81306db-bac5-4b2c-ac52-b42c0ca52621 DEVICE=enp0s8 ONBOOT=yes
[root@cjcos01 network-scripts]# cat ifcfg-enp0s9 TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=none IPADDR=192.100.100.20 PREFIX=24 DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=enp0s9 UUID=587e0d6b-c4af-4273-9c48-bd2f66fbbc84 DEVICE=enp0s9 ONBOOT=yes
檢視網路卡資訊
[root@cjcos01 network-scripts]# nmcli connection show NAME UUID TYPE DEVICE enp0s3 b0b58151-2738-4a9b-8e49-30341e577a60 ethernet enp0s3 enp0s8 f81306db-bac5-4b2c-ac52-b42c0ca52621 ethernet enp0s8 enp0s9 587e0d6b-c4af-4273-9c48-bd2f66fbbc84 ethernet enp0s9 virbr0 c6b6e6fd-1b38-4493-865c-317c16360e46 bridge virbr0
刪除網路卡
[root@cjcos01 network-scripts]# nmcli connection delete enp0s8 Connection 'enp0s8' (2eec6955-a3dd-4909-9cfc-89f06c2a9aca) successfully deleted. Connection 'enp0s8' (972fecaa-7123-45de-8248-dd77912606a2) successfully deleted. Connection 'enp0s8' (7916c63a-2c4e-46a5-8dd6-1d752f694825) successfully deleted.
網路卡繫結
[root@cjcos01 network-scripts]# nmcli connection add type bond ifname bond0 mode 1 ip4 192.100.100.30/24 ipv4.gateway 192.100.100.254 Connection 'bond-bond0' (80418cf9-d103-4bc3-a5b8-17783a5dd4c5) successfully added. [root@cjcos01 network-scripts]# nmcli connection add type bond-slave ifname enp0s8 master bond0 Connection 'bond-slave-enp0s8' (9a848655-4f43-423e-b63e-0c382406a208) successfully added. [root@cjcos01 network-scripts]# nmcli connection add type bond-slave ifname enp0s9 master bond0 Connection 'bond-slave-enp0s9' (df987cba-99bf-444f-a060-e096291a9d3c) successfully added.
檢視資訊
[root@cjcos01 network-scripts]# nmcli connection show NAME UUID TYPE DEVICE bond-bond0 80418cf9-d103-4bc3-a5b8-17783a5dd4c5 bond bond0 enp0s3 b0b58151-2738-4a9b-8e49-30341e577a60 ethernet enp0s3 enp0s8 f81306db-bac5-4b2c-ac52-b42c0ca52621 ethernet enp0s8 enp0s9 587e0d6b-c4af-4273-9c48-bd2f66fbbc84 ethernet enp0s9 virbr0 c6b6e6fd-1b38-4493-865c-317c16360e46 bridge virbr0 bond-slave-enp0s8 9a848655-4f43-423e-b63e-0c382406a208 ethernet -- bond-slave-enp0s9 df987cba-99bf-444f-a060-e096291a9d3c ethernet --
[root@cjcos01 network-scripts]# cat ifcfg-bond-bond0 BONDING_OPTS=mode=active-backup TYPE=Bond BONDING_MASTER=yes PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=none IPADDR=192.100.100.30 PREFIX=24 GATEWAY=192.100.100.254 DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=bond-bond0 UUID=80418cf9-d103-4bc3-a5b8-17783a5dd4c5 DEVICE=bond0 ONBOOT=yes
[root@cjcos01 network-scripts]# cat ifcfg-bond-slave-enp0s8 TYPE=Ethernet NAME=bond-slave-enp0s8 UUID=9a848655-4f43-423e-b63e-0c382406a208 DEVICE=enp0s8 ONBOOT=yes MASTER=bond0 SLAVE=yes
[root@cjcos01 network-scripts]# cat ifcfg-bond-slave-enp0s9 TYPE=Ethernet NAME=bond-slave-enp0s9 UUID=df987cba-99bf-444f-a060-e096291a9d3c DEVICE=enp0s9 ONBOOT=yes MASTER=bond0 SLAVE=yes
檢視網路卡繫結資訊
[root@cjcos01 network-scripts]# cat /proc/net/bonding/bond0 Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011) Bonding Mode: fault-tolerance (active-backup) Primary Slave: None Currently Active Slave: None MII Status: down MII Polling Interval (ms): 100 Up Delay (ms): 0 Down Delay (ms): 0
啟動網路卡
[root@cjcos01 network-scripts]# nmcli connection up bond-bond0 [root@cjcos01 network-scripts]# nmcli connection up bond-slave-enp0s8 [root@cjcos01 network-scripts]# nmcli connection up bond-slave-enp0s9
檢視網路卡繫結狀態
[root@cjcos01 network-scripts]# cat /proc/net/bonding/bond0 Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011) Bonding Mode: fault-tolerance (active-backup) Primary Slave: None Currently Active Slave: enp0s8 MII Status: up MII Polling Interval (ms): 100 Up Delay (ms): 0 Down Delay (ms): 0 Slave Interface: enp0s8 MII Status: up Speed: 1000 Mbps Duplex: full Link Failure Count: 0 Permanent HW addr: 08:00:27:93:03:0a Slave queue ID: 0 Slave Interface: enp0s9 MII Status: up Speed: 1000 Mbps Duplex: full Link Failure Count: 0 Permanent HW addr: 08:00:27:de:7f:38 Slave queue ID: 0
刪除網路卡繫結
[root@cjcos01 network-scripts]# nmcli connection show NAME UUID TYPE DEVICE bond-bond0 80418cf9-d103-4bc3-a5b8-17783a5dd4c5 bond bond0 enp0s3 b0b58151-2738-4a9b-8e49-30341e577a60 ethernet enp0s3 enp0s8 f81306db-bac5-4b2c-ac52-b42c0ca52621 ethernet enp0s8 enp0s9 587e0d6b-c4af-4273-9c48-bd2f66fbbc84 ethernet enp0s9 virbr0 c6b6e6fd-1b38-4493-865c-317c16360e46 bridge virbr0 bond-slave-enp0s8 9a848655-4f43-423e-b63e-0c382406a208 ethernet -- bond-slave-enp0s9 df987cba-99bf-444f-a060-e096291a9d3c ethernet --
[root@cjcos01 network-scripts]# nmcli connection delete bond-bond0 Connection 'bond-bond0' (80418cf9-d103-4bc3-a5b8-17783a5dd4c5) successfully deleted. [root@cjcos01 network-scripts]# nmcli connection delete bond-slave-enp0s8 Connection 'bond-slave-enp0s8' (9a848655-4f43-423e-b63e-0c382406a208) successfully deleted. [root@cjcos01 network-scripts]# nmcli connection delete bond-slave-enp0s9 Connection 'bond-slave-enp0s9' (df987cba-99bf-444f-a060-e096291a9d3c) successfully deleted.
歡迎關注我的微信公眾號"IT小Chen",共同學習,共同成長!!
!
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29785807/viewspace-2721650/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- redhat 7 使用nmcli 命令配置網路Redhat
- 在 Linux 中用 nmcli 命令繫結多塊網路卡Linux
- Linux 網路卡配置Linux
- Linux 雙網路卡雙IP配置Linux
- suse linux配置網路卡bondingLinux
- 安裝配置Linux網路卡(轉)Linux
- Redhat7/CentOS7 網路配置與管理(nmtui、nmcli、GNOME GUI、ifcfg檔案、IP命令)RedhatCentOSGUI
- linux網路卡配置檔案詳解Linux
- LINUX 網路卡配置檔案引數Linux
- Redhat Linux網路卡配置與繫結RedhatLinux
- VMwareNAT網路卡配置
- Oracle Linux 7.1 增加網路卡及IP配置OracleLinux
- Redhat Linux網路卡配置與繫結(zt)RedhatLinux
- 如何在CentOS 7中使用nmcli工具管理網路CentOS
- [Linux] Linux bond 網路卡繫結配置教程(轉載)Linux
- linux下一個網路卡配置多個IPLinux
- Linux網路卡配置檔案 引數詳解Linux
- 【Linux】Linux網路配置基礎1 網路相關命令與網路卡配置檔案Linux
- 配置雙網路卡BOND
- 雙網路卡BOND配置
- 如何在RedHat/CentOS 7.x中使用nmcli管理網路RedhatCentOS
- 配置Linux環境下多網路卡高可用網路埠Linux
- 雲主機新增網路卡配置多網路卡策略路由路由
- Linux網路卡teamLinux
- kali網路卡配置檔案
- vmware克隆機網路卡配置
- (轉)Ubuntu網路卡基本配置Ubuntu
- 雙網路卡bonding配置
- 多網路卡路由出口配置路由
- 【Linux】Linux網路配置基礎3 編輯配置檔案設定網路卡子介面ipLinux
- 【Linux】Linux網路配置基礎2 system-config-network配置網路卡訪問外網Linux
- 深度分析Linux下雙網路卡繫結七種模式 多網路卡的7種bond模式原理Linux模式
- Linux系統下雙網路卡bonding的配置方法Linux
- Linux網路卡的配置檔案詳解及應用Linux
- linux9.0 vmware配置網路卡不能起的bug(轉)Linux
- rocky與linux的nmcli命令用法Linux
- 使用nmcli配置主備模式鏈路聚合模式
- Linux網路卡繫結Linux