1. Configure the IP address
Edit the/etc/Network/interfaces file.
For example, fixed IP Address:
Auto eth0
# Iface eth0 Inet DHCP Dynamic Allocation
Iface eht0 Inet static
Address 192.168.1.254
Netmask 255.255.255.0
Gateway 192.168.1.1
Nameserver 192.168.1.1
Restart
Sudo/etc/init. d/networking restart
2. Configure DNS
Edit/etc/resolve. conf
Specify as follows:
Nameserver 127.0.0.1
The reprinted content is as follows:
Ubuntu Command Line Network Configuration Modification Method
/Etc/Network/interfaces
After it is enabled, you can set DHCP or manually set static IP addresses. Auto eth0 in front to enable automatic Nic mounting.
1. Configure the NIC in DHCP Mode
Edit the file/etc/Network/interfaces:
Sudo VI/etc/Network/interfaces
Replace eth0 with the following rows:
# The primary network interface-use DHCP to find our address
Auto eth0
Iface eth0 Inet DHCP
Run the following command to make the network settings take effect:
Sudo/etc/init. d/networking restart
You can also enter the following command in the command line to obtain the address.
Sudo dhclient eth0
2. configure a static IP address for the NIC
Edit the file/etc/Network/interfaces:
Sudo VI/etc/Network/interfaces
Replace eth0 with the following rows: # the primary network interface
Auto eth0
Iface eth0 Inet static
Address 192.168.3.90
Gateway 192.168.3.1
Netmask 255.255.255.0
# Network 192.168.3.0
# Broadcast 192.168.3.255
Replace the preceding IP address and other information with your own. Use the following command to make the network settings take effect:
Sudo/etc/init. d/networking restart
3. Set the second IP address (virtual IP address)
Edit the file/etc/Network/interfaces:
Sudo VI/etc/Network/interfaces
Add the following lines to the file:
Auto eth0: 1
Iface eth0: 1 Inet static
Address 192.168.1.60
Netmask 255.255.255.0
Network x. x
Broadcast x. x
Gateway x. x
Fill in all information such as address, netmask, network, broadcast, and gateways according to your situation.
Run the following command to make the network settings take effect:
Sudo/etc/init. d/networking restart
4. Set Host Name (hostname)
Run the following command to view the Host Name of the current host:
Sudo/bin/hostname
Run the following command to set the Host Name of the current host:
Sudo/bin/hostname newname
When the system starts, it reads the host name from/etc/hostname.
For more information about setting host names, visit here
5. Configure DNS
First, you can add some host names to/etc/hosts and the IP addresses corresponding to these host names. This is a simple static query on the local machine.
To access the DNS server for query, you need to set the/etc/resolv. conf file.
If the IP address of the DNS server is 192.168.3.2, the content of the/etc/resolv. conf file should be:
Search test.com
nameserver 192.168.3.2