Brief introduction to Linux network configuration

Source: Internet
Author: User
Tags nameserver

Linux is a server-built operating system, the main function of the server is to provide network-related services. Therefore, configuring Linux network properties and viewing network properties is an essential skill for Linux system administrators. The network functionality of Linux is provided by the TCP/IP protocol stack in the kernel. Configuring Linux Network properties mainly requires the configuration of Ip/netmask, Gateway, DNS, route, hostname-related information , after the correct configuration of this information, the Linux server can be connected to the Internet.

To configure Linux Network properties to be temporary and permanent (effective at next boot), let me explain how to configure Linux network-related properties.

To start or stop a network card device :

Ifconfig eth# {Up|down}

IP link set eth# {up|down}

Configuration Ip/netmask:

permanent : Edit the/etc/sysconfig/network-scripts/ifcfg-eth# profile directly, and the profile key information is as follows:

deivce=eth# Device Name

Bootproto={bootp|dhcp|static|none} How to configure the address

Onboot={yes|no} whether to activate this device at boot time

Ipaddr= IP Address

netmask= Subnet Mask

gateway= Gateway

dns1= Preferred DNS

dns2= Alternate DNS

Userctl={yes|no} whether to allow ordinary users to control this NIC device

temporary entry into force :

Ifconfig eth# 10.0.0.1/8 or ifconfig eth# 10.0.0.1 netmask 255.0.0.0

IP addr Add 10.0.0.1/8 dev eth# (a network card can use this method to configure multiple different network segments or the same network segment IP, and will not overwrite the original IP address)

IP addr Add 10.0.0.1/8 dev eth# label eth#:# (add alias to this network interface and configure IP address)

Delete Ip/netmask:

IP addr del 10.0.0.1 dev eth#

To Configure the Gateway :

permanent : Defines the gateway option in the/etc/sysconfig/network-scripts/ifcfg-eth# script file.

temporary entry into force :

Route add default GW 10.0.0.254

IP route add default via 10.0.0.254

Configure DNS:

Edit/etc/resolv.conf to define the following information:

NameServer 202.106.46.151

NameServer 202.106.0.20

To Configure routing :

permanent : Creates a new route-eth# configuration file in the/etc/sysconfig/network-scripts/directory with the following two formats:

First format

Network Address Gateway

192.168.1.0 via 10.0.0.254

Second format

Address#=destination

Netmask#=mask

Gateway#=gw

Note: When specifying a route or gateway, the gateway must be in the same network segment as one of the host network cards

temporary entry into force :

Route add {-net|-host} 192.168.1.0/24 GW 10.0.0.254

IP route add 192.168.1.0/24 via10.0.0.254

To View routing information :

IP Route Show

Route-rn

Netstat-rn

To delete a route :

Route Del-net 192.168.1.0/24

IP Route del 192.168.1.0/24

Configure host name :

Permanent: Edit the hostname in/etc/sysconfig/network-scripts/network, in the following format

Hostname=www.movekj.com

temporary entry into force :

Hostname www.movekj.com

View Host network related information :

Netstat: View network connection information.

-N: View with digital information, do not reverse the IP address and port number to host name

-RN: Viewing routing table information

-nt: View information about connection TCP connections established

-NTL: View TCP connection information in the listening state

-nta: View TCP connection information for all States

-P: View the relevant socket is registered by that process

-u: View UDP-related information

SS: View network connection information.

-T: View TCP-related information
-u: View UDP-related information
-P: View the process name and process number of the socket

-L: View connection information in listening state
-N: Digitally view, do not reverse IP address and port number to host name

                      -A: View TCP connection information for all States           

-E: Extended information
-M: socket-related memory usage information
-O State {established,fin_wait_1, fin_wait_2, listening}
' (Dport = or sport =) '
Displays only connections of the specified state, and can also specify filter criteria

This article is from "Chalet Technology" blog, please make sure to keep this source http://starli.blog.51cto.com/8813574/1662150

Brief introduction to Linux network configuration

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.