New Linux Network Config
New Linux Network Config
Ethernet Interfaces
• Identify Ethernet Interfaces
• To quickly identify all available Ethernet interfaces, you
can use the ip command.
– ip a
• To identify all network interfaces available to your system
is the lshw command. This command provides greater
details around the hardware capabilities of specific
adapters
– lshw -class network
Ethernet Interface Settings
• ethtool is a program that displays and changes
Ethernet card settings such as auto-negotiation, port
speed, duplex mode, and Wake-on-LAN.
– ethtool enp0s25
IP Addressing
• To temporarily configure an IP address, you can use the ip command
– ip addr add 10.102.66.200/24 dev enp0s25
• The ip can then be used to set the link up or down.
– ip link set dev enp0s25 up
– ip link set dev enp0s25 down
• To verify the IP address configuration of enp0s25
– ip address show dev enp0s25
• To delete the IP address configuration
– ip addr del 192.168.1.200/24 dev enp0s25
• Add alias interface
– ip addr add 10.0.0.1/8 dev enp0s25 label enp0s25 :1
• If you no longer need this configuration and wish to purge all IP configuration from an interface
– ip addr flush enp0s25
IP Addressing
• To temporarily configure Dynamic IP Address Assignment (DHCP
Client)
– dhclient enp0s25
Routing
• To configure a default gateway
– ip route add default via 10.102.66.1
• Add a new route to network
– ip route add {NETWORK/MASK} via {GATEWAYIP}
– ip route add 192.168.1.0/24 via 192.168.1.254
• To verify your default gateway configuration
– ip route show
DNS
• If you require DNS for your temporary network
configuration, you can add DNS server IP addresses in
the file /etc/resolv.conf.
– nameserver 8.8.8.8
Set Permanent Config
• Open the netplan configuration file using your text editor
• In case a YAML file is not created by the distribution installer, you can
generate the required configuration for the renderers with this command.
– netplan generate
– pico /etc/netplan/01-netcfg.yaml
Set Permanent Config
• The configuration can then be applied using the netplan command
– netplan apply
• To configure IP address dynamically through DHCP