Basic Linux Network Configuration

Source: Internet
Author: User
Tags echo 7 nameserver traceroute command

Basic Linux Network Configuration

1. TCP/IP network configuration file

/Etc/sysconfig/network-scripts/ifcfg-eth0

/Etc/sysconfig/network

/Etc/host. conf

/Etc/hosts

/Etc/resolv. conf

/Etc/services

(1)/etc/sysconfig/network-scripts/ifcfg-eth0

Network Interface Startup Script

Content instance:

DEVICE = eth0

ONBOOT = yes

BOOTPROTO = static

IPADDR = 192.168.1.10

NETMASK = 255.255.255.0

GATEWAY = 192.168.1.1

NETWORK = 192.168.1.0

BROADCAST = 192.168.1.255

(2)/etc/sysconfig/network

Basic Network Information Configuration

Content instance:

NETWORKING = yes

HOSTNAME = linux.jnrp.cn

GATEWAY = 192.168.1.1

(3)/etc/hosts

The/etc/hosts file is the local host name resolution database of the system.

Content instance:

# Do not remove the following line, or various programs

# That require network functionality will fail.

127.0.0.1 localhost. localdomain localhost

192.168.1.2 CentOS5

(4)/etc/host. conf

The/etc/host. conf file is used to specify how to resolve the host name. Available options include:

Order: Set the available methods and sequence for host name resolution. Available methods include hosts (using the/etc/hosts file for resolution) and bind (using DNS Server Resolution), nis (using Network Information Service NIS resolution)

Multi: sets whether to return multiple IP addresses of the host from the/etc/hosts file. The value is on/off.

(5)/etc/resolv. conf

The/etc/resolv. conf file is the client configuration file of the DNS domain name service.

Content instance:

Nameserver 218.30.19.40

Nameserver61.134.1.4

Search jnrp.cn

Domain jnrp.cn

(6)/etc/services

Set the default TCP or UDP port used by the Network Service

File Content instance:

# Each linedescribes one service, and is of the form:

#

# Service-name port/protocol [aliases...] [# comment]

Tcpmux 1/tcp # TCP port servicemultiplexer

Tcpmux 1/udp # TCP port servicemultiplexer

Ipve 5/tcp # Remote Job Entry

Rje 5/udp # Remote Job Entry

Echo 7/tcp

Echo 7/udp

Discard 9/tcp sink null

Discard 9/udp sink null

Listen at 11/tcp users

Protocol at 11/udp users

2. Use the command line tool to configure the network

Basic network configuration command:

Ifconfig

Ifup

Ifdown

Hostname

(1) ifconfig command

The ifconfig command is used to view and Configure TCP/IP networks.

Command instance:

# Ifconfig eth0

Eth0 Link encap: Ethernet HWaddr 00: 0C: 29: FB: E4: 89

Inet addr: 192.168. 1.3 Bcast: 192.168. 1.255 Mask: 255.255.255.0

Inet6 addr: fe80: 20c: 29ff: fefb: e489/64 Scope: Link

Up broadcast running multicast mtu: 1500 Metric: 1

RX packets: 36 errors: 0 dropped: 0 overruns: 0 frame: 0

TX packets: 139 errors: 0 dropped: 0 overruns: 0 carrier: 0

Collisions: 0 FIG: 1000

RX bytes: 4321 (4.2 KiB) TXbytes: 13153 (12.8 KiB)

Interrupt: 10 Base address: 0x1400

# Ifconfig eth0 192.168.1.3 netmask 255.255.255.0

(2) route command

The route command is used to set the route information of the Linux system.

View route information:

Route-n

Add a static route entry

Route add-net netaddr netmask gw ipaddr dev

Set the Default Gateway

Route add default gw ipaddr

Delete A route entry

Route del-net netaddr netmask gw ipaddr dev

 

Ping Command to test network connection through ICMP protocol

The traceroute command can trace the path to a specific destination.

The netstat command is used to view various network-related status information, including the network connection status, interface statistics, and route table and port monitoring information.

(3) ping command

The basic usage of the ping command is:

Destination Address of the ping Option

Common options include:

-C: specify the number of ICMP messages sent by the ping command. If this parameter is not specified, the ICMP messages will be sent continuously until you press ctrl + c to stop the command.

-I: Specifies the interval between the ping command and each ICMP message. The default value is 1 second. For security reasons, only super users can set this value to less than 0.2 seconds.

-S: sets the size of each ICMP message. The default value is 64 bytes and the maximum value is 65507.

-T: Set ttl (Time to Live)

(4) traceroute command

(5) netstat command

Common netstat Commands include:

-A: displays all listening and non-listening sockets.

-I: displays statistics of interfaces.

-N: the IP address and port are displayed in numbers instead of names.

-P: displays the PID and program name of the process using the port.

-R: displays the kernel route table.

-S: displays statistics for each protocol

 


What are the basic configurations of Linux?

It is very easy to install ubuntu with a new CD. After the CD is started, it is easy to select the language and set the password. It is mainly divided into disks because linux and windows are two different systems, therefore, many new users may not understand what to write. When partitioning a disk, you must note that at least one/partition is usually separated, and no/partition cannot be installed, swap is required for stable system operation. It does not seem to be okay, but it is best to score points. After installation, wait. If you have a network connection, you can ensure that the system is the latest and the Language Pack will be automatically installed, but it is time-consuming. We recommend that you use wubi to install ubuntu for the first time. This is more practical. Otherwise, it is inconvenient to install it again. For more linux partition solutions, you can search for them online ......

Teach public exam questions basic network configuration in linux, and start the relevant IP Network Service (3), one of which must start

1. Edit the configuration file
Vi/etc/sysconfig/network-scripts/ifcfg-eth0, requires the following:
DEVICE = eth0
BOOTPROTO = static
HWADDR = 00: 00: 00: 00: 00: 00 (here is the mac address, which can be viewed using the ifconfig command)
ONBOOT = yes
IPADDR = 192.168.0.10
NETMASK = 255.255.255.0
GATEWAY = 192.168.0.1
Then Press ESC to log out of the wq disk.
Configure DNS
Vi/etc/resolv. conf. The following content is required:
Nameserver 192.168.0.100 (primary DNS)
Nameserver 192.168.0.200 (secondary DNS)
2. Start the network service
/Etc/rc. d/init. d/network start
3. ping 192.168.0.2

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.