Chinaunix首页 | 论坛 | 博客
  • 博客访问: 46071
  • 博文数量: 10
  • 博客积分: 346
  • 博客等级: 入伍新兵
  • 技术积分: 100
  • 用 户 组: 普通用户
  • 注册时间: 2010-08-08 12:37
文章分类
文章存档

2014年(1)

2010年(9)

分类:

2010-08-09 16:05:52


在虚拟机上给一个网卡分配多个IP地址(临时)

     先查看我的网卡信息

[root@localhost ~]# ifconfig

eth0      Link encap:Ethernet  HWaddr 00:0C:29:79:AB:A4

          inet addr:192.168.1.106  Bcast:255.255.255.255  Mask:255.255.255.0

          inet6 addr: fe80::20c:29ff:fe79:aba4/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:5132 errors:0 dropped:0 overruns:0 frame:0

          TX packets:1887 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:416347 (406.5 KiB)  TX bytes:236454 (230.9 KiB)

          Interrupt:67 Base address:0x2000

 

lo        Link encap:Local Loopback

          inet addr:127.0.0.1  Mask:255.0.0.0

          inet6 addr: ::1/128 Scope:Host

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

 

其中lo是本地回环,eth0是物理网卡,而我只有一个

     分配IP地址

[root@localhost ~]# [root@localhost ~]# ifconfig eth0:0 192.168.1.107

或者

[root@localhost ~]# ifconfig eth0:0 192.168.1.107 netmask 255.255.255.0 up

在不指定netmask的情况下,如上面第一种,系统会默认;

对于A类私有IP地址,系统默认为255.0.0.0

对于B类私有IP地址,系统默认为255.255.0.0

对于C类私有IP地址,系统默认为255.255.255.0

对于这种设定IP地址的方法,当重启网络服务时,就会消失

     重启网络服务

[root@localhost ~]# service network restart

正在关闭接口 eth0                                        [确定]

关闭环回接口:                                             [确定]

弹出环回接口:                                             [确定]

弹出界面 eth0

正在决定 eth0 IP 信息...完成。

                                                           [确定]

 

或者

[root@localhost ~]# /etc/init.d/network restart

正在关闭接口 eth0                                        [确定]

关闭环回接口:                                             [确定]

弹出环回接口:                                             [确定]

弹出界面 eth0

正在决定 eth0 IP 信息...完成。

                                                           [确定]

注:系统服务的所有脚本都在/etc/init.d目录下

 netsniper11yin                                                                2010.08.7

阅读(2840) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~