Linux network configuration related commands, virtual network interface eth0:0

Source: Internet
Author: User
Tags web hosting

network Interface (interface) is the network hardware device in the operating system representation method, such as NIC in the Linux operating system with EthX, is a positive integer starting from 0, such as eth0, eth1 ... ethX. And the common cat and ADSL interface is pppx, such as ppp0 and so on;

all available network cards, names, configuration files in the machine:

  • DMESG | grep ETH: You can see the network card startup information and the name of the corresponding network card when the system starts, then you can manually add the corresponding/ETC/SYSCONFIG/NETWORK-SCRIPTS/IFCFG-ETHX file to configure the network card
  • Ifconfig-a: View all active and terminated network cards and corresponding information
  • Cat/proc/net/dev: View all virtual ETH files
  • Files such as/dev/eth0,/dev/eth1 are not found in the Dev directory: in many UNIX operating systems, network devices appear in the/dev directory. But that's not the case with Linux. In Linux, network devices are created dynamically and do not require a device file to be generated in the/dev directory. Most network devices are automatically created by device drivers when initializing and loading hardware. For example: Ethernet device driver in order to load Ethernet hardware when the ETH[0..N] NIC interface, the first Ethernet card into eth0, the second Ethernet card into a eth1. This is defined in Net-3-howto in the/doc/howto directory of the Redhat 6.0 installation disk. You can view the configured Ethernet device properties through the virtual file:/proc/net/dev. In many Unix operating systems the network devices has appearances in The/dev directory. This was not so in Linux. In Linux the network devices is created dynamically in software and does not require device files to be present. In the majority of cases the network device was automatically created by the device driver while it was initializing and has Located your hardware. For example, the Ethernet device driver creates ETH[0..N] interfaces sequentially as it locates your Ethernet hardware. The first Ethernet card found becomes eth0, the second eth1 etc. " This is quoted from Net-3-howto in The/doc/howto directory of my RH 6.0 Install cdrom. Can see the SEttings for configured Ethernet devices in The/proc/net/dev ' pseudo file


Network Configuration related commands:

    • /bin/hostname Display host Name
    • /etc/rc.d/init.d/network Network Service startup script (service network restart)
    • /sbin/ifconfig view, configure, enable or disable the network interface (NIC) IP address, MAC address, mask, broadcast address, if is the network interface (interface) shorthand
    • /sbin/ifup Ifdown activating or terminating the network interface


/etc/init.d/network Network Service startup script  
Service Network start|stop|reload|restart|status| FORCE-RELOAD&NBSP

/sbin/ifconfig to view, configure, enable, or disable the network interface (NIC) tool  
Ifconfig is a view, configuration, A tool that enables or disables the network interface, which is a very common tool. For example, we can use this tool to configure the network card IP address, MAC address, mask, broadcast address and so on. It is worth saying that you use Ifconfig to specify the IP address for the network adapter, which is only used for debugging networks, and does not change the system configuration file on the NIC. If you want to fix the IP address of the network interface, there are currently three methods: one is to modify the IP address through each release and version-specific tool, and the other is to modify the configuration file of the network interface directly, and the third is to modify the specific file and add the ifconfig instruction to specify the IP address of the NIC. For example, in Redhat or Fedora, the name of the Ifconfig is written to the/etc/rc.d/rc.local file,  

ifconfig Configure network interface syntax:  
Ifconfig Network port IP address HW MAC address netmask Mask address broadcast broadcast address [up/down] 

ifconfig common usage:  

    • ifconfig: View the network interface of the host activation state; in the output: Lo is the return bad address of the host, Eth0 represents the first Nic, where HWaddr represents the physical address (MAC address) of the network card, and inet addr is used to represent the IP address of the network card. Bcast represents the broadcast address, mask represents the mask address
    • ifconfig-a: View all of the network interfaces that are not active
    • ifconfig eth0: View the status of a specific network interface
    • IFC Onfig eth0 down = ifup eth0: If the eth0 is active, terminate it. This command is equivalent to Ifdown eth0;
    • ifconfig eth0 up = Ifdown eth0: activates eth0; This command is equivalent to ifup eth0
    • ifconfig eth0 192.168.1 . Broadcast 192.168.1.255 netmask 255.255.255.0: Configure the Eth0 IP address, broadcast address, and netmask;
    • ifconfig eth0 192.168.1.99 Broadcast 192.168.1.255 netmask 255.255.255.0 up: Activate Nic eth0
    • ifconfig eth1 hw ether 00:11:00:00:11:22 While configuring IP address, netmask, broadcast address : Sets the physical address (MAC address) of the network card. Where HW is followed by the network interface type, ether means Ethernet, but also support ax25, ARCnet, Netrom, etc., see Man ifconfig for details;


to configure a virtual network interface with Ifconfig:
Sometimes we need to configure the virtual network interface to meet different needs, such as we use a different IP address to run multiple httpd servers, it is necessary to use virtual address, so that the same IP address, if you open two httpd server, you want to specify the port number.

Virtual network interface refers to a network interface to specify multiple IP addresses, the virtual interface is such eth0:0, Eth0:1, Eth0:2 ... eth1n. Of course you specify multiple IP addresses for eth1, i.e. eth1:0, eth1:1, Eth1:2 ... And so on
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
Note: When specifying, specify a different physical address for each virtual NIC;

Association: name-based Virtual Host Support-apache domain-based web hosting settings (1 IPs, multiple services)

Linux network configuration related commands, virtual network interface eth0:0

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.