ip address add [ipaddress/netmask-prefix] dev [iface-name] ip address add 192.168.89.2/24 dev enp0s8 ip link set dev enp0s8 up
ip route add default via [gw-address] dev [iface-name] ip route add default via 192.168.89.1 dev enp0s8 ip route add default via 192.168.89.1 dev enp0s8 metric 100 (if there is 2 interface with different gateway, https://askubuntu.com/questions/293827/error-rtnetlink-answers-file-exists).
dhclient [iface-name] dhclient enp0s8
vim /etc/network/interfaces
auto enp0s8
iface enp0s8 inet static
address 192.168.88.2
netmask 255.255.255.0
gateway 192.168.88.1
service networking restart
vim /etc/network/interfaces
auto enp0s8
iface enp0s8 inet dhcp
service networking restart
Ubuntu 18.04 Bionic Beaver has switched to Netplan (/etc/netplan) for configuring network interfaces. This is a yaml based configuration system, which should simplify the process. To re-enable ifupdown on Ubuntu 18.04 system, you must install ifupdown package first.
vim /etc/netplan/50-cloud-init.yaml
# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
ethernets:
enp0s8:
addresses: [192.168.88.2/24]
gateway4: 192.168.88.1
nameservers:
addresses: [8.8.8.8,8.8.4.4]
dhcp4: no
version: 2
Validate configuration : netplan try Save configuration : netplan --debug apply
vim /etc/netplan/50-cloud-init.yaml
# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
ethernets:
enp0s8:
addresses:
dhcp4: true
optional: true
version: 2
Validate configuration : netplan try Save configuration : netplan --debug apply
echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.conf; sysctl -p
Name resolution as it relates to IP networking is the process of mapping IP addresses to hostnames, making it easier to identify resources on a network. If you require DNS for your temporary network configuration, you can add DNS server IP addresses in the file /etc/resolv.conf. In general, editing /etc/resolv.conf directly is not recommanded, but this is a temporary and non-persistent configuration.
To configure the resolver permanently, add the IP addresses of the nameservers that are appropriate for your network to the netplan configuration file. You can also add an optional DNS suffix search-lists to match your network domain names.
nameservers:
search: [example.com, sales.example.com, dev.example.com]
addresses: [1.1.1.1, 8.8.8.8, 4.4.4.4]
ip addr flush [iface-name]