Temporarily add IP command: ifconfig eth0:1 IP address netmask Subnet code broadcast broadcast address gateway Gateways
Ifconfig eth0:1 10.1.104.65 netmask 255.255.255.0 broadcast 10.1.104.255 Gateway 10.1.104.11
Note: eth0 is the first network card, the other is eth1,eth*,eth0:x (x is 0-255 for example eth0:0 or eth0:1, etc.), eth0:x is called the virtual network interface, is built on the network pretext (eth0) top.
Use Ifconfig to see if the new IP has been added.
Static methods
Note: All operations are using the root user
Modify IP:
Edit File/etc/sysconfig/network-scripts/ifcfg-eth0
Device=eth0//device name, do not modify
Bootproto=static//Do not modify
BROADCAST=10.10.22.255//broadcast address, typically the last IP of the network segment
ipaddr=10.10.22.145//IP Address
netmask=255.255.255.0//Subnet mask
network=10.10.22.0//Network segment Address
Onboot=yes//Do not modify
Type=ethernet//Do not modify
Note: Ifcfg-eth0 is the first NIC, Ifcfg-eth1 is the second NIC, and so on
Add IP:
You can recompile a file with a file name of/etc/sysconfig/network-scripts/ifcfg-eth0:0
can also be added directly in/etc/sysconfig/network-scripts/ifcfg-eth0 (but the device eth0 must have)
device=eth0:0//device name, do not modify
Bootproto=static//Do not modify
BROADCAST=10.10.33.255//broadcast address, typically the last IP of the network segment
ipaddr=10.10.33.145//IP Address
netmask=255.255.255.0//Subnet mask
network=10.10.33.0//Network segment Address
Onboot=yes//Do not modify
Type=ethernet//Do not modify
And so on, if you add another IP, add the following configuration:
Device=eth0:1//device name, do not modify
Bootproto=static//Do not modify
BROADCAST=10.10.44.255//broadcast address, typically the last IP of the network segment
ipaddr=10.10.44.145//IP Address
netmask=255.255.255.0//Subnet mask
network=10.10.44.0//Network segment Address
Onboot=yes//Do not modify
Type=ethernet//Do not modify
Also if on the second NIC, you need to add:
device=eth1:0//device name, do not modify
Bootproto=static//Do not modify
BROADCAST=10.10.33.255//broadcast address, typically the last IP of the network segment
ipaddr=10.10.33.145//IP Address
netmask=255.255.255.0//Subnet mask
network=10.10.33.0//Network segment Address
Onboot=yes//Do not modify
Type=ethernet//Do not modify
To increase the default gateway method:
Note that a machine can have only one default gateway, otherwise it should be given a specific routing method.
Add one item to the associated device configuration, for example, in the above configuration, add a default gateway to the first IP of the first network card:
Device=eth0
Bootproto=static
broadcast=10.10.22.255
ipaddr=10.10.22.145
netmask=255.255.255.0
network=10.10.22.0
Onboot=yes
Type=ethernet
gateway=10.10.22.3
After the modification is complete, you need to restart the machine or restart the network for the above changes to take effect.
The way to restart the machine is:Reboot
The way to restart the network is: Service network restart
The above is a static method to increase the IP, that is, the method is still valid after the machine restarts.
Dynamic methods
Note: All operations are using the root user
Modify IP:
Ifconfig eth0 10.10.22.145
The IP of the first net card is changed to 10.10.22.145 directly.
Add IP:
Ifconfig eth0 Add 10.10.33.145//Add an IP
Ifconfig eth0:0 Broadcast 10.10.33.255//modify the broadcast address of the IP just added
Add one more IP:
Ifconfig eth0:0 Add 10.10.44.145
Ifconfig eth0:0:1 Broadcast 10.10.44.255//modify the broadcast address of the IP just added
Never do the following:
Ifconfig eth0 Add 10.10.44.145
So we can change the IP10.10.33.145 just to 10.10.44.145.
Add one more IP:
Ifconfig eth0:0:1 Add 10.10.55.145
Ifconfig eth0:0:1:1 Broadcast 10.10.55.255//modify the broadcast address of the IP just added
In turn
The above additions will take effect immediately, but after the machine restarts, it is invalid.
Turn from
Linux Modify, add IP method, a network card bound multiple ip/drift IP
Http://www.360doc.com/content/12/0223/00/7313939_188780792.shtml
Linux Modify, add IP method, a network card bound multiple ip/drift IP "turn"