1. Set IP address, gateway
Cp/etc/network/interfaces/etc/network/interfaces.bak # Backing up legacy configuration Files
Vi/etc/network/interfaces # Edit Network adapter profile
# The Loopback network interface
Auto Lo
Iface Lo inet Loopback
# The Primary network interface
Auto eth0 # Auto Connect network
Allow-hotplug eth0
Iface eth0 inet Static # static means using dynamic IP with fixed ip,dhcp representations
Address 192.168.21.166 # set IP address
netmask 255.255.255.0 # Set Subnet mask
Gateway 192.168.21.2 # Setting up gateways
Press the ESC key, and then enter: EQ to save and exit.
The following version is easy to copy because it is best not to have Chinese in the configuration file:
# The Loopback network interface
Auto Lo
Iface Lo inet Loopback
# The Primary network interface
Auto Eth0
Allow-hotplug eth0
Iface eth0 inet Static
Address 192.168.21.166
Netmask 255.255.255.0
Gateway 192.168.21.1
2. Set up DNS
Cp/etc/resolv.conf/etc/resolv.conf.bak # Backing up the original DNS configuration file
Vi/etc/resolv.conf # Edit configuration file
NameServer 127.0.0.1
NameServer 8.8.8.8 # Setting Preferred DNS
NameServer 8.8.4.4 # Setting up alternate DNS
Press the ESC key, and then enter: EQ to save and exit.
The following version is easy to copy because it is best not to have Chinese in the configuration file:
NameServer 127.0.0.1
NameServer 8.8.8.8
NameServer 8.8.4.4
3. Restart the network
Service Networking Restart # Restart Network
At this point, the IP address, gateway, DNS configuration is complete, now the system is ready to go online.
Set IP address, Gateway, DNS in Debian