Linux System Network Setup issues summary

Source: Internet
Author: User
Tags domain name server nameserver nslookup command

1. How to determine the corresponding IP and port ports when multiple NICs are in the network?

can see up (the UP network card is enabled, down is the network card is not enabled), RUNNING is to indicate that the network cable is inserted, the following 4, 5 lines are sent and received packets 7,8 is the statistics of the package and receive packets

Method 2 "" Su root under the use of Ethtool tools, Ethtool--p eth0 10 is to indicate the test eth0 port, so that the port blinks 10 times, in order to determine the correct network port, the above method is best in the cable unplugged state test.

Method 3 "" Ethtool eth0 directly shows the connection status of the last line, yes indicates the connection

2. What is the usual way to set ip,gateway,dns?

Method 1:

The first is to configure the IP address of the NIC using the Ifconfig command. This command is typically used to test for zero, and after the computer starts

The configuration of the IP address is automatically invalidated. The specific usage is as follows. Ipconfig ethx ipadd netmask x.x.x.x.

where x in ETHX represents the Fast Ethernet card, the default first block is 0.ipadd for the IP address. x.x.x. X is the subnet mask. For example, the IP address configured for the NIC Eth0 is 192.168.1.1 Subnet Mask is 255.255.255.0

Method 2:

Neat command to configure IP address under =redhat-config-network graphics

Restart Network Service after configuration is complete

Method 3:

(3) Netconfig command

After entering Netconfig, it will appear as shown, click the Yes button.

Note (This method configures the IP address after the computer is still active from the new boot)

Method 4:

(4) Vi/etc/sysconfig/network-scripts/ifcfg-ethx

Restart the service after the configuration is complete. The P address is configured. In fact, the previous 3 configuration method eventually changed the configuration file under/etc/sysconfig/network-scripts/ifcfg-ethx.

Method 5: Set the DNS method

:---Modify IP address---Immediate effect: # ifconfig eth0 192.168.1.155 netmask 255.255.255.0

Restart Effective: Modify/etc/sysconfig/network-scripts/ifcfg-eth0

---Modify the default gateway---Immediate effect: # route add default GW 192.168.1.1

Restart Effective: Modify/etc/sysconfig/network-scripts/ifcfg-eth0

---Modify DNS---Modify/etc/resolv.conf to take effect immediately after modification, restart is also valid

---Modify host name---immediate effect: # hostname Test1 Restart effective: Modify/etc/sysconfig/network

1. Add the DNS server address by editing the Ifcfg-eth0 configuration file under the Vi/etc/sysconfig/network-scripts NIC

Added: dns1= "XXX.XXX.XXX"

2. Graphical interface DNS settings

Terminal Input Setup command to bring up graphical interface settings (configuration information write, etc/resolv.conf file)

3.host Host Table File

Prioritize DNS server addresses by setting host table addresses for specific host resolution. configuration files, in/etc/hosts

Summary: The location of the DNS settings under Linux is mainly, 1 network card settings file inside the DNS server address settings, 2. The system default DNS server address setting 3.host file specifies that the order of validity is: 1 host file---2 network adapter profile DNS service address---3/etc/ resolv.conf

First, modify the IP address

[Email protected] network-scripts]$ VI ifcfg-eth0

Device=eth0

Onboot=yes

Bootproto=static

ipaddr=219.136.241.211

netmask=255.255.255.128

gateway=219.136.241.254

Second, modify the gateway

Vi/etc/sysconfig/network

Networking=yes

Hostname=aaron

gateway=192.168.1.1

Third, modify the DNS

[Email protected] etc]$ VI resolv.conf

NameServer 202.96.128.68

NameServer 219.136.241.206

Iv. Restarting the network configuration

/etc/init.d/network restart

Modify IP Address

Immediate effect:

# ifconfig eth0 192.168.0.20 netmask 255.255.255.0

Activation takes effect:

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

Modify the default gateway

Immediate effect:

# route add default GW 192.168.0.254

Activation takes effect:

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

Modify DNS

Modify/etc/resolv.conf

Modified to take effect immediately, start the same effective

Modify Host Name

Immediate effect:

# hostname FC2

Activation takes effect:

One. Linux Basic Network Configuration command 1.ifconfig View information about the network interface. Full path for normal users to use Ifconfig:/sbin/ifconfig

Ifconfig Network Interface Name: Displays detailed information for the specified interface.

Ifconfig-a View information for all network interfaces.

2. route Display routing Table

Route | grep defaults Displays the default gateway for the host.

3.ping-c 4 192.168.1.10 sends a specified number of packets for network connectivity testing.

4.traceroute 192.168.1.10 Test the network connection path to the other hosts.

5.hostname Displays the current host name.

Second, use the command network settings

1.dhclient Request a new network setting from the DHCP server.

2.ifconfig network interface IP address netmask Subnet mask: Configure the IP address, the network interface properties set by the Ifconfig command are only valid on the current system, and the network interface properties will be reconfigured after the system restarts with the contents of the network interface configuration file.

3.route del default GW defaults gateway address: Deletes the default gateway route record.

Route add default GW default gateway address: Add the Defaults gateway.

4.hostname Linserver: The host name is set to take effect immediately, and the original hostname will be restored after reboot.

5. Use the server command in the interactive mode of the nslookup command to display the DNS server addresses used in the Linux system.

6.netconfig: Character interface for network configuration.

Service Network Restart: Restart the Network service.

Ifdown Network Interface

Ifup Network interface: Restart the network interface

7. Modify the MAC address:

Ifconfig eth0 down: Disable NIC First

ifconfig eth0 hw ether 1234567890ab

Keep it that way forever:

Add these three sentences in/etc/rc.d/rc.local (you can also add the following three lines in/etc/init.d/network)

Ifconfig eth0 ifconfig eth0 hw ether 1234567890ab ifconfig eht0 up

Third, modify the configuration file for network configuration

1. Network interface configuration file:/etc/sysconfig/network-scripts/ifcfg-eth0

/etc/sysconfig/network-scripts/ifcfg-lo

The contents of the static IP address set in the "Ifcfg-eth0" configuration file are as follows:

Device=eth0 Setting the network interface name

Onboot=yes set the network interface to be activated at system startup.

Bootproto=static configured as static address

ipaddr=192.168.1.10

netmask=255.255.255.0

gateway=192.168.1.1 default gateway for network interfaces

To obtain network configuration content using DHCP:

Device=eth0

Onboot=yes

Bootproto=dhcp

2. hostname configuration file/etc/sysconfig/network

Networking=yes

Hostname=linserver Linserver is the host name to set.

3. Local Host name resolution file/etc/hosts

4. Domain Name server configuration file/etc/resolv.conf

Search lingdian.com Set the default lookup domain name for the host

NameServer 192.168.152.2 Set the IP address of the DNS server, the file can have up to 3 "nameserver" Configuration records, one row per record, the system will first use the top "nameserver" configuration record

Basic network configuration commands for Linux

1. View Ip:ifconfig

2, the method of configuring IP:

A, this method takes effect immediately, but restarts will not be saved. (All other methods except this one can be saved)

Ifconfig eth0 1.1.1.1 netmask 255.0.0.0 up

Ifconfig eth01 1.1.1.3 up a way to set up a network card with multiple IPs (useful when setting up a virtual host)

Activating the NIC: Ifconfig eth0 up

Close network card: Ifconfig eth0 down

Dynamic acquisition of Ip:ifconfig Etho–dynamic

Dhclient

Modify Mac Value: First turn off the network card: Ifconfig eth0 down

To modify the Mac value: Ifconfig eth0 hw ether 112233445566

Re-activate the NIC: Ifconfig eth0 up

B, Netconfig or setup, but can only set Eth0 NIC

C, Neat: Open the graphics window to set

D, configuration File settings:

VI Etcsysconfignetwork-scriptsifcfg-eth0

Note: When you restart the NIC service network restart fails, use the fourth method to check if the bootup in the configuration file is None, and if DHCP is the usual error.

3. Configure the Gateway:

View Gateway: Route

To add a default route:

Route add–net 0.0.0.0 netmask 0.0.0.0 GW 192.168.0.1

To delete the default route:

Route del–net 0.0.0.0 netmask 0.0.0.0 GW 192.168.0.1

4. Configure DNS:

echo nameserver 192.168.0.1etcresolv.conf

Linux Routing configuration:

1. First turn on the routing function

Echo 1 Procsysnetipv4ip_forward (1 for open routing, 0 for off-routing feature)

(In this experiment just turn on the routing function OK)

2. Other Routing settings:

A. Add Routing information:

Route add–net 10.0.0.1 netmask 255.0.0.0 GW 192.168.0.1

or route add–net 10.0.0.1 netmask 255.0.0.0 Dev eth0 (out of the first network card on this computer)

To delete a route entry: Just change the above add to Del.

B. Configure routing with Zebra (configuration is the same as Cisco's command):

1) Set the login password:

Vi etczebrazebra.conf

Password ABC #设置连接时的密码

Enable Password 123 # set privileged passwords

2) Open Service

Service Zebra Start

3) Establish the routing protocol file to be configured

As with RIP protocol: Touch etczebraripd.conf

4) Open RIP Protocol: Service RIPD start

5) into Zebra:

Method One, Telnet 127.0.0.1 2601 # # Remember the port is 2601

If no password is set, the connection is not allowed by default and is suitable for remote login

Method Two, Vtysh # # No password can also be entered, if there is a password will also be displayed, but only for local login.

6) Configure routing: Just like in the Cisco router, it's a little bit.

7) Quit Quit (remember to save it before exiting)

33. FAQ for frequently encountered problems?

>> IFCONFIG not show other network cards, workaround "Delete current network card settings, rebuild Settings" IFCONFIG display status

Linux System Network Setup issues summary

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.