Network configuration under Ubuntu

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:

The primary network interface - use DHCP to find our address

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:

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

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

Network configuration under Ubuntu
Ubuntu 18.04 network card configuration
ubuntu 18.04 early configuration
CentOS7.0 network configuration
CentOS 7.0 network configuration
Ubuntu nfs configuration
Ubuntu20.04 configuration notes
Ubuntu 14.04 configuration record
JDK environment variable configuration method under ubuntu
Ubuntu 18.04 LTS configuration network tutorial through Netplan
DLNA/UPnP Server installation and configuration under Ubuntu 12.04
Install apache+PHP under Ubuntu
Install node.js under Ubuntu
Install python3.6 under Ubuntu 16.04
ubuntu configuration python, Red
Install mysql under Ubuntu 16.04
Install Thrift under ubuntu 14.10
Install OpenJDK10 under Ubuntu
Install Caffe under Ubuntu 14.04
Python MySQLd under Ubuntu
Ubuntu configuration development environment
Start working under ubuntu
[python] python2 and python3 under ubuntu
Use iptables under ubuntu
Ubuntu development environment configuration
Ubuntu configure network commands
023. Ubuntu common personalized configuration
Install ROS under ROS Ubuntu 18.04[2]
Kaldi installation and configuration graphic tutorials under Ubuntu
Install MySQL under Ubuntu
Install Yarm-PM2 under Ubuntu
Ubuntu16.04 mirror complete installation and configuration tutorial under VMware
Detailed explanation of static DNS configuration under Ubuntu system
Django&MySQL environment deployment under Ubuntu 14.04
Deploy FTP server under ubuntu
Solve Unment dependencies under ubuntu
Open SSH service under Ubuntu
Ubuntu16.04 installation and simple configuration
Modify shortcut keys under Ubuntu 18.04
Use of mediawiki under ubuntu
Install server-side Shadowsocks under Ubuntu 16.04
Open SSH service under Ubuntu
Implementation of CentOS8.0 Network Configuration
DNS service construction under Ubuntu
CentOS8 network card configuration file
Ubuntu16.04 install SVN and configuration
Ubuntu PostgreSQL installation and configuration
Install rgl package under Ubuntu
Ubuntu 20.04 best configuration guide for engineers
Ubuntu 20.04 best configuration guide for engineers
Installation of deb package under Ubuntu
Deploy the mail system under Ubuntu 19.10
How to compile ijkplayer-android under ubuntu
Install 3 single-cell R packages under Ubuntu
Ubuntu16.04 configuration OpenCV3.4.2 and basic use
Detailed examples of Centos6 network configuration
Install and deploy Gerrit under Ubuntu
Install MySQL under Ubuntu 18.04 (graphic tutorial)
Install JDK1.8 original under Ubuntu Kylin
Redis installation under ubuntu and windows
Small tool: install screenshot tool under ubuntu