First, the network card
1, Linux: Network is the function of the kernel
2, the network card definition:
A) RHEL5 network card definition file:/etc/modprobe.conf
b) RHEL6 NIC definition file:/etc/udev/rules.d/70-persistent-net.rules
3. Name of network card:
A) Lo: local loopback
b) Ethernet network card: EthX
c) Point-to-point connection network card: pppx
4. NIC configuration command
a) ifconfig [EthX]: Display network card information
-A: Displays the configuration of all interfaces
b) ifconfig EthX ip/mask [Up|down]
The configured address takes effect immediately, but restarting the network service or host will fail;
c) ifconfig EthX Up|down Enable or disable the NIC
5, Network services:
A) RHEL5:/etc/init.d/network {start|stop|restart|status}
b) RHEL6:/etc/init.d/networkmanager {start|stop|restart|status}
6. Gateway Command: Route
Changes made to restart the Network service or host after the failure;
A) format: Route add-net|-host DEST GW Nexthop
b) Format: Route add default GW nexthop
such as: Route add-net 10.0.0.0/8 GW 192.168.10.1
c) Options:
Add: Adding
-host: Host Routing
-net: Network Routing
-net 0.0.0.0: Default route
d) Options:
Del: Delete
-host
-net
such as: Route del-net 10.0.0.0/8
Route Del-net 0.0.0.0
Route del Default
e) View:
Route-n: Digitally display information about each host or port
Second, network configuration file
1. Network interface configuration file:/etc/sysconfig/network-scripts/ifcfg-interface_name
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 to obtain an address using a DHCP server;
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;
will not take effect immediately, but restarting the network service or host will take effect;
2. Routing Profile:/etc/sysconfig/network-scripts/route-ethx
Add format one:
DEST via Nexthop
Add format two:
address0=
netmask0=
gateway0=
3. The DNS server specifies only one method:/etc/resolv.conf
NameServer dns_ip_1
NameServer dns_ip_2
NameServer Dns_ip_3
4. Specify local parsing:/etc/hosts
Format:
Host IP host name host Alias
172.16.0.1 www.magedu.com www
5. Configure host Name:/etc/sysconfig/network
A) configuration file: Hostname=
b) The order is effective immediately, but not permanently: hostname NAME
6. Graphical interface Configuration
RHEL5:
Setup:system-config-network-tui
System-config-network-gui
Third, Iproute2 package
1, Ifconfig, is the old command
2. Iproute2 software package, powerful function
Ip
Link: Network Interface properties
Addr: Protocol Address
Route: Routing
a) Link
Show
Ip-s Link Show
Set
IP link set DEV {up|down}
b) Addr
Add
IP addr add address dev Dev (can add secondary addresses)
Del
IP addr del ADDRESS dev Dev
c) Show
IP addr Show
IP addr Show Dev dev to PREFIX (show only relevant addresses)
d) Flush (clear all relevant addresses)
IP addr Flush Dev dev to PREFIX
IP addr Flush to PREFIX
e) Route:
Route add-net 10.0.1.0/24 GW 192.168.100.6
IP route add to 10.0.1.0/24 Dev eth1 via 192.168.100.6
Add, change, show, flush, replace
Iv. Adding a secondary address
1, network equipment can be aliases:
Eth0:
Ethx:x, eth0:0, Eth0:1, ...
2, the command configuration method:
Ifconfig ethx:x Ip/netmask
such as: Ifconfig eth0:0 172.6.200.33/16
3. File configuration: /etc/sysconfig/network-scripts/ifcfg-ethx:x
Device=ethx:x
Non-primary addresses cannot be dynamically obtained using DHCP;
such as: IP addr add 192.168.100.1/24 dev eth1 label eth1:0.
This article is from "Nick Liu's blog", so be sure to keep this source http://zkhylt.blog.51cto.com/3638719/1409453