Detailed Network configuration under Linux

Source: Internet
Author: User
Tags nameserver

Detailed Network configuration under Linux

1. The network card name setting path is as follows:

RHEL5:/etc/modprobe.conf

RHEL6:/etc/udev/rules.d/70-persistent-net.rules

2.ifconfig command

Format: ifconfig ethX ip/mask [Up|down]

-A: Displays configuration information for all interfaces

Example: ifconfig eth0 192.168.1.1/24 Configuring IP Address

Ifconfig eth0 up Enable interface

Ifconfig eth0:0 172.16.1.1/24 Configuring eth0 Secondary IP Address

Ifconfig eth0:0 Down interface

Ps:ifconfig command configuration information takes effect immediately, but fails after restarting the computer

Network services enable or disable or view:

RHEL5:/etc/init.d/network {start|stop|restart|status}

Service Network {Start|stop|restart|status}

RHEL6:/etc/init.d/networkmanager {start|stop|restart|status}

3. Gateway or route settings:

Format: Route add|del-net|-host target network GW next hop address

Route displays routing information (display name, if name is included)

Route-n: Displaying routing information digitally

Route add-net 172.16.8.0/24 GW 192.168.2.1 Add subnet route

Route add-host 172.16.9.1/32 GW 192.168.2.1 Add host route

Route add-net 0.0.0.0 GW 192.168.2.1 Add default route

Route add default GW 192.168.2.1

Route del-net 10.0.0.0/8 Delete subnet route

Route del-net 0.0.0.0 Default default route

Route del defaults default route

Ps:route command changes the configuration information to take effect immediately, but after restarting the network service or the host computer fails;

4. Network profile: Configuration information is permanent, but does not take effect immediately, restarting the network service or host will take effect immediately

4.1. Network Master switch configuration file:/etc/sysconfig/network

networking= Yes | No

4.2. Network interface configuration file:/etc/sysconfig/network-scripts/ifcfg-ethx

Device=: The associated device name, to be consistent with the second half of the file name "Interface_name";

BOOTPROTO={STATIC|NONE|DHCP|BOOTP}: Boot protocol; To use static addresses, use either statics or none;

DHCP indicates the use of a DHCP server to obtain an address;

Ipaddr=: IP Address

netmask=: Subnet Mask

Gateway=: Set default gateway;

Onboot=: Whether the network interface is activated automatically when booting;

Hwaddr=: Hardware address, to be consistent with the address in the hardware;

Userctl={yes|no}: Whether to allow ordinary users to control this interface;

Peerdns={yes|no}: Whether the DNS address specified by the DHCP server is accepted when Bootproto is DHCP;

Redhat5:setup | System-config-network-tui text mode command to change the configuration file

System-config-network-gui graphical interface command and change the configuration file

4.3. Routing configuration file:/etc/sysconfig/network-scripts/route-ethx

Add format one:

Destination network via next-hop address

....

Add format two:

The first route is represented as follows:

address0=

netmask0=

gateway0=

The second route is represented as follows:

address1=

netmask1=

gateway1=

......

5.DNS Server Setup method: Config file:/etc/resolv.conf

NameServer DNS1 Address

NameServer DNS2 Address

6. Local parsing: Configuration file/etc/hosts

Format: Host IP host name FQDN host Alias

Note: Linux hostname resolution order:/ETC/HOSTS-->/ETC/RESOLV.CONF

7. Configure host Name:

hostname hostname effective immediately, but not permanently;

Configuration file:/etc/sysconfig/network

Hostname= Host name FQDN

8.IP Command: Iproute installation package is required, more powerful than ipconfig command

Format: IP

Link: Network Interface properties

Ip-s Link Show

IP link Set NIC name {Up|down}

Addr: Protocol Address

IP addr Add ip address dev NIC name

IP addr del ip address dev NIC name

IP addr Show dev nic name to subnet prefix

IP addr Flush Dev nic name to subnet prefix

IP addr Add 192.168.200.1/24 dev eth1 label eth1:0

Route: Routing

IP route add subnet by Dev online name via next hop address

IP route add 1.1.1.0/24 deve eth0 via 192.168.3.1

IP Route del 1.1.1.0/24

9. Network Device Settings aliases:

Command configuration: ifconfig ethx:x IP address/mask

Ifconfig eth0:0 192.168.100.1/24

IP addr Add 192.168.200.1/24 dev eth1 label eth1:0

File configuration:/etc/sysconfig/network-scripts/ifcfg-ethx:x

Device=ethx:x

PS: Network device alias, that is, non-primary address cannot use DHCP dynamic acquisition;

This article is from the "Xavier Willow" blog, please be sure to keep this source http://willow.blog.51cto.com/6574604/1766989

Detailed Network configuration under Linux

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.