How does FedoraLinux set the network card to automatically obtain the network address?

Source: Internet
Author: User
Step 1: Activate the FedoraLinux system. After the system is installed, the default Nic is eth0. Use the following command to activate the NIC. # Ifconfigeth0up Step 2: Set the network adapter to start when entering the system. If you want to automatically obtain the IP address to access the Internet each time you start the system, you must set the network service to start when the system starts. Linux is different from windows in that many services are stopped by default, while

Step 1: Activate the NIC

After the ora Linux system is installed, the default Nic is eth0. Use the following command to activate this Nic.
# Ifconfig eth0 up

Step 2: Set enable when the NIC enters the system
If you want to automatically obtain the IP address to access the Internet each time you start the system, you must set the network service to start when the system starts. Linux is different from windows in that many services are stopped by default, and you start the service when you use the service, but it is not set to start by default, the next time you enter the system, the service is still stopped. The following describes how to set the network service to start when the system starts.

Use the chkconfig command to enable the network service to be started by default when the system startup level is 2345.

# Chkconfig -- level 2345 network on

Step 3: Modify the ifcfg-eth0 of the NIC File
Modify the ifcfg-eth0 file and set the ONBOOT value to yes so that the network adapter is used when the network service starts. Set the value of BOOTPROTO to dhcp so that the NIC can automatically obtain the IP address from the DHCP server.

# Vi/etc/sysconfig/network-scripts/ifcfg-eth0

ONBOOT = yes
BOOTPROTO = dhcp

Summary:
Generally, the third step is the most important, because most of the default network services in Linux are also started when the system starts, and the NIC is also enabled, as long as you set the third step, run the following command to start the network service.

# Service network start

Configure static IP addresses and dynamic IP addresses, modify the ifcfg-eth0, and then restart the network service with the Command service network retart.

DEVICE = eth0
IPADDR = 192.168.1.100
NETMASK = 255.255.255.0
GATEWAY = 192.168.1.1
DNS = 8.8.8.8
BOOTPROTO = static
ONBOOT = yes

After completing the preceding three steps, you can obtain the ip address. But later, it appeared that the ip address could not be obtained, and repeated ip addresses would not work.

Use

# Dhclient eth0

Note:

Linux Force DHCP client (dhclient) to renew ip address

Linux renew ip command
$ Sudo dhclient-r // release ip release IP
$ Sudo dhclient // obtain the IP address

Now obtain fresh IP:
$ Sudo dhclient
There is no need to restart network service. above command shoshould work with any Linux distro such as RHEL, Fedora, CentOS, Ubuntu and others. on a related note you can also try out the following commands:
# Ifdown eth0
# Ifup eth0
#/Etc/init. d/network restart
OR
#/Etc/init. d/networking restart

Related Article

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.