This article is reproduced from: Ubuntu Network Configuration
1、 Configure the network card by DHCP
Edit the file /etc/network/interfaces:sudo vi /etc/network/interfaces and replace the line about eth0 with the following line:
auto eth0
iface eth0 inet dhcp
Use the following command to make the network settings effective: sudo /etc/init.d/networking restart, or you can directly enter the following command under the command line to obtain the address sudo dhclient eth0
2、 Configure a static IP address for the network card
Edit the file /etc/network/interfaces:sudo vi /etc/network/interfaces and replace the line about eth0 with the following line:
auto eth0
iface eth0 inet static
address 192.168.3.90
gateway 192.168.3.1
netmask 255.255.255.0
Just replace the above ip address and other information with yourself. 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, and add the following line to the file:
auto eth0:1
iface eth0:1 inet static
address 192.168.1.60
netmask 255.255.255.0
network x.x.x.x
broadcast x.x.x.x
gateway x.x.x.x
Fill in all information such as address, netmask, network, broadcast and gateways according to your situation.
Use the following command to make the network settings take effect: sudo /etc/init.d/networking restart
4、 Set the host name (hostname)
Use the following command to view the host name of the current host: sudo /bin/hostname, use the following command to set the host name of the current host: sudo /bin/hostname newname When the system starts, it will read from /etc/hostname The name of the host.
5、 Configure DNS
First of all, you can add some host names and the IP addresses corresponding to these host names in /etc/hosts. This is simply a static query using this machine. To access the DNS server for query, you need to set the /etc/resolv.conf file . Assuming that 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
The above describes the Ubuntu network configuration.
Recommended Posts