First, use the command to set the Ubuntu IP address
1. Modify the configuration file blacklist.conf disable IPV6
sudo vi/etc/modprobe.d/blacklist.conf
Indicates that the contents of the blacklist.conf document in the MODPROBE.D folder under the ETC folder can be edited using the VI editor (or other editors, such as Gedit).
Note: can only be modified in root user mode
Add blacklist IPv6 at the end of the document
Then view the results of the changes
Cat/etc/modprobe.d/blacklist.conf
2. Set the IP address and subnet mask of the NIC Eth0
sudo ifconfig eth0 192.168.2.1 netmask 255.255.255.0
Change IP address to: 192.168.2.1, subnet mask to: 255.255.255.0
3.Ubuntu IP Settings Gateway
sudo route add default GW 192.168.2.254
4.Ubuntu IP Settings DNS modified/etc/resolv.conf, where the nameserver DNS address 1 and nameserver DNS address 2 are added.
5. Restart the Network service (if not, please restart Ubuntu:sudo reboot)
sudo/etc/init.d/networking restart
6. View current IP
Ifconfig
Second, directly modify the Ubuntu IP system configuration file
The network configuration file for Ubuntu IP is the root directory:/etc/network/interfaces
Note : After modifying the contents of the interfaces document, you need to modify the managed parameter in the/etc/networkmanager/networkmanager.conf document so that it is true and restarts. Otherwise, you will be prompted to say " wired network devices are not hosted ."
After opening, you can set up DHCP or manually set the static IP.
The front auto eth0 indicates that the network card is automatically mounted eth0.
1. Configuring the NIC in DHCP mode
Edit File/etc/network/interfaces
sudo vi/etc/network/interfaces
Replace the line with the following line for eth0:
#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
You can also enter the following command directly below the command line to get the address sudo dhclient eth0
2. Configure a static Ubuntu IP address for the NIC
Edit File/etc/network/interfaces
sudo vi/etc/network/interfaces
Replace the line with the following line for eth0:
# The primary network interface auto eth0 iface eth0 inet static address 192.168.2.1 Gateway 192.168.2.254 netmask 25 5.255.255.0 #network 192.168.2.0 #broadcast 192.168.2.255
After modifying the IP assignment mode of eth0 to static assignment (static), the IP, gateway, subnet mask and so on are established.
Replace the above-mentioned Ubuntu IP address with your own on-the-go information.
Use the following command to make the network settings effective:
sudo/etc/init.d/networking restart
3. Set a second Ubuntu IP address (virtual IP address)
Edit File/etc/network/interfaces:sudo vi/etc/network/interfaces
Add the following line to the file:
Auto eth0:1 iface eth0:1 inet static address x.x.x.x netmask x.x.x.x 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 effective
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 reads the name of the host from/bin/hostname.
5. Configure DNS
First, you can add some host names and IP addresses for these host names in/etc/hosts, which is a static query that uses native computers simply. To access the DNS server for querying, you need to set the/etc/resolv.conf file, assuming that the IP address of the DNS server is 192.168.2.2, then the contents of the/etc/resolv.conf file should be:
Search chotim.com
NameServer 192.168.2.2
6. Restart the Network service manually: sudo/etc/init.d/networking restart
The returned results are as follows:
*reconfiguring Network Interfaces ... [OK]
Ubuntu ways to modify IP addresses and gateways