Configuration
Link
Change Status
To change the status of a link, the
ip link set
command can be used:sudo ip link set <interface> <up|down|...>
Example:
sudo ip link set ens18 up
IP Address
Flush IP Addresses
To remove all ip addresses of an interface, the
ip addr flush
command can be used:sudo ip addr flush dev <interface>
Example:
sudo ip addr flush dev ens18
where
ens18
is the name of the network interface.
Add IP Addresses
An ip address can be added to an interface using the
ip addr add
command:sudo ip addr add <ip-address>/<prefix-length> dev <interface>
Example:
sudo ip addr add 192.168.10.1/24 dev ens18
where
ens18
is the name of the network interface and192.168.10.1
is the ip address and24
is the prefix length, which corresponds to a network mask of255.255.255.0
.
Default Gateway
Change Default Gateway
The default gateway of an interface can be configured using the
ip route
command:sudo ip route flush default sudo ip route add default via <gateway-ip> dev <interface>
Example:
sudo ip route flush default sudo ip route add default via 192.168.10.1 dev ens18
where
ens18
is the name of the network interface and192.168.10.1
is the IP address of the default gateway.
DNS Nameserver
Change DNS nameservers
The DNS nameservers can be configured in
/etc/resolv.conf
. For example, to use Cloudflare’s nameservers:options edns0 nameserver 1.1.1.1 nameserver 1.0.0.1