Linux Network configuration ifconfig use of IP commands

Source: Internet
Author: User

The IP address belongs to the kernel, not the NIC. As long as the kernel has to be able to ping through.


Common types of network adapters:

Lo (loopback): local loopback.

Ethnum: Ethernet network card. CentOS7 in the ensnums.

Pppnum: Point-to-point.


To load a module configuration file:

/etc/modprobe.conf

In CentOS, only the/etc/modprobe.conf/folder can be created manually.


/etc/udev/rules.d/



#ifconfig [OPTION] [DEVICE] [ip/mask| IP MASK] [up|donw] Displays the status of the network card that is currently in use.

IP configured with this command will take effect immediately, but will fail if the service or host is restarted.

[OPTION]

-a displays the configuration parameters for all interfaces.


Network services:

Rhel5:/etc/init.d/network Start|stop|restart|status

Rhel6:/etc/init.d/networkmanager Start|stop|restart|status



Gateway:

#route [OPTION] Displays the routing table for the current system without any parameters.

As with Ipconfig, changes made after restarting the service or host are invalidated.

[OPTION]

Add

-host Host Routing

-net Network Routing


Del Delete

-host

-net


-n displays information such as hostname or port in digital form.



For example:

#route add-net 10.0.0.0/8 GW 192.168.10.1

#route del-net 10.0.0.0/8



Network configuration file:

The global file.

/etc/sysconfig/network

Information such as the gateway can also be defined in this file. However, the system will be a small range of whichever. The configuration of both network cards is higher than the global.


NIC configuration file:

The configuration file will not take effect immediately after it is modified, and will not take effect until the service or host is restarted.

/etc/sysconfig/network-scripts/ifcfg-internface_name


Common content is as follows:

Device=device the name of the associated device.


bootproto= static|bootp|dhcp|none Boot protocol.


ipaddr= IP Address IP addresses


netmask= NETMASK Subnet Mask


gateway= Gateway Gateways


onboot= On|off Whether this network interface is activated automatically.


Hwaddr= MAC address.


Userctl= yes|no allow normal user to control this interface


peerdns= Yes|no If the DNS address specified by the DNS server is accepted when Bootproto is DHCP.



Routing configuration file:

/etc/sysconfig/nework-scripts/route-device


Format 1:

DEST via Nexthop

For example:

192.168.2.0/24 via 10.0.0.1


Format 2;

addressnum=

netmasknum=

gatewaynum=

For example:

address0=192.168.10.0

nexthop0=255.255.255.0

gateway0=10.10.10.254

address1=192.168.20.0

netmask1=255.255.255.0

gateway1=10.10.20.254



DNS configuration file

/etc/resolv.conf


Fill up to 3 records.

If Bootprot is set to DHC in the network configuration file, setting Peerdns to No will prevent the DHCP server from overwriting the contents of this file.

Format:

NameServer DNS_IP


Local parsing file:

/etc/hosts

Format:

Host IP host name alias (can be omitted)


Parse Order:

/etc/hosts-->dns Cache-->dns Server



Configure host Name:

#hostname hostname effective immediately and fails after reboot.


To modify a configuration file:

Takes effect after restarting the service or host.

/etc/sysconfig/network

Hostname= HOSTNAME


Iproute2 Package

#ip

Link Network Interface Properties

Show view network interface address, equivalent to ifconfig-a.

-S Display Interface statistics


Set DEVICE sets the operating properties of the network interface




Addr Protocol Address

Add

Ipaddrss Dev DEVICE lable device:num

Del

IPADDRESS Dev DEVICE


Show Dev DEVICE

To PREFIX show matching criteria

For example:

#ip addr Show to 10/8 displays only the information that begins with 10.


Flush Dev DEVICE Empty address

For example:

#ip addr Flush Dev eth1 to 10/8 empties the address starting with 10.



Route routing

Show

To PREFIX

Flush





A single network card uses multiple addresses:

Use aliases:

#ifconfig Device:num Ipadd/netmask

/etc/sysconfig/network-scirpts/ifcfg-device:num

Device=device:num

Bootproto=static|none


Use the IP command:

#ip addr Add 192.168.1.22/24 eth1 lable eth1:3

#ip Addr Show


This article is from "Small Private blog" blog, please be sure to keep this source http://ggvylf.blog.51cto.com/784661/1609302

Linux Network configuration ifconfig use of IP commands

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.