When we turn on the computer, we need to connect the host to the network, so we must configure the network to realize our communication in the LAN and even the communication between different networks.
In the network, the general configuration of several aspects:
IP address; netmask subnet mask; Gateway Gateway (the direction in which the network is to be reached);
hostname host name; DNS; DHCP (automatically obtain IP address)
RHEL5: The driver for the same type of network card is defined in the/etc/modprobe.conf file.
And in RHEL6: it's defined in the/etc/udev/rules.d/70-persistent-net.rules file (not much said here)
First configure various information with the command:
(But the configured address can take effect immediately, but restarting the network service or host, is not valid, is temporary.) )
1, configure the host name:
hostname hostname
2, Ifconfig command
Ifconfig [ethx]--Display the configuration information for the NIC
-A: Display configuration information for all interfaces
Ifconfig ethx Ip/mask [Up|down] configures the IP address and subnet mask of a network interface
3, Route command:
route--View routing Table
route-n--displays information about each host or port in digital form
To add host Routing and network routes and their gateways:
Route add-net|-host DEST GW Nexthop
Route add default GW nexthop or route add-net 0.0.0.0
To delete a route:
Route Del-net|-host Destip/mask
Route del-net 0.0.0.0 or Route del defaul remove the default route
The configuration file modification makes the configuration information permanent, but takes effect when the network or host is restarted.
1, network configuration file:
/etc/sysconfig/network
2, network interface configuration file:
/etc/sysconfig/network-scripts/ifcfg-interface_name
Its internal format is as follows:
Device=: The associated device name to be consistent with the second half of the filename, "interface_name"
BOOTPROTO={STATIC|NONE|DHCP|BOOTP}: Boot protocol: To use static addresses, use either static or none; DHCP represents using a DHCP server to obtain addresses.
Ipaddr=:ip Address
netmask=: Subnet Mask
Gateway=: Set Default gateway
Onboot=: Automatically activate this network interface at power-on
Hwaddr=: Hardware address, to be consistent with the address in the hardware;
Userctl={yes|no}: Allow normal users to control this interface
Peerdns={yes|no}: Whether to accept DNS addresses specified by the DHCP server when BOOTPROTP is DHCP
3. Route:
/etc/sysconfig/network-scripts/route-ethx
There are two ways to add a format:
Add format one:
DEST via Nexthop
Add format two:
address0=
netmask0=
gateway0=
4. The DNS server specifies only one method:
/etc/resolv.conf
NameServer dns_ip_1
NameServer dns_ip_2
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/Linux/
5. Specify local resolution:
/etc/hosts
Host IP host name [host Alias]
Example: 172.16.0.1 www.hallo.com www
6. Configure the configuration file for the host name:
/etc/sysconfig/network
Networking=yes
Networking_ipv6=no
Hostname=hostname
You can add a gateway here
The second way to configure IP and routing with commands:
IP [OPTIONS] OBJECT {COMMAND | help}
Link: Configuring Network interface Properties
Show: View network interface address
# Ip-s Link show: displaying statistics
Set: Enable