Modify
NICs
nmtui
Provides a text user interface to easily modify network interface settings through NetworkManager.
ifconfig <interface> <IP_address> netmask <netmask>
Assigns an IP and netmask
ip link set eth0 address 00:11:22:33:44:55
Change MAC address (temporarily)
ifconfig <interface> up|down
Activates/deactivates an interface
ip addr add <IP_address>/<netmask> dev <interface>
Adds an IP and netmask
ip addr del <IP_address>/<netmask> dev <interface>
Deletes an IP from a network interface
ip link set <interface> up|down
Brings a network interface up or down
ip link set dev <interface> name <new_name>
Changes the name of a network interface.
ethtool -G <interface> rx <value> tx <value>
Changes the RX and TX ring buffer sizes for an Eth interface.
ethtool -s eth0 speed 100 duplex full autoneg on
Change speed, duplex mode, auto-negotiation
iwconfig <interface> essid <ESSID>
Sets the ESSID (network name) for a wireless network interface.
iwconfig <interface> mode <mode>
Set operating mode of a wireless interface (e.g., Managed, Master, Monitor).
iw <interface> set type <type>
Changes the type of a wireless interface (e.g., managed, monitor) using the iw
command.
ip route add|del via dev
Adds or deletes a route to a network or host via a specified gateway
ethtool -s <interface> speed <speed> duplex <duplex> autoneg on|off
Changes the speed, duplex mode, and autonegotiation settings for an Ethernet interface
nmcli device modify <interface> ipv4.addresses <IP>/<netmask> ipv4.gateway <gateway> ipv4.dns "<dns_servers>"
Modifies the IP address, gateway, and DNS settings for a network interface using NetworkManager
Adds or deletes a route to a network or host via a specified gateway:
Changes the speed, duplex mode, and autonegotiation settings for an Ethernet interface:
Modifies the IP address, gateway, and DNS settings for a network interface using NetworkManager:
Config Files (persistent changes)
Edit /etc/network/interfaces (Debian/Ubuntu):
Add lines like auto eth0
, iface eth0 inet static
, address 192.168.1.100
, netmask 255.255.255.0
.
Edit /etc/sysconfig/network-scripts/ifcfg-eth0 (Red Hat/CentOS):
Modify BOOTPROTO
, IPADDR
, NETMASK
, etc.
ARP
arp -d <IP>
Deletes an ARP
ip neigh del <IP>
Deletes an ARP
ip neigh del <IP_address> dev <interface>
Deletes an ARP entry for the specified IP
arp -s <IP> <MAC>
Adds a static ARP entry
ip neigh add <IP> lladdr <MAC>
Adds a static ARP entry
ip neigh add <IP> lladdr <MAC> nud permanent dev <interface>
Adds a static ARP entry
Replaces or adds an ARP entry. If the entry for the specified IP address exists, it is updated; otherwise, a new entry is added:
Removes ARP entries matching the <selector>
, which can be an IP
, network
, or all
to clear the entire ARP cache:
DNS
Direct File Editing
Edit /etc/resolv.conf for temporary changes:
Add or modify nameserver lines to specify DNS servers.
Add or modify search lines to set search domains.
Changes might not persist after network restarts or DHCP updates.
sudo vi /etc/resolv.conf
Modify nsswitch.conf for DNS Lookup Order
/etc/nsswitch.conf: This file controls the sources from which names are resolved (e.g., hosts, passwords).
For DNS, you might modify the hosts: line to change the lookup order.
Example command to edit:
sudo vi /etc/nsswitch.conf
Network Manager (if applicable)
Use GUI or command-line tools like nmcli or nmtui to modify DNS settings via Network Manager. Changes usually persist across reboots and network changes.
nmcli: For systems using NetworkManager, nmcli can modify DNS settings.
To set DNS servers on a specific connection:
nmcli con mod <connection_name> ipv4.dns "<DNS_servers>"
nmcli con mod <connection_name> ipv6.dns "<DNS_servers>"
To reload the connection and apply changes:
nmcli con up <connection_name>
dhclient
dhclient: If your system uses DHCP to obtain network settings, including DNS, you might need to modify the DHCP client configuration to change DNS behavior. \
The configuration file might vary, but commonly /etc/dhcp/dhclient.conf is used. \
You can specify prepend domain-name-servers <DNS_server_IP>
; to add custom DNS servers. \
Example command to edit dhclient.conf:
sudo vi /etc/dhcp/dhclient.conf
Distribution-Specific Tools
Debian/Ubuntu: Use resolvconf
to manage resolv.conf dynamically.
Red Hat/CentOS: Use systemd-resolved
to manage DNS configuration. systemd-resolve or resolvectl: On systems using systemd-resolved, this tool manages DNS settings. \
To set global DNS servers: ` sudo systemd-resolve --set-dns=<DNS_server_IP> --interface=<interface_name>
To set DNS domains for searches: ` sudo systemd-resolve --set-domain= --interface=<interface_name>
Routing Tables
ip route add <network>/<prefix> via <gateway>
Add a route
route add -net <network> netmask <netmask> gw <gateway>
Add a route
ip route del <network>/<prefix>
Delete a route
route del -net <network> netmask <netmask>
Delete a route
ip route add default via <gateway>
Change the default gateway
route add default gw <gateway>
Change the default gateway
ip route flush all
Flush all routes
Config Files (persistent changes)
Edit /etc/network/interfaces (Debian/Ubuntu): Add post-up
or pre-up
commands to execute routing commands after interface activation.
Edit /etc/sysconfig/network-scripts/route-<interface> (Red Hat/CentOS): Add routing rules directly to configuration files.
Sockets
Adjusts the range of ports available for user-space applications:
Enables reuse of sockets in TIME-WAIT state for new connections, affecting how sockets are managed:
Uses Uncomplicated Firewall (ufw) to allow or deny access to specific ports on Ubuntu and other systems:
Allows incoming TCP connections on a specific port. Modify rules to control access to sockets:
The easiest way to open and close ports is to kill/disable the process/service using it. Otherwise, you can make firewall/iptable rules to block/allow/etc.
Last updated
Was this helpful?