Set IPv4 in Ubuntu

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.