📄 linux 网络接口配置文件及相关工具 (v0_1b) linuxsir_org.htm
字号:
<P><FONT id=4.1 size=3><B><BR>4.1 Debian
网络接口配置文件和专用配置工具;<BR></B></FONT></P>
<P>正在增加中;</P>
<P><FONT id=4.2 size=3><B><BR>4.2 Redhat/Fedora
网络接口的配置文件和网络接口专用配置工具;<BR></B></FONT></P>
<P>在Redhat/Fedora 中,与乙太网卡相关的配置文件位于 /etc/sysconfig/network-scripts目录中,比如
ifcfg-eth0、ifcfg-eth1 .... .... </P>
<P><FONT id=4.21 size=2><B><BR>4.21 Redhat/Fedora
或类似这样的系统,网卡的配置文件;<BR></B></FONT?< p>
<P>比如在Fedora 5.0中,ifcfg-eth0 ;</P>
<P>如果您用DHCP服务器来自动获取IP的,一般情况下ifcfg-eth0的内容是类似下面这样的;</P>
<P>
<DIV
class=codeblock><CODE>DEVICE=eth0<BR>ONBOOT=yes<BR>BOOTPROTO=dhcp<BR>TYPE=Ethernet</CODE></DIV>
<P></P>
<P>如果您是指定IP的,一般内容是类似下面的;</P>
<P>
<DIV class=codeblock><CODE>DEVICE=eth0 注:网络接口<BR>ONBOOT=yes
注:开机引导时激活<BR>BOOTPROTO=static 注:采用静态IP地址;<BR>IPADDR=192.168.1.238
注:IP地址<BR>NETMASK=255.255.255.0 注:网络掩码;<BR>GATEWAY=192.168.1.1
注:网关;</CODE></DIV>
<P></P>
<P>下面的几个选项也可以利用;</P>
<P>
<DIV class=codeblock><CODE>HOSTNAME=linxsir03
注:指定主机名;<BR>DOMAIN=localdomain 注:指定域名;<BR>HWADDR=00:00:11:22:00:aa
注:指定网卡硬件地址 (MAC地址),
也可以省略,不过这在这里来更改MAC地址一般是不能生效的。还是通过前面所说的ifconfig的办法来更改吧;</CODE></DIV>
<P></P>
<P><FONT id=4.22 size=2><B><BR>4.22 Redhat/Fedora 或类似系统, 配置网络的工具介绍
;<BR></B></FONT></P>
<P>在Redhat早期的版本中, 有linuxconf 、redhat-config-network 、netconfig 等工具;</P>
<P>在Redhat/Fedora 最新的版本有 system-config-network-tui (文本模式的)
、system-config-network (图形模式的),netconfig(文本模式的)。</P>
<P>这些工具都会直接修改Linux系统中关于网络接口的配置文件;这是 ifconfig 所不能比的;</P>
<P>其中 redhat-config-network
和system-config-network工具不仅仅是配置网卡的工具,还有配置ISDN和普通猫、ADSL的工具、网络硬件的添加、主机名字的配置、DNS各客户端的配置等。其实是一个工具组的集成;</P>
<P>这些工具比较简单,以root权限运行命令就能调用,比如:</P>
<P>
<DIV class=codeblock><CODE>[root@localhost ~]#
/usr/sbin/system-config-network<BR>[root@localhost ~]#
system-config-network</CODE></DIV>
<P></P>
<P>如果您设置了可执行命令的环境变量,不用加路径就可以运行,但前提是您得安装这个网络管理工具;</P>
<P><B>不过值得一说的是netconfig
工具是一个在文本模式比较好的工具,推荐大家使用;理由是这个工具在文本模式下,也有一个简单的图形界面;还有命令模式;功能强着呢;</B></P>
<P>
<DIV class=codeblock><CODE>[root@localhost ~]# netconfig -d eth0
注:配置eth0<BR>[root@localhost ~]# netconfig -d eth1 注:配置eth1</CODE></DIV>
<P></P>
<P><FONT id=4.23 size=2><B><BR>4.23 Redhat/Fedora系统中的netconfig
特别介绍;<BR></B></FONT></P>
<P>netconfig这个工具,在Redhat/Fedora
或类似于它们的系统中都是存在的,这个工具比较强大。所以特别介绍一下。但在Slackware中netconfig是TEXT模式下有一个图形模式,但不能象ifconfig一样用命令来操作网卡接口;</P>
<P><B>netconfig 的用法如下:</B></P>
<P>
<DIV class=codeblock><CODE>[root@localhost ~]# netconfig --help
注:帮助;<BR> --bootproto=(dhcp|bootp|none) Boot protocol to
use(<BR> --gateway=STRING Network
gateway(指定网关)<BR> --ip=STRING IP
address(指定IP地址)<BR> --nameserver=STRING
Nameserver(指定DNS客户端)<BR> --netmask=STRING
Netmask(指定网络掩码)<BR> --hostname=STRING Hostname(
指定主机名)<BR> --domain=STRING Domain name(指定域名)<BR> -d,
--device=STRING Network device (指定网络设备)<BR> --nodns No DNS
lookups (没有DNS查询)<BR> --hwaddr=STRING Ethernet hardware address
(指定网卡的物理地址)<BR> --description=STRING Description of the device
(描述性文字)<BR>Help options: (帮助选项)<BR> -?, --help Show this help
message<BR> --usage Display brief usage message</CODE></DIV>
<P></P>
<P><B>实例一:设置网卡的DHCP模式自动获得IP</B></P>
<P>
<DIV class=codeblock><CODE>[root@localhost ~]# netconfig -d eth0
--bootproto=dhcp</CODE></DIV>
<P></P>
<P><B>实例一:手动设置网卡的IP等</B></P>
<P>
<DIV class=codeblock><CODE>[root@localhost ~]# netconfig -d eth0
--ip=192.168.1.33 --netmask=255.255.255.0
--gateway=192.168.1.1</CODE></DIV>
<P></P>
<P><FONT id=4.3 size=3><B><BR>4.3 Slackware网卡配置文件和配置工具;<BR></B></FONT></P>
<P>Slackware 有关网卡的配置文件是/etc/rc.d/rc.inet1.conf ,
这个文件包括乙太网接口的网卡和无线网卡的配置。Slackware 还是比较纯净的,网络配置也较简单;在Slackware中也有netconfig
配置工具,也是text模式运行的,人机交互界面,这个设置比较简单;</P>
<P>Slackware 用netconfig 配置网卡完成后,其实质是修改了/etc/rc.d/rc.inet1.conf
文件。Slackware是源法原味的Linux系统,他的配置文件比较标准 ,所以我推荐您在生产型的系统,不妨尝试一下Slackware ;</P>
<P>配置好网卡后,我们还得运行下面的命令,才能激活网卡;</P>
<P>
<DIV class=codeblock><CODE>[root@localhost ~]#
/etc/rc.d/rc.inet1</CODE></DIV>
<P></P>
<P>下面是一个例子,比如此机器有两个网卡eth0和eth1,eth0用DHCP获得IP地址,eth1指定IP地址;</P>
<P>
<DIV class=codeblock><CODE># Config information for
eth0:<BR>IPADDR[0]=""<BR>NETMASK[0]=""<BR>USE_DHCP[0]="yes"
注:在这里写上yes,表示用DHCP获得IP;<BR>DHCP_HOSTNAME[0]="linuxsir01"
注:DNS服务器主机名,也可以用IP来指定DNS服务器;<BR># Config information for eth1:
注:网卡eth1的配置;<BR>IPADDR[1]="192.168.1.33"
注:指定IP地址;<BR>NETMASK[1]="255.255.255.0" 注:指定掩码;<BR>USE_DHCP[1]="no"
注:不用DHCP获得IP;<BR>DHCP_HOSTNAME[1]=""<BR># Config information for
eth2:<BR>IPADDR[2]=""<BR>NETMASK[2]=""<BR>USE_DHCP[2]=""<BR>DHCP_HOSTNAME[2]=""<BR>#
Config information for
eth3:<BR>IPADDR[3]=""<BR>NETMASK[3]=""<BR>USE_DHCP[3]=""<BR>DHCP_HOSTNAME[3]=""<BR>#
Default gateway IP address:<BR>GATEWAY="192.168.1.1" 注:指定网关;</CODE></DIV>
<P></P>
<P><FONT id=4.4 size=3><B><BR>4.4
SuSE或OpenSuSE网卡配置文件和配置工具;<BR></B></FONT></P>
<P>正在更新之中;</P>
<P><FONT id=5 size=4><B><BR>5、关于拔号工具的介绍;<BR></B></FONT></P>
<P>有的弟兄可能需要ADSL猫和普通猫的拔号工具;现在我们分别介绍一下;</P>
<P><FONT id=5.1 size=3><B><BR>5.1 ADSL pppoe
拔号工具rp-pppoe;<BR></B></FONT></P>
<P>如果您的ADSL不是路由的,如果是路由的,在路由路就能设置好自动拔号。只要把机器接上就能用了,这个咱们不说了,路由器大家都会用;但如果您的ADSL不支持路由,或您想用您当前所用的主机来做路由器;这就需要一个拔号软件;</P>
<P>目前国内大多城市都用的是pppoe协议 ,所以我们有必要介绍 pppoe 拔号软件,在Linux中,这个软件的名字是 rp-pppoe
;</P>
<P><B>rp-pppoe 主页;</B></P>
<P>http://www.roaringpenguin.com/penguin/open_source_rp-pppoe.php</P>
<P><FONT id=5.11 size=2><B><BR>5.11 各大发行版自带的 rp-pppoe
的安装和使用;<BR></B></FONT></P>
<P>rp-pppoe
目前在各大发行版本都是存在的,比如Redhat/Fedora、红旗、Slackware、Debian、SuSE等系统,都是采用这个拔号软件,所以您大可不必为下载源码编译安装。只需要在各大发行版的安装盘中就可以找得到;请用各大发行版自带的软件包管理工具来安装此软件包;</P>
<P><B>* 如果您用的是各大发行版提供的rp-pppoe软件包</B></P>
<P>比如 RPM包的系统是用 rpm -ivh rp-pppoe*.rpm<BR>Slackware 系统是用 installpkg
rp-pppoe*.tgz </P>
<P>在Redhat/Fedora 中可以通过图形配置工具来完成,redhat-config-network
命令,调用配置网络,要通过XDSL来添加拔号,比较简单;</P>
<P>所有发行版通用的方法是adsl-setup 命令来配置ADSL;</P>
<P>
<DIV class=codeblock><CODE>[root@localhost ~]# adsl-setup
注:配置pppoe拔号,请文档下面,都差不多;<BR>[root@localhost ~]# adsl-start
注:启动拔号;<BR>[root@localhost ~]# adsl-stop 注:断开连接;</CODE></DIV>
<P></P>
<P><FONT id=5.12 size=4><B><BR>5.12
如果是源码包安装,我们要自己来编译安装;<BR></B></FONT></P>
<P>
<DIV class=codeblock><CODE>[root@localhost ~]# tar zxvf
rp-pppoe-3.8.tar.gz<BR>[root@localhost ~]# cd
rp-pppoe-3.8<BR>[root@localhost rp-pppoe-3.8]# ./go <BR>Welcome to the
Roaring Penguin PPPoE client setup. First, I will run<BR>some checks on
your system to make sure the PPPoE client is
installed<BR>properly...<BR>Looks good! Now, please enter some
information:<BR>USER NAME<BR>>>> Enter your PPPoE user name
(default bxxxnxnx@sympatico.ca): 在这里添写你的拔号用户名;就是服务商提供的;<BR>>>>
Enter the Ethernet interface connected to the DSL modem<BR>For Solaris,
this is likely to be something like /dev/hme0.<BR>For Linux, it will be
ethn, where 'n' is a number.<BR>(default eth0): eth0
如果是乙太接口的ADSL,就要在这里写上接猫的那个网络接口号。此处是eth0;<BR>Do you want the link to come up
on demand, or stay up continuously?<BR>If you want it to come up on
demand, enter the idle time in seconds<BR>after which the link should be
dropped. If you want the link to<BR>stay up permanently, enter 'no' (two
letters, lower-case.)<BR>NOTE: Demand-activated links do not interact well
with dynamic IP<BR>addresses. You may have some problems with
demand-activated links.<BR>>>> Enter the demand value (default
no): 注:默认回车<BR>>>> Enter the DNS information here: 202.96.134.133
注:在这里写上DNS服务器地址;可以和提供商要,也可以用我写的这个;<BR>Please enter the IP address of your
ISP's secondary DNS server.<BR>If you just press enter, I will assume
there is only one DNS server.<BR>>>> Enter the secondary DNS
server address here: 202.96.128.143 这是第二个DNS服务器地址;<BR>>>> Please
enter your PPPoE password:在这里输入用户的密码;<BR>>>> Please re-enter your
PPPoE password: 确认密码;<BR>The firewall choices are:<BR>0 - NONE: This
script will not set any firewall rules. You are
responsible<BR> for
ensuring the security of your machine. You are
STRONGLY<BR> recommended
to use some kind of firewall rules.<BR>1 - STANDALONE: Appropriate for a
basic stand-alone web-surfing workstation<BR>2 - MASQUERADE: Appropriate
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -