Linux network settings (version 2) and linux Version 2

Source: Internet
Author: User
Tags name database nameserver

Linux network settings (version 2) and linux Version 2
Linux network settings-network configuration file and command network configuration file

1./etc/sysconfig/network-scripts/ifcfg-eth0 # [Save the IP address and gateway]

[Set static IP addresses]

IPADDR = new IP address # This option sets the IP address. If BOOTPROTO = dhcp is set and the IP address is automatically obtained, this option is not available. Otherwise, it is BOOTPROTO = no.

GATEWAY = GATEWAY # specify a GATEWAY

BROADCAST = BROADCAST address

NETMASK = Subnet Mask

 

2./etc/sysconfig/network # Save the local host name

HOSTNAME = host name # specify the host name. If dhcp is specified for automatic allocation, this option is not available because the host names are all localhost.

 

3./etc/rc. d/init. d/network start/stop/restart network Startup Script

Or service network restart

If a static IP address is set, restart the system, or reload the following STARTUP script. The setting takes effect. However, the latter is recommended!

 

4./etc/hosts # saves the domain name database

 

5./etc/services # stores network service information, such as ports and transmission protocols.

 

6./etc/resolv. conf # specify the DNS server address

Nameserver [DNS Server IP address] # Add a DNS server. You can specify multiple DNS server addresses with spaces. Up to three DNS server addresses can be used.

 

Appendix-the service program may not use a fixed port, but the WebServer exposed to the outside will not change the port, but it is recommended to change the port like SSH to avoid Scanning

Nmap [IP address] # scan the host to enable those services, but it only scans the ingress port or the port of the well-known service by default.

Network management commands

1. ifconfig # view network port settings

Ifconfig eth0 up/down # enable/disable the NIC

 

2. ethtool [Nic name] # detect Nic line connection

Ethtool eth0

Ethtool wlan0

The ethtool command is very important when multiple NICs exist on a server!

 

3. arp # view ARP table information, as shown in the preceding figure.


4. ping # detect remote hosts

Ping-c 10-s 1000 IP address #-c specifies the number of ping requests, and-s specifies the size of sent packets. Pay attention to the packet loss rate during ping.

 

5. route # operate the route table

Route add default gw 192.168.14.100 # add a gateway without modifying the configuration file

[But it is better to modify the configuration file]

Zerba routing software]

 

6. traceroute # view the route path

Traceroute www.163.com # it lists all the routers and latencies that pass through the host.

 

7. netstat # monitor the network status

Netstat-an # view all connections

Netstat-an | grep: 80 # Check whether the Apache service is started


How do I configure the network in Linux?

1. install and configure network devices

When installing linux, if you have a nic, the installer will prompt you to provide TCP/IP network configuration parameters, such as the local ip address, the default gateway ip address, and the DNS ip address. based on these configuration parameters, the installer automatically compiles the NIC (which must be supported first in linux) driver into the kernel. but we must understand the process of loading the NIC driver, so we will be very easy to operate when we change the NIC later and use multiple NICs. nic drivers are loaded into the kernel as modules. All Nic drivers supported by linux are stored in the directory/lib/modules/(linux Version)/net /, for example, the driver of the inter 82559 series 10/100 M Adaptive boot Nic is eepro100.o, and the driver of 3C509 ISA Nic of 3COM is 3C509. o, DLINK pci 10 NIC Driver is via-rhine.o, NE2000 compatible NIC Driver is ne2k-pci.o and ne. o. after learning about these basic drivers, we can modify the module configuration file to replace or add a nic.

1. Modify the/etc/conf. modules File

This configuration file is an important parameter file for Loading modules. Let's take a look at an example file.

#/Etc/conf. modules

Alias eth0 eepro100

Alias eth1 eepro100

This file is a conf file in a linux system with two inter 82559 series NICs. contents in modules. the alias command indicates the name of the driver of the Ethernet port (such as eth0). The alias eth0 eepro100 indicates that the driver to be loaded on the Ethernet port 0 is eepro100.o. when modprobe eth0 is used, the system automatically loads eepro100.o to the kernel. for pci NICs, because the system will automatically find the NIC's io address and interrupt number, there is no need. in modules, use options to specify the NIC's io address and interrupt number. but corresponding to the ISA Nic, it must be in conf. the io address or interrupt number specified in the module, as shown below, indicates the conf of an ISA Nic of NE. modules file.

Alias eth0 ne

Options ne io = 0x300 irq = 5

After modifying the conf. modules file, run the following command to load the module:

# Insmod/lib/modules/2.2.14/net/eepro100.o

In this way, you can load the module eepro100.o at the Ethernet port. You can also run the following command to view the information of the currently loaded module:

[Root @ ice/etc] # lsmod

Module Size Used

Eepro100 15652 2 (autoclean)

The returned result indicates that the currently loaded module is eepro100, with a size of 15652 bytes and two users. The returned result is cleared automatically.

2. Modify the/etc/lilo. conf file.

In some newer linux versions, because the operating system automatically detects all related hardware, you do not have to modify/etc/lilo. conf file. however, for the ISA Nic and old version, you can modify lilo to initialize the newly added Nic In system initialization. conf file. in/etc/lilo. in the conf file, add ...... remaining full text>

Linux network settings

First, set the virtual machine to bridge, and then configure the ip address

Ping the gateway 192.168.100.100 using a virtual machine.

Generally, a vro provides a dial-up function. If your real machine does not make a dial-up every time on the Internet, it is an automatic Dial-Up On The vro. Otherwise, you do not need to dial-up.

Linux ping 192.168.100.100 indicates that the IP address and gateway are correct.

Otherwise, the IP address or gateway settings are incorrect.

To solve the IP address and gateway problems, enter setup to enter the network. In general, only one network card is the one under eth0.

But remember, there is a use dhcp option in it, which indicates that you cannot manually set IP addresses when DHCP is enabled.
If you do not want to change it, you need to set up a DHCP server or enable the DHCP function of the route. to manually set it, you need to cancel this

After modifying the ip address, restart the NIC and enter ifdown eth0.
Ifup eth0

However, if the ping www.baidu.com fails, it indicates that no DNS or DNS is set incorrectly.

Vi/etc/resolv. conf

Input I

Enter

Nameserver's own city dns
Nameserver's own city dns

Example: I am in Chengdu

Nameserver 202.98.96.68
Nameserver 61.139.2.69

Enter the following information when exiting, and then press x to save it.

Ask again if you do not understand

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.