NetworkManager: Difference between revisions
No edit summary |
|||
(11 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
==Summary== | ==Summary== | ||
nmcli | <code>nmcli</code> is a command-line tool used to interact with NetworkManager, a Linux utility that manages network connections. <code>nmcli</code> allows you to create, configure, manage, and troubleshoot network interfaces and connections directly from the terminal without using a graphical interface. | ||
==New Network Connection== | |||
== | ===Gather info=== | ||
These commands are useful in gathering network information about a host. | |||
ip addr | ip addr | ||
nmcli con show | |||
nmcli dev status | |||
nmcli con | ===Delete a connection=== | ||
nmcli con del {name} | |||
===Add a new connection=== | |||
nmcli con add con-name {name} ifname {interface} type ethernet ipv4.addresses {ip/sm} ipv4.gateway {ip} | |||
===Modify existing connection=== | |||
nmcli con mod {name} ipv4.dns "{ip1},{ip2}" | |||
nmcli con mod {name} ipv4.addr {x.x.x.x/x} | |||
nmcli con mod {name} ipv4.gateway {x.x.x.x} | |||
===Bring connection up=== | |||
nmcli con | nmcli con up {name} | ||
===Bring connection down=== | |||
nmcli con | nmcli con up {name} | ||
===Bring connection down/up=== | |||
Brings it down and then immediately back up, even if you lose connectivity in between (as long as you configured everything correctly). | |||
nmcli con up | nmcli con down {name}; nmcli con up {name} | ||
==Other Useful Commands== | ==Other Useful Commands== | ||
Show all connections | ===Show all connections=== | ||
nmcli con show | nmcli con show | ||
Show all | ===Show all interfaces=== | ||
nmcli dev show | nmcli dev show | ||
Line 37: | Line 55: | ||
nmcli dev status | nmcli dev status | ||
Add a new connection to an interface | ===Add a new connection to an interface=== | ||
nmcli con add con-name {name} ifname {interface} type ethernet ipv4.addresses {ip/sm} ipv4.gateway {ip} ipv4.dns {ip1},{ip2} | |||
===Show details about a connection=== | |||
nmcli con show {name} | more | |||
===Modify the IP address, etc. for an existing connection=== | |||
nmcli con mod {name} ipv4.addresses {ip/sm} | |||
nmcli con mod | nmcli con mod {name} ipv4.dns {ip1},{ip2} | ||
nmcli con mod | nmcli con mod {name} ipv4.dns-search "{domain suffix}" | ||
===Create an 802.1Q interface for use on a trunk port=== | |||
This is also called a ''VLAN'' or ''subinterface''. | |||
nmcli con add type vlan con-name | nmcli con add type vlan con-name {name}.{vlan#} ifname {interface}.{vlan#} dev {interface} id {vlan#} ipv4.addresses {ip/sm} ipv4.gateway {ip} | ||
==Bonding== | ==Bonding== | ||
A network bond is a method to combine or aggregate physical and virtual network interfaces to provide a logical interface with higher throughput or redundancy. In a bond, the kernel handles all operations exclusively. You can create bonds on different types of | A network bond is a method to combine or aggregate physical and virtual network interfaces to provide a logical interface with higher throughput or redundancy. In a bond, the kernel handles all operations exclusively. You can create bonds on different types of interfaces, such as Ethernet interfaces or VLANs. | ||
===Example=== | ===Example=== | ||
In this example, I was able to successfully bond two links to a Juniper EX3300 using LACP (802.3ad): | In this example, I was able to successfully bond two links to a Juniper EX3300 (and later an EX3400) using LACP (802.3ad): | ||
{{Info|Be sure to delete any existing connection profiles that are applied to any interfaces you plan to use as slaves.}} | {{Info|Be sure to delete any existing connection profiles that are applied to any interfaces you plan to use as slaves.}} | ||
nmcli connection add type bond con-name bond0 ifname bond0 bond.options "mode=802.3ad,lacp_rate=fast" | |||
nmcli connection modify bond0 connection.autoconnect-slaves 1 | |||
nmcli connection add type ethernet slave-type bond con-name bond0-port0 ifname enp129s0f0 master bond0 | |||
nmcli connection add type ethernet slave-type bond con-name bond0-port1 ifname enp129s0f1 master bond0 | |||
nmcli connection modify bond0 ipv4.addresses '10.144.30.20/24' ipv4.gateway '10.144.30.1' ipv4.dns '10.144.30.4,10.150.30.2' ipv4.dns-search 'lambnet.us' ipv4.method manual | |||
===Verification=== | ===Verification=== | ||
cat /proc/net/bonding/bond0 | |||
Also, unplug one member cable of the bond at a time while performing a ping, to confirm link stays up. | Also, unplug one member cable of the bond at a time while performing a ping, to confirm link stays up. | ||
===Sources=== | ===Sources=== | ||
{https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html/configuring_and_managing_networking/configuring-network-bonding_configuring-and-managing-networking https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html/configuring_and_managing_networking/configuring-network-bonding_configuring-and-managing-networking} | |||
{https://www.kernel.org/doc/Documentation/networking/bonding.txt https://www.kernel.org/doc/Documentation/networking/bonding.txt} |
Latest revision as of 23:21, 20 January 2025
Summary
nmcli
is a command-line tool used to interact with NetworkManager, a Linux utility that manages network connections. nmcli
allows you to create, configure, manage, and troubleshoot network interfaces and connections directly from the terminal without using a graphical interface.
New Network Connection
Gather info
These commands are useful in gathering network information about a host.
ip addr nmcli con show nmcli dev status
Delete a connection
nmcli con del {name}
Add a new connection
nmcli con add con-name {name} ifname {interface} type ethernet ipv4.addresses {ip/sm} ipv4.gateway {ip}
Modify existing connection
nmcli con mod {name} ipv4.dns "{ip1},{ip2}"
nmcli con mod {name} ipv4.addr {x.x.x.x/x}
nmcli con mod {name} ipv4.gateway {x.x.x.x}
Bring connection up
nmcli con up {name}
Bring connection down
nmcli con up {name}
Bring connection down/up
Brings it down and then immediately back up, even if you lose connectivity in between (as long as you configured everything correctly).
nmcli con down {name}; nmcli con up {name}
Other Useful Commands
Show all connections
nmcli con show
Show all interfaces
nmcli dev show
nmcli dev status
Add a new connection to an interface
nmcli con add con-name {name} ifname {interface} type ethernet ipv4.addresses {ip/sm} ipv4.gateway {ip} ipv4.dns {ip1},{ip2}
Show details about a connection
nmcli con show {name} | more
Modify the IP address, etc. for an existing connection
nmcli con mod {name} ipv4.addresses {ip/sm}
nmcli con mod {name} ipv4.dns {ip1},{ip2}
nmcli con mod {name} ipv4.dns-search "{domain suffix}"
Create an 802.1Q interface for use on a trunk port
This is also called a VLAN or subinterface.
nmcli con add type vlan con-name {name}.{vlan#} ifname {interface}.{vlan#} dev {interface} id {vlan#} ipv4.addresses {ip/sm} ipv4.gateway {ip}
Bonding
A network bond is a method to combine or aggregate physical and virtual network interfaces to provide a logical interface with higher throughput or redundancy. In a bond, the kernel handles all operations exclusively. You can create bonds on different types of interfaces, such as Ethernet interfaces or VLANs.
Example
In this example, I was able to successfully bond two links to a Juniper EX3300 (and later an EX3400) using LACP (802.3ad):
Info: Be sure to delete any existing connection profiles that are applied to any interfaces you plan to use as slaves.
nmcli connection add type bond con-name bond0 ifname bond0 bond.options "mode=802.3ad,lacp_rate=fast" nmcli connection modify bond0 connection.autoconnect-slaves 1 nmcli connection add type ethernet slave-type bond con-name bond0-port0 ifname enp129s0f0 master bond0 nmcli connection add type ethernet slave-type bond con-name bond0-port1 ifname enp129s0f1 master bond0 nmcli connection modify bond0 ipv4.addresses '10.144.30.20/24' ipv4.gateway '10.144.30.1' ipv4.dns '10.144.30.4,10.150.30.2' ipv4.dns-search 'lambnet.us' ipv4.method manual
Verification
cat /proc/net/bonding/bond0
Also, unplug one member cable of the bond at a time while performing a ping, to confirm link stays up.
Sources
{https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html/configuring_and_managing_networking/configuring-network-bonding_configuring-and-managing-networking https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html/configuring_and_managing_networking/configuring-network-bonding_configuring-and-managing-networking}
{https://www.kernel.org/doc/Documentation/networking/bonding.txt https://www.kernel.org/doc/Documentation/networking/bonding.txt}