Redhat Linux Network configuration, basically by modifying several configuration files to achieve, although you can also use Ifconfig to set the IP, with the route to configure the default gateway, with the hostname to configure the hostname, but the restart will be lost.
Related configuration Files
/ect/hosts Configuring host name and IP address correspondence
/etc/sysconfig/network Configuring host names and Gateways
/etc/sysconfig/network-scripts/ifcfg-eth0 eth0 configuration file, eth1 file name is Ifcfg-eth1, and so on
First, the network card configuration
Suppose we want to configure the IP address 192.168.168.1/24 with the hostname Test,eth0, the gateway address 192.168.168.250
The contents of the/etc/sysconfig/network file are as follows:
Networking=yes
Hostname=test
gateway=192.168.168.250
eth0 corresponding configuration file/etc/sysconfig/network-scripts/ifcfg-eth0 content is as follows:
Device=eth0
Bootproto=static
ipaddr=192.168.168.1
netmask=255.255.255.0
Type=ethernet
Onboot=yes
Two, a single network adapter to bind multiple IPs
Sometimes we need to configure multiple IPs on a NIC, for example, in the example above, we also need to configure IP 192.168.168.2 and 192.168.168.3 for eth0. Then you need to create a new two configuration file under/etc/sysconfig/network-scripts:
ifcfg-eth0:0 content is as follows:
device=eth0:0
Bootproto=static
ipaddr=192.168.168.2
netmask=255.255.255.0
Onboot=yes
ifcfg-eth0:1 content is as follows:
Device=eth0:1
Bootproto=static
ipaddr=192.168.168.3
netmask=255.255.255.0
Onboot=yes
Three, multiple network cards bundled into a virtual network card
In order to provide high availability of the network, we may need to bind multiple network cards into a virtual network card to provide services, so that even if one of the physical NIC fails, it will not cause a connection interruption. For example, we can bind eth0 and eth1 to a virtual NIC Bond0
First, create the BOND0 configuration file for the virtual network card under/etc/sysconfig/network-scripts/ ifcfg-bond0, as follows
Device=bond0
Bootproto=none
broadcast=192.168.168.255
ipaddr=192.168.168.1
netmask=255.255.255.0
network=192.168.168.0
Onboot=yes
Type=ethernet
gateway=192.168.168.250
Userctl=no
Then modify the eth0 and eth1 configuration files separately
Ifcfg-eth0 content:
Device=eth0
Bootproto=none
Onboot=yes
Userctl=no
Master=bond0
Slave=yes
Ifcfg-eth1 Content
Device=eth1
Bootproto=none
Onboot=yes
Userctl=no
Master=bond0
Slave=yes
Because the Linux virtual network card is implemented in the kernel module, it needs to be installed when the module is loaded. Add the following in the /etc/modules.conf file (if there is no file, create a new one):
Alias Bond0 Bonding
Options Bond0 miimon=100 mode=1 primary=eth0
Where miimon=100 indicates that the link connection status is checked every 100ms, and if the general switch physical NIC
Mode=1 represents the primary standby mode, that is, only one NIC is active and only provides fail-safe. If the mode=0 is in load-balanced mode, all network cards are active, and some other modes are seldom used to
Primary=eth0 means eth0 as the default active NIC in the primary and Standby mode
Miimon is the number of milliseconds that trigger an event that detects line stability every 100 milliseconds.
Mode is the working state of Ifenslave.
A total of 7 ways:
=0: (BALANCE-RR) round-robin policy: (Balanced whirl cycle strategy): The transmit packet order is transmitted sequentially until the last transmission is complete, which provides load balancing and fault tolerance.
= 1: (active-backup) active-backup policy: (Primary-backup policy): Only one device is active. One goes down and the other immediately transforms the primary device from the backup. The MAC address is externally visible. This mode provides fault tolerance.
= 2: (balance-xor) XOR policy: (Balancing strategy): transmission selects the transmission device according to the original address Boolean value. This mode provides load balancing and fault tolerance.
= 3: (broadcast) broadcast policy: (Broadcast policy): Transfers all packets to all interfaces. This mode provides fault tolerance.
= 4: (802.3AD) IEEE 802.3ad Dynamic link aggregation. IEEE 802.3ad Dynamic Link aggregation: Create an aggregation group that shares the same speed and duplex settings. (I don't really understand.) )
=5: (balance-tlb) Adaptive Transmit load balancing (adapter transport load Balancer): There is no special policy, the first device can not pass through the first device to take over the MAC address that is being processed, help on a pass.
=6: (BALANCE-ALB) Adaptive load Balancing: (Adapter transport load balancer): Roughly means including mode5,bonding driver intercepts requests sent by ARP on the local system, Overwrite the original address of the slave device with one of the hardware addresses. It's like a different person on the server using a different hardware address.
These options can be viewed with the command: # modinfo Bonding
Finally, add in the /etc/rc.local
Modprobe Bonding miimon=100 mode=1
After restarting the machine, you can see that the virtual network card is in effect, you can test it by plugging in the network cable of two physical network cards, but the NIC takes over in Linux for a long time.
From:http://www.360doc.com/content/10/1016/14/1317564_61486325.shtml
====================================================
It should be explained that if you want to load balance, just set here Modprode bonding miimon=100 mode=0 is not enough, also need to set the port of the switch.
From the principle analysis (bond runs under mode 0):
Mode 0 under Bond the IP of the NIC adapter is modified to the same MAC address, if these network cards are connected to the same switch, then the switch ARP table this MAC address corresponds to a number of ports, then the switch accepts to this MAC address of the packet should go to which port forwarding it? Normally the MAC address is the only one in the world, and a MAC address that corresponds to multiple ports definitely confuses the switch.
So mode0 bond If you connect to the switch, these ports of the switch should be aggregated (Cisco is called Ethernetchannel,foundry called PortGroup), since the switches are aggregated, Several ports under aggregation are also bundled into a MAC address
Since there is no three-layer switch at home, the experiment here is left to users to authenticate themselves.
====================================================
Add a line to the/etc/rc.local file:
/root/bonding.sh
bonding.sh File Contents:
#!/bin/sh
Modprobe-r Bonding
Modprobe Bonding miimon=100 mode=6
Ifconfig bond0 172.16.96.46 netmask 255.255.248.0 up
Route add default GW 172.16.100.1 bond0
#ifenslave bond0 eth0 eth1 eth2 eth3 eth4 eth5
Service Network restart
Linux dual-NIC binding bond details-Single network card binding multiple IPs