Modify host name and IP settings in Linux

Source: Internet
Author: User

After a long time learning about the Linux system, you may encounter a Linux system problem. Here we will introduce how to solve the Linux system problem and configure the network.

1. Modify the host name/etc/sysconfig/network (file)

 
 
  1. NETWORKING=Yes 
  2. NETWORKING_IPV6=No 
  3. NETWORKING_IPV4=Yes 
  4. HOSTNAME=Localhost. Localdomain/* Host Name definition, change localhost to your corresponding host name, such as bea */
  5. DOMAINNAME=Localdomain 
  6. GATEWAY=192. 168.0.1

In Linux, the/etc/hosts file defines the relationship between the ip address and the host name.) 127.0.0.1 localhost. localdomain localhost/* Change localhost to your host name. For Linux systems such as bea */host name, the file is changed to 127.0.0.1 bea after restart. localdomain bea

2. IP settings

Run the following command to temporarily modify the Linux system: ifconfig eth0 x. x. x. x netmask x. x. x. x does not change if the service is not restarted after the ip address is changed.

The command to restart the network service is:

 
 
  1. Service network restart or/etc/init. d/network restart
  2. # Sometimes you may need to use the following command
  3. # Disabling network devices
  4. Ifconfig eth0 down
  5. # Enable network devices
  6. Ifconfig eth0 up

If you want to change the ip address permanently in Linux, you can solve the problem in either of the following two ways. <A> enter a command to configure the ip address. The command is setup <B> or edit the file directly.

 
 
  1. /Etc/sysconfig/network-scripts/ifcfg-ethX Redhat and Fedora)
  2. /Etc/sysconfig/network/ifcfg-ethX SuSE)
  3. /Etc/network/interfaces Debian and Ubuntu)

The content of the Linux system file is as follows:

 
 
  1. A. static IP Address:
  2. DEVICE=Eth0 
  3. BOOTPROTO=Static 
  4. ONBOOT=Yes 
  5. TYPE=Ethernet 
  6. NETMASK=255. 255.255.0
  7. IPADDR=192. 168.0.1
  8. GATEWAY=192. 168.0.1
  9. BROADCAST=192. 168.0.255
  10.  
 
 
  1. b.DHCP:  
  2. DEVICE=eth0 
  3. BOOTPROTO=dhcp 
  4. ONBOOT=yes 
  1. Linux has successfully fixed many bugs.
  2. Linux system management has won various honors
  3. Ubuntu Linux systems can be used without any knowledge
  4. More stable and secure Linux systems
  5. High-performance servers and monitoring required for Linux System Administrators

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.