Set IPv4 in Ubuntu: edit/etc/network/interfaces and/etc/resolv. conf files. The former sets the IP address, gateway, and subnet mask, and the latter sets dns and other attributes. Example: 1. configure the NIC in DHCP mode to edit the file/etc/network/interfaces: sudovi/etc/network/interfaces and replace the eth0 row with the following line: # Th
Set IPv4 in Ubuntu:
Edit the/etc/network/interfaces and/etc/resolv. conf files. The former sets IP addresses, gateways, and subnet masks, and the latter sets dns and other attributes.
Example:
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. 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:
Nameserver 192.168.3.2