Linux Network Management

Source: Internet
Author: User

Configuration of the Linux network environment

In the Linux server system we are all using a text terminal to operate, so the connection network is not as simple as the Windows platform. We need to modify the relevant file configuration to enable the server to connect to the network, now to describe the network configuration methods.

1. Dynamic Method (DHNP)

DHCP services can be supported in any operating system, so what does the DHCP service do? It can actually help you to dynamically obtain the IP address and other information, very convenient.

So how do we use DHCP services?

First of all, our system has to have DHCP software (not installed can go to yum download installation), if not, then do not have to play, go directly to manually set it.

How to set it? Linux network card configuration file is stored in the/etc/sysconfig/network-scripts, for the first Ethernet device, the configuration file name is generally Ifcfg-eth0

So open this file with the command Vi/etc/sysconfig/network-scripts/ifcfg-eth0 and you can see

Device=eth0 #物理设备名

Onboot=yes # [Yes|no] (whether the device is activated at boot time)

Bootproto=static #[none|static|bootp|dhcp](no protocol at boot | static Assignment | BOOTP protocol | DHCP protocol)

See the fields marked Red No, as long as we choose DHCP then we can dynamically obtain IP. Other options can be set as above.

Save the modified file to exit, with the command service network Restart Restart the service can be connected to the network.

2. Static fetch (Static)

Open this file with the command Vi/etc/sysconfig/network-scripts/ifcfg-eth0

Device=eth0 #物理设备名

Onboot=yes # [Yes|no] (whether the device is activated at boot time)

Bootproto=static #[none|static|bootp|dhcp]( no protocol at boot | static Assignment | BOOTP protocol | DHCP protocol)

ipaddr=192.168.1.10 #IP地址

netmask=255.255.255.0 #掩码值

gateway=192.168.1.1 #网关地址

dns1=202.202.10.20

Select static and set the IP, subnet mask, gateway, and so on, which can also set up DNS and so on. The Ipaddr,netmask,gateway is only useful when statically static (when DHCP is selected, none of the subsequent functions).

Save the modified file to exit, with the command service network Restart Restart the service can be connected to the network.

3. Using the Setup command

What is the Setup command? In some Linux distribution, the setup software can be used for network configuration, it is a graphical interface, so the interaction is very friendly. But the principle of configuration and the same as above, one is automatic DHCP acquisition, one is manually set

4. The following are some of the relevant network Setup commands and configuration files:

Ifconfig: View network configuration information (equivalent to ipconfig under win), use ifconfig eth0 192.168.0.1 netmask 255.255.255.0 can also temporarily configure IP

/etc/sysconfig/network: Gateway configuration file

  Configuration file for/etc/resolv.conf:dns

Ifdown: Turn off the network card, for example: Ifdown eth0
Ifup: Turn on the network card, for example: Ifup eth0
Service iptables start: Start firewall

Service iptables STOP: Turn off the firewall

Linux Network Management

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.