Mar 1

linux下单网卡设双IP 不指定

ouwsh , 20:18 , Linux/Unix相关 , 评论(0) , 引用(0) , 阅读(2468) , Via 本站原创 | |
1.进入目录:
[root@dfxg root]# cd /etc/sysconfig/network-scripts/

2:ifcfg-eh0:0中的eh0:0是网卡的代号,当然你也可以用eh0:1之类的,随你喜欢怎么弄,但在eh0:X之前必须有ifcfg,也就是下面这种形式的,我们以eh0:0为例。

[root@dfxg root]#cp ifcfg-eth0 ifcfg-eth0:0

3,编辑ifcfg-eth0:0
[root@Linuxsir root]# vi ifcfg-eth0:0

ifcfg-eth0:0里面有这样的内容,你可以这样设置,然后IP可以自己设置了。象我这样设置也一样。

# Please read /usr/share/doc/initscripts-*/sysconfig.txt
# for the documentation of these parameters.
USERCTL='no'
NETMASK='255.255.255.0' -》子掩码
BOOTPROTO='static' -》协议
DEVICE='eth0:0' -》虚拟网卡的代号
IPADDR='192.168.0.9' -》我自己设定的IP
TYPE='Ethernet'
ONBOOT='yes' -》是否开机激活
NETWORK='192.168.0.0' -》网域
BROADCAST='192.168.0.255' -》广播

4.保存退出,然后运行如下的命令,来激活虚拟的网卡。
[root@dfxg root]# ifup eh0:0


---------------------------------------------
临时办法:
ifconfig eth0:0 192.168.1.1 netmask 255.255.255.0
重启就没了。

永久办法:
# cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:0
vi ifcfg-eth0:0,修改IP,其它不变。
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]