Set the IP address, gateway, and DNS in the command line in Linux

Source: Internet
Author: User
Set the IP address, gateway, and DNS in the command line in Linux
Run the command: ifconfig eth0 192.168.1.123 netmask 255.255.255.0
Run the following command to configure the Gateway: Route add default GW 192.168.1.3
You can write these two commands to/etc/rc. Local or/etc/rc. d/rc. Local to save them permanently.

/Etc/sysconfig/Network: Set the default gateway, host name, and whether to start the network;
/Etc/sysconfig/network-script/ifcfg-ethn, N indicates the ID of the NIC. You can set the parameters of the NIC in this area,
For example, IP address, netmask, network, broadcast, gateway, and the Protocol (DHCP, static) for obtaining IP addresses at startup are static,
Whether to start at startup or not,
/Etc/resolv. conf configure the DNS server
/Etc/hosts maps the machine name in the LAN with the IP address to access other machines through the machine name (only through
If the machine name cannot be used to check the IP address)

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.