First, use the command to set the IP address of Ubuntu
1. Modify the configuration file blacklist.conf disable IPV6:
sudo vi/etc/modprobe.d/blacklist.conf
2. Add blacklist IPv6 at the end of the document and review the results:
Cat/etc/modprobe.d/blacklist.conf
3. Set IP (set IP address and subnet mask for NIC Eth0)
sudo ifconfig eth0 192.168.2.1 netmask 255.255.255.0
4. Setting up the Gateway
sudo route add default GW 192.168.2.254
5. Set the DNS modification/etc/resolv.conf, where nameserver DNS is added to address 1 and nameserver DNS address 2 is complete.
6. Restart the Network service (if not, please restart Ubuntu:sudo reboot):
sudo/etc/init.d/networking restart
7. View current IP:
Ifconfig
Second, directly modify the system configuration file
The Ubuntu network configuration file is:/etc/network/interfaces
After opening, you can set up DHCP or manually set the static IP. Front auto eth0, let the network card boot automatically mount.
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 get the address by typing the following command directly below the command line
sudo dhclient eth0
2. Configure a static IP address for the network card
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 255.255.255.0
#network 192.168.2.0
#broadcast 192.168.2.255
Replace the above IP address with your own. Use the following command to make the network settings effective:
sudo/etc/init.d/networking restart
3. Set a second 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
5. Configure DNS
First, you can/etc/ Hosts include some host names and the corresponding IP addresses for these host names, which is a static query that uses native computers simply.
6. Restart the Network service manually:
sudo /etc/init.d/networking Restart
Linux Command (9) Set fixed IP