Linux系统下怎么加IP呢?服务器租用商usa-idc下面以Cent OS 5.5 版本系统为例,说明下怎么加IP的。
1、进入网卡配置所在文件:
[root@www.usa-idc.com ~]# cd /etc/sysconfig/network-scripts/ (提示:这个路径会因Linux版本不同有所不同)
[root@www.usa-idc.com network-scripts]#
2、查看网卡配置文件,并复制一个新文件,下面红色的就是网卡配置文件。
[root@www.usa-idc.com network-scripts]# ls
ifcfg-eth0 ifdown-ipv6 ifdown-tunnel ifup-ipv6 ifup-routes network-functions
ifcfg-lo ifdown-isdn ifup ifup-ipx ifup-sit network-functions-ipv6
ifdown ifdown-post ifup-aliases ifup-isdn ifup-sl
ifdown-bnep ifdown-ppp ifup-bnep ifup-plip ifup-tunnel
ifdown-eth ifdown-routes ifup-eth ifup-plusb ifup-wireless
ifdown-ippp ifdown-sit ifup-ippp ifup-post init.ipv6-global
ifdown-ipsec ifdown-sl ifup-ipsec ifup-ppp net.hotplug
[root@www.usa-idc.com network-scripts]# cp ifcfg-eth0 ifcfg-eth0:1
3、用vi命令编辑复制的新文件,如现在的IP是192.168.1.89,需要新加的IP是192.168.1.90,下面红色的地方就是修改过的地方。
[root@www.usa-idc.com network-scripts]# vi ifcfg-eth0:1
# Intel Corporation 82540EM Gigabit Ethernet Controller
DEVICE=eth0:1
BOOTPROTO=static
BROADCAST=192.168.1.255
HWADDR=08:00:27:23:E9:86
IPADDR=192.168.1.90
NETMASK=255.255.255.0
NETWORK=192.168.1.0
ONBOOT=yes
4、按esc键,按:键,输入wq保存退出,重启网卡(service network restart),至此,一个IP就加好了。
[root@www.usa-idc.com network-scripts]# service network restart
正在关闭接口 eth0: [确定]
关闭环回接口: [确定]
弹出环回接口: [确定]
弹出界面 eth0: [确定]
[root@www.usa-idc.com network-scripts]# ifconfig
eth0 Link encap:Ethernet HWaddr 08:00:27:23:E9:86
inet addr:192.168.1.89 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe23:e986/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:8760 errors:0 dropped:0 overruns:0 frame:0
TX packets:1334 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3682711 (3.5 MiB) TX bytes:116492 (113.7 KiB)
eth0:1 Link encap:Ethernet HWaddr 08:00:27:23:E9:86
inet addr:192.168.1.90 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1