Getting started with linux network configuration

Source: Internet
Author: User
Getting started with linux network configuration (I) network interface www.2cto.com ① naming rules linux kernel specifies different prefixes for interface names based on the interface type, each interface will be allocated a number from scratch... info & nbsp; | & nbsp; getting started with linux Network Configuration Guide (I) network interface www.2cto.com ① naming rules linux kernel specifies different prefixes for interface names based on the interface type, each interface is allocated a number from scratch. for example, all Ethernet interfaces start with eth, eth0, eth1, and eth2 indicate the first, second, and third Ethernet cards, respectively. ② The Nic configuration information is displayed. only the active Nic ifconfig displays all interfaces (NICS) ifconfig-a or ip link (II) driver select www.2cto.com Redhat to compile the NIC driver as the kernel module, according to/etc/modprobe. in conf, the NIC module is loaded at/etc/mod In probe. conf, map the interface name to the specified module [plain] [root @ Think ~] # Grep 'Alias eth '/etc/modprobe. conf alias eth0 vmxnet alias eth1 e1000 alias eth2 e1000 if there is only one Nic, that is, only one Nic uses this module (driver), then in modprobe. if multiple NICs are mapped to one module at the same time, for example, in the preceding example, both eth1 and eth2 use the e1000 module, you must specify the HWADDR variable. you can specify [plain] [root @ Think ~] in/etc/sysconfig/network-scripts/ifcfg-eth *. # Grep 'hwaddr '/etc/sysconfig/network-scripts/ifcfg-eth */etc/sysconfig/network-scripts/ifcfg-eth1: HWADDR = 00: C2: 89: fQ: b7: 55/etc/sysconfig/network-scripts/ifcfg-eth2: HWADDR = 00: TC: Q6: CC: 5F: F5 (3) default mode for bandwidth and duplex settings, the interface module is configured with autonegotiate, that is, allow the NIC to communicate with the upper-level hub/switch. select the best setting but sometimes it is not the best. you can manually set ① temporary modification: ifdown eth0 ethtool-s eth0 autoneg off speed 1000 duplex full ifup eth0 set the network adapter eth0 to 1000 Mbps bandwidth, full duplex mode, and disable automatic negotiation ② permanent modification: You only need to add the ETHTOOL_OPTS variable in/etc/sysconfig/network-scripts/ifcfg-ethX: ETHTOOL_OPTS = "autoneg off speed 1000 duplex full" (4) the dynamic IPv4 configuration interface is defined in: /etc/sysconfig/network-scripts/ifcfg-etcX dynamic setting usage variable: BOOTPROTO = dhcp case: [plain] [root @ Think ~] # Cat/etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE = eth0 BOOTPROTO = dhcp ONBOOT = yes activation changes to the configuration: ifdown ethX ifup ethX (v) static IPv4 configuration interface configuration is defined in: /etc/sysconfig/network-scripts/ifcfg-etcX static configuration use variable: BOOTPROTO = none IPADDR = NETMASK = case: [plain] [root @ Think ~] # Cat/etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE = eth0 BOOTPROTO = none IPADDR = 192.168.1.112 NETMASK = 255.255.255.0 GATEWAY = 192.168.1.1 ONBOOT = yes activate configuration changes: ifdown ethX ifup ethX (6) The IP alias binds multiple IP addresses to one Nic, for example, eth0: 1 eth0: 2 eth0: 3. each device alias generates an independent interface configuration file, for example: /etc/sysconfig/network-scripts/ifcfg-etc0: 1 specific configuration please refer to the previous blog: http://www.2cto.com/os/201211/170717.html (Vii) use route netstat-r ip route [plain] [root @ Think ~] to browse the route table. # Route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.1.0*255.255.255.0 U 0 0 0 eth0 192.168.122.0*255.255.255.255.0 U 0 0 virbr0 255.* 255.255.0.0 U 0 0 0 eth0 default 192.168.1.1 0.0.0.0 UG 0 0 0 eth0 [root @ Think ~] # Netstat-r Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 192.168.1.0*255.255.255.0 U 0 0 0 eth0 192.168.122.0*255.255.255.0 U 0 0 0 virbr0 255.* 255.255.255.0.0 U 0 0 0 eth0 default 192.168.1.1 0.0.0.0 UG 0 0 0 eth0 [root @ Think ~] # Ip route 192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.112 192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 169.254.0.0/16 dev eth0 scope link default via 192.168.1.1 dev eth0 guest default gateway default Gateway (vro) when there is no "more specific match" in the routing table, you can use this function to dynamically retrieve IP data packets when only "one egress" is available in the LAN: configure static DHCP server configuration: use the variable GATEWAY to configure/etc/sysconfig/network in the general network configuration file to configure/etc/sysconfig/network-scripts/in the interface configuration file/ If ifcfg-ethX is configured in both common and interface, the interface configuration has a higher priority (priority) and the IP connection ping is determined by using the following command: network packet loss and wait time measurement tool ping the default behavior is to send a 64 byte ICMP packet-c option to the specified host per second to allow us to cancel the ping command when Ctrl-c combination key should number of ICMP packets sent: traceroute: it is shown that the network path to the destination passes through the network. it usually goes through multiple routers to determine which router fails. (10) it is usually useful to define the local host name query host name: temporary hostname definition: permanent definition of hostname Think: the HOSTNAME (11) variable specified in/etc/sysconfig/network must be resolved locally. the priority of www.2cto.com is higher than that of the DNS configuration file/etc/hosts. localhost entries must be included, it is better to include the master that has been defined in/etc/sysconfig/network Do not modify the localhost line name, but you can add the alias [plain] [root @ Think ~] at the end of the line. # Cat/etc/hosts # Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 localhost. localdomain localhost 192.168.1.112 localhost. localdomain localhost 117.79.93.222 www.csdn.net www (12) remote resolution configuration file/etc/resolv. conf
 
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.