Forrest logo
back to the nmcli tool

nmcli-connection:tldr:af139

nmcli-connection: Create a static IPv4-only connection.
$ nmcli connection add ifname ${interface_name} type ${ethernet} ip4 ${10-0-0-7-8} gw4 ${10-0-0-1} ipv4.dns ${10-0-0-1} ipv6.method ${ignore}
try on your machine

This command is used to add a new network connection using the nmcli tool in Linux.

Here's a breakdown of the command:

  • connection add: This part of the command specifies that we want to add a new network connection.
  • ifname ${interface_name}: Here, ${interface_name} is a placeholder for the name of the interface (e.g., eth0, ens33) through which you want to create the connection.
  • type ${ethernet}: The ${ethernet} placeholder represents the type of connection you want to create, in this case, an Ethernet connection.
  • ip4 ${10-0-0-7-8}: This defines the IPv4 address to be assigned to the connection. ${10-0-0-7-8} is a placeholder for the specific IP address you want to assign.
  • gw4 ${10-0-0-1}: This sets the IPv4 gateway address for the connection. ${10-0-0-1} is a placeholder for the specific gateway IP address.
  • ipv4.dns ${10-0-0-1}: This specifies the IPv4 DNS server to be used for the connection. ${10-0-0-1} is the placeholder for the specific DNS server IP address.
  • ipv6.method ${ignore}: This sets the method for handling IPv6 protocol. ${ignore} is the placeholder for the method you want to choose, in this case, "ignore" means the system will ignore the IPv6 protocol for this connection.

Note: The IP addresses mentioned in the command are placeholders, and you would need to replace them with actual IP addresses suitable for your network configuration.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the nmcli tool