1. Network Interfaces and configuration tools;
Network interfaces are the representation of network hardware devices in the operating system. For example, if the network adapter uses ethx in the Linux operating system, it is a positive integer starting from 0, for example, eth0 and eth1 ...... ethx. The interfaces of common cats and ADSL are pppx, such as ppp0;
In Linux, network interfaces are usually configured through network configuration tools, but the ultimate goal is to modify Network-related configuration files through network configuration tools. Therefore, we can directly modify the configuration file for the network configuration. For example, the IP address, subnet mask, and gateway of the network interface (NIC) only need to modify a configuration file in slackware./etc/rc. d/RC. inet1, and in RedHat/Fedora or other release versions based on Redhat/fedora, it usually involves several files, for example, including/etc/sysconfig/network-scripts/ifcfg-eth0.
It is extremely important to understand the Linux network configuration file. We can only understand the network configuration file to understand what has been modified through tools and how it has taken effect. An inappropriate analogy: Linux is a transparent box. Everything in the box is clear at a glance. However, we have no chance to know about the closed source operating system, but we do not know how it is implemented.
For complex network models, Linux has great advantages. We may look at man and help to modify and modify the configuration file in just a few minutes. However, the operating system that closes the source graphic interface is not so lucky. Repeated mouse clicks and clicks dozens of times cannot solve the problem, which is extremely common.
Many releases and versions of Linux have their own dedicated configuration tools. The main purpose is to facilitate network configuration. However, there are also common configuration tools, such as ifconfig, IFUP, and ifdown;
2. Drivers of network hardware devices;
I have written in my previous documents that network hardware, such as network cards (including wired and wireless), cats, including common cats and ADSL cats, all require Kernel support, therefore, we must first know whether our network device has been supported by the hardware kernel. If not, we need to find the driver (or compile the kernel) to support it;
See:
3. Introduction to ifconfig tools for configuring network interfaces;
Ifconfig is a tool used to view, configure, enable, or disable network interfaces. For example, we can use this tool to temporarily configure the IP address, mask, broadcast address, and gateway of the NIC. You can also write it into a file (such as/etc/rc. d/RC. in this way, the system will read the file and set an IP address for the NIC. However, this is not necessary for the time being. The main reason is that each release version has its own configuration tool, and the host can be added to the network in any case;
Next we will look at the ifconfig usage;
3.1 ifconfig: view the network interface status;
If ifconfig is not followed by any parameters, the current network interface is output;
[root@localhost ~]# ifconfigeth0 Link encap:Ethernet HWaddr 00:C0:9F:94:78:0E inet addr:192.168.1.88 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::2c0:9fff:fe94:780e/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:850 errors:0 dropped:0 overruns:0 frame:0 TX packets:628 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:369135 (.4 KiB) TX bytes:75945 (74.1 KiB) Interrupt:10 Base address:0x3000lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:57 errors:0 dropped:0 overruns:0 frame:0 TX packets:57 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:8121 (7.9 KiB) TX bytes:8121 (7.9 KiB)
Explanation:
Eth0 indicates the first network card. hwaddr indicates the physical address of the network card. We can see that the physical address (MAC address) of this network card is 00: C0: 9f: 94: 78: 0e; Inet ADDR is used to indicate the IP address of the NIC. the IP address of the NIC is 192.168.1.88, the broadcast address, bcast: 192.168.1.255, and mask Address Mask: 255.255.255.0.
Lo indicates the host's bad return address. It is generally used to test a network program, but does not want users on the LAN or Internet to view it, you can only run and view the network interfaces on this host. For example, if we specify a bad address for the httpd server, we can enter 127.0.0.1 in the browser to see your website. But you can only see it, and other hosts or users in the LAN cannot know it;
If you want to know all the network interfaces of the host, use the following command;
[root@localhost ~]# ifconfig -a
If we want to view a port, for example, we want to view the eth0 status, we can use the following method;
[root@localhost ~]# ifconfig eth0
3.2 configure the network interface in ifconfig;
Ifconfig can be used to configure the IP address, mask, gateway, and physical address of the network interface. It is worth mentioning that ifconfig is used to specify an IP address for the network adapter, which is only used to debug the network interface, the system Nic configuration file will not be changed. If you want to fix the IP address of the network interface, there are three methods: one is to modify the IP address through a dedicated tool for each release and version; the second is to directly modify the configuration file of the network interface. The third is to modify a specific file and add the ifconfig command to specify the IP address of the NIC, for example, in RedHat or fedora, write the ifconfig language name to/etc/rc. d/RC. local file;
How to configure the network port in ifconfig:
The ifconfig tool configures network interfaces through command parameters. We only need to specify the most common parameters;
Ifconfig network port IP address HW <HW> MAC address netmask mask address broadcast address [up/down]
* Instance 1:
For example, we use ifconfig to debug the address of the eth0 Nic.
[root@localhost ~]# ifconfig eth0 down
[root@localhost ~]# ifconfig eth0 192.168.1.99 broadcast 192.168.1.255 netmask 255.255.255.0
[root@localhost ~]# ifconfig eth0 up
[root@localhost ~]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:11:00:00:11:11
inet addr:192.168.1.99 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:11 Base address:0x3400
Note:Let's explain the above example;
The first line: ifconfig eth0 down indicates that if eth0 is activated, it will be down. This command is equivalent to ifdown eth0;
Row 2: Use ifconfig to configure the eth0 IP address, broadcast address, and network mask;
Row 3: Use ifconfig eth0 up to activate eth0. This command is equivalent to IFUP eth0.
Row 4: Use ifconfig eth0 to view the eth0 status;
Of course, you can also use the command IP address, network mask, broadcast address to activate the NIC, add the up parameter, for example, the following example;
[root@localhost ~]# ifconfig eth0 192.168.1.99 broadcast 192.168.1.255 netmask 255.255.255.0 up
* Example 2:In this example, we need to learn how to set the network IP address and the physical address (MAC address) of the network card );
For example, we set the IP address, network mask, broadcast address, physical address, and activate the eth1 Nic;
[Root @ localhost ~] # Ifconfig eth1 192.168.1.252 HW ether 00: 11: 00: 00: 11: 11 netmask 255.255.255.0 broadcast 192.168.1.255 up
Or
[Root @ localhost ~] # Ifconfig eth1 HW ether 00: 11: 00: 00: 11: 22
[Root @ localhost ~] # Ifconfig eth1 192.168.1.252 netmask 255.255.255.0 broadcast 192.168.1.255 up
HW is followed by the network interface type. Ether indicates Ethernet. It also supports ax25, ARCNET, and netrom. For more information, see man ifconfig;
3.3 How to Use ifconfig to configure virtual network interfaces;
Sometimes we need to configure virtual network interfaces to meet different needs. For example, we need to use different IP addresses to run multiple HTTPd servers; in this way, the same IP address is saved. If two HTTPd servers are opened, you must specify the port number.
A virtual network interface is used to specify multiple IP addresses for a network interface. The virtual interfaces are eth0: 0, eth0: 1, eth0: 2... eth1n. Of course, you must specify multiple IP addresses for eth1, that is, eth1: 0, eth1: 1, eth1: 2 ...... and so on;
In fact, if you use ifconfig to configure multiple IP addresses for a nic, you can use the ifconfig usage we mentioned earlier. This is relatively simple. See the following example;
[Root @ localhost ~] # Ifconfig eth1: 0 192.168.1.20.hw ether 00: 11: 00: 00: 11: 33 netmask 255.255.255.0 broadcast 192.168.1.255 up
Or
[Root @ localhost ~] # Ifconfig eth1 HW ether 00: 11: 00: 00: 11: 33
[Root @ localhost ~] # Ifconfig eth1 192.168.1.20.netmask 255.255.255.0 broadcast 192.168.1.255 up
Note:Specify a different physical address for each virtual network card;
In RedHat/Fedora or a system similar to RedHat/fedora, you can configure the network IP address, broadcast address, mask address, physical address, and activate the network interface in one sentence, write/etc/rc. d/RC. local. For example, the following example;
ifconfig eth1:0 192.168.1.250 hw ether 00:11:00:00:11:44 netmask 255.255.255.0 broadcast 192.168.1.255 up
ifconfig eth1:1 192.168.1.249 hw ether 00:11:00:00:11:55 netmask 255.255.255.0 broadcast 192.168.1.255 up
Explanation:Two virtual interfaces are set for the network interface of eth1. Each interface has its own physical address and IP address ......
3.4 how to use ifconfig to activate and terminate network interface connections;
Use the ifconfig command to activate and terminate the network interface, followed by the network interface, and add the down or up parameter to disable or activate the corresponding network interface. Of course, you can also use specialized tools IFUP and ifdown;
[root@localhost ~]# ifconfig eth0 down
[root@localhost ~]# ifconfig eth0 up
[root@localhost ~]# ifup eth0
[root@localhost ~]# ifdown eth0
This is also true for activating other types of network interfaces, such as ppp0 and wlan0. It is only valid for the NIC of the specified IP address.
Note: The IP address automatically assigned by DHCP must be activated by the network tools provided by each release. Of course, you must install the DHCP client. You should understand this;
For example, RedHat/Fedora
[root@localhost ~]# /etc/init.d/network start
Slackware release;
[root@localhost ~]# /etc/rc.d/rc.inet1
4. Debian, slackware, RedHat/fedora, Suse, and other specialized network interface configuration tools;
Ifconfig is troublesome to use and used to test the network. However, this tool cannot modify the corresponding configuration file of the network interface. Although the ifconfig Network Interface Configuration statement can also be written to a statement similar to/etc/rc. d/RC. the local file, but it is relatively safer and more reliable to write the configuration file about the network interface; but it is similar to/etc/rc to write the virtual network interface. d/RC. local is still acceptable;
Next we will introduce the network interface configuration tools for each release;
4.1 Debian network interface configuration file and dedicated Configuration tool;
Adding;
4.2 RedHat/Fedora network interface configuration file and network interface dedicated Configuration tool;
In RedHat/fedora, configuration files related to the Ethernet Adapter are located in the/etc/sysconfig/network-scripts directory, such as ifcfg-eth0, ifcfg-eth1 ........
4.21 RedHat/Fedora or the NIC configuration file of a system similar to this;
</Font? <P>
For example, in fedora 5.0, ifcfg-eth0;
If you use a DHCP server to automatically obtain the IP address, the content of the ifcfg-eth0 is generally similar to the following;
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=dhcp
TYPE=Ethernet
If you specify an IP address, the general content is similar to the following;
Device = eth0 Note: Network Interface
Onboot = Yes Note: activated during boot
Bootproto = static Note: static IP addresses are used;
Ipaddr = 192.168.1.238 Note: IP Address
Netmask = 255.255.255.0 Note: network mask;
Gateway = 192.168.1.1 Note: gateway;
The following options can also be used;
Hostname = linxsir03 Note: Specify the host name;
Domain = localdomain Note: Specifies the domain name;
Hwaddr = 00: 00: 11: 22: 00: AA note: the hardware address (MAC address) of the NIC can also be omitted, however, changing the MAC address here generally does not take effect. You can use the ifconfig method mentioned above to change it;
4.22 RedHat/Fedora or similar systems, network configuration tools;
In earlier versions of RedHat, tools such as linuxconf, RedHat-config-network, and netconfig are available;
The latest versions of RedHat/Fedora include system-config-Network-tui (in text mode), system-config-Network (in graphic mode), and netconfig (in text mode ).
These tools will directly modify the network interface configuration file in Linux; this is incomparable to ifconfig;
The RedHat-config-network and system-config-network tools are not only used to configure network interfaces, you can also configure ISDN and common cats, ADSL tools, network hardware addition, host name configuration, DNS Client configuration, and so on. It is actually a tool group integration;
These tools are relatively simple and can be called by running commands with root permissions, for example:
[root@localhost ~]# /usr/sbin/system-config-network
[root@localhost ~]# system-config-network
If you have set the environment variables for executable commands, you can run the command without adding a path, provided that you have to install the network management tool;
However, it is worth noting that the netconfig tool is a good tool in the text mode and is recommended for use. The reason is that the tool also has a simple graphical interface in the text mode, as well as a command mode; powerful functions;
[Root @ localhost ~] # Netconfig-D eth0 Note: Configure eth0
[Root @ localhost ~] # Netconfig-D eth1 Note: Configure eth1
4.23 special introduction to netconfig in RedHat/Fedora;
Netconfig is a powerful tool that exists in RedHat/Fedora or systems similar to them. So let's take a special look. However, in slackware, netconfig is a graphical mode in text mode, but it cannot be used to operate Nic interfaces like ifconfig;
The usage of netconfig is as follows:
[Root @ localhost ~] # Netconfig -- help Note: help;
-- Bootproto = (DHCP | BOOTP | none) boot protocol to use (
-- Gateway = string Network Gateway (specified gateway)
-- IP = string IP address (specified IP address)
-- Nameserver = string nameserver (specify the DNS Client)
-- Netmask = string netmask (specify the network mask)
-- Hostname = string hostname (specify the host name)
-- Domain = string domain name (specified domain name)
-D, -- device = string network device (specify the network device)
-- Nodns no DNS lookups (no DNS query)
-- Hwaddr = string Ethernet hardware address (specify the physical address of the NIC)
-- Description = string description of the device (descriptive text)
Help options: (help options)
-?, -- Help show this help message
-- Usage display brief usage message
Instance 1: Set the DHCP mode of the NIC to automatically obtain the IP address
[root@localhost ~]# netconfig -d eth0 --bootproto=dhcp
Instance 1: manually set the IP address of the NIC.
[root@localhost ~]# netconfig -d eth0 --ip=192.168.1.33 --netmask=255.255.255.0 --gateway=192.168.1.1
4.3 slackware Nic configuration file and Configuration tool;
The slackware Nic configuration file is/etc/rc. d/rc. inet1.conf. This file includes the NIC and wireless Nic configurations of the Ethernet interface. Slackware is still relatively pure, and the network configuration is also relatively simple; In slackware, there is also a netconfig Configuration tool, which is also run in text mode. The man-machine interaction interface, this setting is relatively simple;
After slackware uses netconfig to configure the network card, its essence is to modify the/etc/rc. d/rc. inet1.conf file. Slackware is a Linux system with the original source method. Its configuration files are standard. Therefore, I recommend that you try slackware in a production system;
After configuring the NIC, you must run the following command to activate the NIC;
[root@localhost ~]# /etc/rc.d/rc.inet1
The following is an example. The machine has two NICs eth0 and eth1. eth0 uses DHCP to obtain the IP address, and eth1 specifies the IP address;
# Config information for eth0:
Ipaddr [0] = ""
Netmask [0] = ""
Use_dhcp [0] = "yes" Note: "Yes" indicates that IP addresses are obtained through DHCP;
Dhcp_hostname [0] = "linuxsir01" NOTE: You can also use IP addresses to specify the DNS server host name;
# Config information for eth1: Note: the configuration of the network adapter eth1;
Ipaddr [1] = "192.168.1.33" NOTE: specify an IP address;
Netmask [1] = "255.255.255.0" NOTE: Specify the mask;
Use_dhcp [1] = "no" NOTE: IP addresses are obtained without DHCP;
Dhcp_hostname [1] = ""
# Config information for eth2:
Ipaddr [2] = ""
Netmask [2] = ""
Use_dhcp [2] = ""
Dhcp_hostname [2] = ""
# Config information for eth3:
Ipaddr [3] = ""
Netmask [3] = ""
Use_dhcp [3] = ""
Dhcp_hostname [3] = ""
# Default gateway IP Address:
Gateway = "192.168.1.1" NOTE: Specify the gateway;
4.4 SuSE or opensuse Nic configuration files and configuration tools;
Updating;
5. Introduction to the numbering tool;
Some brothers may need the dialing tools for ADSL cats and common cats. Now let's introduce them separately;
5.1 ADSL pppoe dialing tool RP-pppoe;
If your ADSL instance is not a route entry, if it is a route entry, you can set an automatic dial number on the route entry. You only need to connect the machine to use it. If your ADSL does not support routing, or you want to use your current host as a router; this requires a code pulling software;
Currently, the pppoe protocol is used in most cities in China. Therefore, we need to introduce the pppoe code pulling software. In Linux, the software name is RP-pppoe;
RP-pppoe homepage;
Http://www.roaringpenguin.com/penguin/open_source_rp-pppoe.php
5.11 installation and use of RP-pppoe for various major release editions;
RP-pppoe currently exists in various major release versions, such as RedHat/fedora, Hongqi, slackware, Debian, and Suse, therefore, you do not need to compile and install the source code for download. You only need to find the software package on the installation disks of the major release editions. Use the software package management tool that comes with the major release editions to install the software package;
* If you are using the RP-pppoe software package provided by various major release editions
For example, the RPM package system uses rpm-ivh rp-pppoe *. rpm
The slackware system uses installpkg RP-pppoe *. tgz
In RedHat/fedora, you can use the graphic configuration tool to complete the RedHat-config-network command and call the configuration Network. It is relatively easy to add a dial through XDSL;
The common method for all releases is to configure ADSL through the ADSL-setup command;
[Root @ localhost ~] # ADSL-setup Note: configure the pppoe serial number. See the following for details;
[Root @ localhost ~] # ADSL-start Note: Start the dial number;
[Root @ localhost ~] # ADSL-Stop Note: disconnect;
5.12 if the source code package is installed, We need to compile and install it ourselves;
[Root @ localhost ~] # Tar zxvf rp-pppoe-3.8.tar.gz
[Root @ localhost ~] # Cd rp-pppoe-3.8
[Root @ localhost rp-pppoe-3.8] #./go
Welcome to the roaring penguin pppoe Client Setup. First, I will run
Some checks on your system to make sure the pppoe client is installed
Properly...
Looks good! Now, please enter some information:
User Name
>>> Enter your pppoe User Name (default bxxxnxnx@sympatico.ca): Here add your dial user name; it is provided by the service provider;
>>> Enter the Ethernet interface connected to the DSL modem
For Solaris, this is likely to be something like/dev/hme0.
For Linux, it will be ethn, where 'n' is a number.
(Default eth0): If eth0 is the ADSL of the Ethernet interface, you need to write the network interface number connected to the cat here. Here is eth0;
Do you want the link to come up on demand, or stay up continuously?
If you want it to come up on demand, enter the idle time in seconds
After which the link shoshould be dropped. If you want the link
Stay up permanently, enter 'no' (two letters, lower-case .)
Note: Demand-activated links do not interact well with dynamic IP
Addresses. You may have some problems with demand-activated links.
>>> Enter the demand value (default no): Note: Press enter by default.
>>> Enter the DNS information here: 202.96.134.133 Note: Enter the DNS server address here. You can ask the DNS server address from the provider or use this address;
Please enter the IP address of your ISP's secondary DNS server.
If you just press enter, I will assume there is only one DNS server.
>>> Enter the secondary DNS server address here: 202.96.128.143 this is the second DNS server address;
>>> Please enter your pppoe password: enter your password here;
>>> Please re-enter your pppoe password: confirm the password;
The firewall choices are:
0-None: This script will not set any firewall rules. You are responsible
For ensuring the security of your machine. You are strongly
Recommended to use some kind of firewall rules.
1-standalone: appropriate for a basic stand-alone Web-surfing Workstation
2-masquerade: appropriate for a machine acting as an Internet gateway
For a LAN
>>> Choose a type of firewall (0-2): 2 Note: Write 2 here to share the Internet; of course, add a firewall plan;
Ethernet interface: eth0
User name: dxxx
Activate-on-demand: No
Primary DNS: 202.96.134.20.
Secondary DNS: 202.96.128.143
Firewalling: Masquerade
>>> Accept these settings and adjust configuration files (y/n )? Y Note: whether to save the configuration;
For more information about Internet sharing, see:Solution to ADSL Internet sharing
5.2 introduction to common cat dialing tools;
Common cats are classified into serial ports and PCI devices. For more information, see overview of network devices.
Common cat dialing tools mainly include kppp and wvdial. in RedHat/fedora, you can also set PPP dialing using system-config-network or RedHat-config-network;
In the KDE Desktop Environment, you generally use the kppp dial-up tool and click the mouse to complete it;
Wvdial is a text tool available in almost all major releases. The configuration file of wvdial is/etc/wvdial. conf. If your cat is already driven, run the wvdialconf command to generate/etc/wvdial. conf. Of course, you have to check its content;
[root@localhost ~]# wvdialconf
[root@localhost ~]# more /etc/wvdial.conf
For how to use the wvdial tool, see Introduction to wvdial, a common 56 k cat dialing online tool.
6. Wireless Network Card;
Updating; because I don't have such a nic, is there a detailed article? This is blank in all documents involving wireless NICs. This is what is missing.
It seems that I have to get a wireless network card ......
7. DNS Client configuration file/etc/resolv. conf;
The DNS Client configuration file should not have been put here, but it cannot be accessed by domain names even though it can be used by new beginners to access the Internet. The reason is that the/etc/resolv. conf file is not modified;
The/etc/resolv. conf file stores a list of DNS servers of various communication companies. You can use the following three addresses. Of course, you can call your service provider;
nameserver 202.96.134.133
nameserver 202.96.128.143
nameserver 202.96.68.38
8. About this article;
This article describes the configuration of commonly used Ethernet interfaces, and describes ifconfig and netconfig. I think the most important thing is the configuration file. Let's take a closer look at the configuration file. After you use the tool to complete the configuration, you can view the changes in the corresponding configuration file. I think this learning method can be known and then known;
-- At linuxsir. org 2006-07-05
9. Update logs;
The first draft of v0.1b was completed from;
10. references;
Man and help;
11. related documents;
Linux Network Basics
Tools for changing the speed and negotiation of network interfaces miitool and ethtool