网卡配置
網(wǎng)卡配置文件
(1)/etc/sysconfig/network-scripts/ifcfg-interface-name
配置文件ifcfg-interface-name包含了初始化接口所需的大部分詳細信息。其中interface-name將根據(jù)網(wǎng)卡的類型和排序而不同,一般其名字為eth0、eth1、ppp0等,其中eth表示以太(eth0)類型網(wǎng)卡,0表示第一塊網(wǎng)卡,1表示第二塊網(wǎng)卡,而ppp0則表示第一個point-to-poirt protocol網(wǎng)絡(luò)接口。在ifcfg文件中定義的各項目取決于接口類型。下面的值較問常見:
》DEVICE=name ,其中,name是物理設(shè)備名。
》IPADDR=addr,其中,addr是IP地址。
》NETMASK=mask,其中,mask是網(wǎng)絡(luò)掩碼值。
》NETWORK=addr,其中addr是網(wǎng)絡(luò)地址。
》BROADCAST=addr,其中,addr是廣播地址。
》GATEWAY=addr,其中addr是網(wǎng)關(guān)地址。
》ONBOOT=answer,其中,answer是yes(引導(dǎo)時激活設(shè)備)或no(引導(dǎo)時不激活設(shè)備)
》USERCTL=answer,其中,answer是yes(非root用戶可以控制該設(shè)備)或no
》BOOTPROTO=proto,其中,proto取下列值之一:none,引導(dǎo)時不使用協(xié)議;static靜態(tài)分配地址;bootp,使用BOOTP協(xié)議,或dhcp,使用DHCP協(xié)議。
(2)根據(jù)上述各參數(shù)的意義,設(shè)定linpcl.lintec.edu.cn機器的設(shè)置文件如下:
[root@linpcl root]#cat /etc/sysconfig/networking/devices/ifcfg-rth0
DEVICE=eth0 www.2cto.com
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.0.2
NETMASK=255.255.255.0
GATEWAY=192.168.0.1
(3)參數(shù)配置完畢后保存文件,并使用/etc/init.d/network restart命令重啟網(wǎng)絡(luò)設(shè)備,最新設(shè)值即可生效。
[root@linpcl root]# /etc/rc.d/init.d/network restart
正在關(guān)閉接口 eth0: [確定]
關(guān)閉環(huán)回接口: [確定]
設(shè)置網(wǎng)絡(luò)參數(shù): [確定]
彈出環(huán)回接口: [確定]
彈出界面eth0: [確定]
(4)使用ifconfig命令查看網(wǎng)絡(luò)設(shè)備狀況。
[root@linpcl root]# ifconfig
eth0 Link encap: Ethernet HWassr 52:54:AB:28:EE:37
linet addr:192.168.0.2 bcast:192.168.0.255 Mask:255.255.255.0
(還有一些參數(shù)文件自動顯示,在此省略)。。。
禁用網(wǎng)卡:
ifconfig eth0 down
永久禁用,就要修改一下配置文:件了。
==================================================================================
[root@Linux root]#cd /etc/sysconfig/network-scripts
[root@Linux network-scripts]#vi ifcfg-eth0
DEVICE=eth0 =====
BOOTPROTO=static
BROADCAST=192.168.80.255 //*廣播地址*//
IPADDR=192.168.80.189 //*第一個IP地址*//====
NETMASK=255.255.255.0 //*網(wǎng)絡(luò)掩碼*//
GATEWAY=121.2.0.100 //其中addr是網(wǎng)關(guān)地址。
ONBOOT=yes
:wq //*保存退出*//
2、復(fù)制第一個IP地址配置文件為第二個IP地址配置文件,并修改里面的IP地址:
[root@Linux network-scripts]#cp ifcfg-eth0 ifcfg-eth0:1
[root@Linux network-scripts]#vi ifcfg-eth0:1
DEVICE=eth0:1 //*區(qū)別于第一個網(wǎng)卡ip*//====
BOOTPROTO=static -------
BROADCAST=192.168.80.255 //*廣播地址*//
IPADDR=192.168.80.199 //*第二個IP地址*//---------
NETMASK=255.255.255.0 //*網(wǎng)絡(luò)掩碼*// -------
ONBOOT=yes -----
:wq //*保存退出*//
3、重啟網(wǎng)卡:
[root@Linux network-scripts]#service network restart
或:
[root@Linux network-scripts]#ifdown eth0
[root@Linux network-scripts]#ifup eth0
或
[root@Linux network-scripts]#ifconfig eth0 down
[root@Linux network-scripts]#ifconfig eth0 up
好了,這下兩個ip都通了。
其實說白了,就是把網(wǎng)卡配置文件復(fù)制一份,然后修改其中ip地址以及網(wǎng)關(guān),搞清楚了原理,在圖型界面操作更方便。
?
?
轉(zhuǎn)載于:https://www.cnblogs.com/chenshoubiao/p/4606366.html
總結(jié)
- 上一篇: Eclipse的环境设置
- 下一篇: 原百万访问量博客http://blog.