Basic network configuration for Linux systems

Source: Internet
Author: User
Tags range reserved domain name server traceroute test linux

First, Linux basic network configuration

1. Use the ifconfig command to view network interface information

ETH: The name of the first network card

Lo:loopback abbreviation, "Loopback" network interface

To view basic network adapter configuration information:

1.) Hwaddr: Physical MAC address of the network interface

2.) Inet Addr:ip Address

3.) Bcast: Broadcast address

4.) Mask: Mask for network interface

Use Ifconfig to view network interface information

Use ifconfig eth0 to view specified network interface information

Use Ifconfig–a to view all network interface information

2. Use the ping command to test your network connection

1.) Use ping to test network connections

2.) Use the-C option to specify the number of packets sent

3.) Use the-S option to set packet size

4. Use the ping command to test tips

1. You can test the local network interface address, if successful, the current host network interface is valid

2. Test the IP address of other hosts in the local area network, such as the default gateway, if the test is successful, then the gateway connection is normal, otherwise you need to check the switch, the network cable connection is correct.

3. When the test to the gateway is normal, but can not ping the target host, may be the target host can not connect, it may be the gateway server did not correctly forward the packet.

4. If the network is normal, it may be a firewall impact

3. View and Test routing records

1.) Use route to view routing table information

2.) Use Route–n to display the information in a routing record as a number (default = 0.0.0.0)

3. What network nodes are passed between the host and the target host using the Traceroute test

4. View and test host name

1.) Use the hostname command to view the host name of the current host

2.) Use nslookup domain name or IP address {DNS server address}

5. View network connection status using the netstat command

–A Displays all active network connection information

–n in digital form

–R Display routing table information

–L Displays network interfaces and port information in the listening (listening) state

–t View TCP protocol related information.

–u Display UDP protocol related information

–P Displays the process number associated with the network connection, process information. (Requires root permission)

6. View ARP Address resolution Records

Use Arp–n to display the ARP information for the current Linux host in digital form.

7. Adjust network parameters using commands

1. Implementation of network Configuration command changes: Temporary changes, computer restart or service reload after the failure

2.) Modify configuration file: Permanent modification

8. Use Network configuration commands to modify network information.

1.) Set network card IP address (temporary): Ifconfig network Interface name IP address [netmask subnet mask]

Or: Ifconfig network interface name IP address [/Mask length]

2.) Prohibit network interface ifconfig eth0 down

Activate network interface ifconfig eth0 up

3.) Set up the virtual network interface (e.g. add a virtual NIC on the eth0 eth0:0)

Ifconfig eth0:0 172.17.17.17

4.) Modify the MAC address used by the NIC ifconfig eth0 hw ether 11:22:33:44:55:66

9. Set up Routing Records

1.) Add routing information using route add

-NET Specifies a target network (or-host specifies the target host) GW determines the next hop address.

2.) Delete the routed record for the specified network segment route del–net 192.168.3.0/24

3.) Delete Add default gateway routing records

Route del default GW 192.168.1.1

Route add default GW 192.168.1.1

10. Modify host name hostname + new name

11. Set static ARP record

Bind a network to a MAC address

Arp–s 192.168.1.1 11:22:33:44:55:66

Modification of network parameters via configuration file (permanent)

1. Modify network Interface Configuration

1.) Network Interface Configuration content

DEVICE Set Network interface name

Onboot set whether the system is active at startup

Bootproto set configuration to "static" Static IP for "DHCP" dynamic acquisition

IPADDR set the IP address of the network interface

NETMASK set the subnet mask for the network interface

Gateway sets the default gateway for network interfaces

2.) Stop or enable the specified network interface

Ifdown eth0

Ifup eth0

Restarting service service name restart (stop)

2. Host name configuration file

Vi/etc/sysconfig/network

Modify Hostname= Host Name

3. Local Host name resolution file

Vi/etc/hosts

4. Domain Name server configuration file

Vi/etc/resolv.conf

Add Search Domain

NameServer DNS server address (three can be set)

Iii. using DHCP to dynamically configure a host

1. Configure DHCP Server Software

Mount the CD and install the DHCP package

1.) Main configuration file dhcpd.conf

Basic types of configuration items

Statement: Describes the division of the DHCPD server to the network, is the logical scope of network settings

Parameters: Configured words and corresponding values (typically the default lease time)

Options: Specifies the configuration parameters assigned to the client

Global configuration in the dhcpd.conf file

Ddns-update-style, Dynamic DNS update mode

Default-lease-time, default lease time

Max-lease-time, Maximum lease time

Option Domain-name, default search area

Option Domain-name-server,dns Server address

To set a subnet property using the subnet declaration

Specifies the network address of the subnet using the subnet keyword, netmask keyword specifies the subnet mask

This article URL address: http://www.bianceng.cn/OS/Linux/201410/45506.htm

Use the range parameter to specify the range of dynamically assigned IP addresses, multiple

Specifies the subnet mask address assigned to the client using the option Subnet-mask options

Specify the default gateway address assigned to the client using the option routers options

Setting host properties using the host declaration

Use the Host keyword to specify the name of a DHCP client that needs to be assigned a reserved address

To specify a matching host MAC address using the hardware Ethernet parameter

Use the fixed-address parameter to specify a reserved address

Other settings in the dhcpd.conf file

2.) Command parameter configuration file/ETC/SYSCONFIG/DHCPD

Modify/ETC/SYSCONFIG/DHCPD

3. Start and stop DHCPD service

Verify that the DHCP server's network interface has a statically specified fixed IP address prior to startup and that the negative fails to start

Start Service DHCPD start

Restart Service DHCPD Stop

Stop Service DHCPD restart

2. Using DHCP clients

1.) Modify the corresponding network card configuration file

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

Modify Bootproto=dhcp

2.) and restart Network

3.) Use Dhclient to get address for this machine

3. Configure DHCP Relay

1.) Turn on the Routing and forwarding function of the server

Edit/etc/sysctl.conf File

Modify Net.ipv4.ip_forward = 1

Perform sysctl-p view

2.) Set the interface to allow DHCP relay data and the IP address of the DHCP server

Edit/etc/sysconfig/dhcrelay

Set interfaces= "eth0 eth1"

Dhcpservers= "192.168.1.1"

3.) Start Dhcrelay Relay Service Program

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.