📄 0130internet_connect.htm
字号:
<li><font color="#000066" face="SimSun">主机名称为:   redhat9.vbird.net</font></li><li><font color="#000066" face="SimSun">DNS 设定为:   168.95.1.1</font></li></ul> <br><font color="#000000" face="SimSun">而连上 Internet 的方法只有几个步骤:</font><br><font color="#000000" face="SimSun"> </font><br><font color="#000066" face="SimSun">(1)设定主机名称与预设通讯闸;</font><br><font color="#000066" face="SimSun">(2)设定网络参数( IP, netmask,broadcast, Network 等等 );</font><br><font color="#000066"><font face="SimSun">(3)设定 DNS 服务器的 IP (</font>您<font face="SimSun">的ISP 给的 );</font></font><br><font color="#000066" face="SimSun">(4)重新启动网络设备。</font><br><font color="#000000" face="SimSun"> </font><br><font color="#000000" face="SimSun">这样就够了!您当然可以使用手动指令设定上面的参数,不过需要ifconfig, route 等等指令的下达,有点讨厌就是了!所以这里我们以档案设定的方式来设定网络参数喔!</font><br><font color="#000000" face="SimSun"> </font><ol><li><font color="#000099" face="SimSun">/etc/sysconfig/network ( 设定主机名称与default gateway )</font></li><table bgcolor="#000000" border="1" cols="1" width="550"><tbody><tr><td><font size="-1" face="SimSun"><font color="#ffffff">[root@testroot]# </font><font color="#ffff00">vi /etc/sysconfig/network</font></font><br><font size="-1" color="#ffff00" face="SimSun">NETWORKING=yes</font><br><font size="-1" color="#ffff00" face="SimSun">HOSTNAME=redhat9.vbird.net</font></td></tr></tbody></table><font face="SimSun"> </font><li><font color="#000099" face="SimSun">/etc/sysconfig/network-scripts/ifcfg-eth0( 设定网络卡参数 )</font></li><table bgcolor="#000000" border="1" cols="1" width="550"><tbody><tr><td><font size="-1" face="SimSun"><font color="#ffffff">[root@testroot]#</font><font color="#ffff00"> vi /etc/sysconfig/network-scripts/ifcfg-eth0</font></font><br><font size="-1" color="#ffff00" face="SimSun">DEVICE=eth0</font><br><font size="-1" color="#ffff00" face="SimSun">ONBOOT=yes</font><br><font size="-1" color="#ffff00" face="SimSun">BOOTPROTO=static</font><br><font size="-1" color="#ffff00" face="SimSun">IPADDR=192.168.1.13</font><br><font size="-1" color="#ffff00" face="SimSun">NETMASK=255.255.255.0</font><br><font size="-1" color="#ffff00" face="SimSun">NETWORK=192.168.1.0</font><br><font size="-1" color="#ffff00" face="SimSun">BROADCAST=192.168.1.255</font><br><font size="-1" color="#ffff00" face="SimSun">GATEWAY=192.168.1.2</font></td></tr></tbody></table><font face="SimSun"> </font><li><font color="#000099" face="SimSun">/etc/resolv.conf ( 设定 DNS 主机的IP )</font></li><table bgcolor="#000000" border="1" cols="1" width="500"><tbody><tr><td><font size="-1" face="SimSun"><font color="#ffffff">[root@testroot]# </font><font color="#ffff00">vi /etc/resolv.conf</font></font><br><font size="-1" color="#ffff00" face="SimSun">nameserver168.95.1.1</font><br><font size="-1" color="#ffff00" face="SimSun">nameserver139.175.10.20</font></td></tr></tbody></table><font face="SimSun">我们以中华电信与 SeedNet 在南部的 DNS 主机之 IP 作为设定的方式!请注意一下,如果您不知道</font>您<font face="SimSun">的最接近的DNS 主机的 IP ,那么直接输入 nameserver 168.95.1.1 这个中华电信的 DNS 主机即可!</font><br><font face="SimSun"> </font><li><font color="#000099" face="SimSun">重新启动网络设定:</font></li><br><font face="SimSun"><font color="#000000">因为我们更动过 /etc/sysconfig/network这个档案,所以最好以『network restart』来启动较好,</font><font color="#000066">有时候甚至需要reboot 才能让主机名称生效呢</font><font color="#000000">!不过,如果仅是要测试网络卡的话,使用ifup 即可!</font></font><table bgcolor="#000000" border="1" cols="1" width="500"><tbody><tr><td><font size="-1" face="SimSun"><font color="#ffffff">[root@testroot]#</font><font color="#ffff00"> /etc/rc.d/init.d/network restart</font></font><br><font size="-1" face="SimSun"><font color="#ffffff">[root@testroot]# </font><font color="#ffff00">ifdown eth0</font></font><br><font size="-1" face="SimSun"><font color="#ffffff">[root@testroot]#</font><font color="#ffff00"> ifup   eth0</font></font></td></tr></tbody></table>到这一步骤就算成功啦!使用 ping 试看看能否成功喔!<br><font color="#000000" face="SimSun"> </font></ol></ul> <font color="#000000" face="SimSun">使用固定 IP 的上网方式设定其实较为简便,这些步骤要记熟啊!因为未来会常常做这方面的操作喔!</font><br><font color="#000000" face="SimSun"> </font><br><hr width="100%"><a name="connect_cable"></a><font size="+1" color="#000099">CableModem 上网方式</font><br><font color="#000000" face="SimSun"> </font><br>在 Linux 上设定以 Cable 魔电( Modem )来上网是最简单的事了!因为他是透过所谓的DHCP 协议来直接分配 IP 与相关的网络参数给 Linux 的,所以,我们几乎所有的网络参数都不需要设定呢!只要设定启动网络卡时候,选择的启动协议为dhcp 就可以了!不过,如果主机端没有给我们 DNS 的 IP 与主机名称的时候,还是需要设定的啦!^_^<br> <ol><li><font color="#000099" face="SimSun">/etc/sysconfig/network ( 设定主机名称与default gateway )</font></li><table bgcolor="#000000" border="1" cols="1" width="500"><tbody><tr><td><font size="-1" face="SimSun"><font color="#ffffff">[root@testroot]# </font><font color="#ffff00">vi /etc/sysconfig/network</font></font><br><font size="-1" color="#ffff00" face="SimSun">NETWORKING=yes</font><br><font size="-1" color="#ffff00" face="SimSun">HOSTNAME=redhat9.vbird.net</font></td></tr></tbody></table><font face="SimSun"> </font><li><font color="#000099" face="SimSun">/etc/sysconfig/network-scripts/ifcfg-eth0( 设定网络卡参数 )</font></li><table bgcolor="#000000" border="1" cols="1" width="500"><tbody><tr><td><font size="-1" face="SimSun"><font color="#ffffff">[root@testroot]#</font><font color="#ffff00"> vi /etc/sysconfig/network-scripts/ifcfg-eth0</font></font><br><font size="-1" color="#ffff00" face="SimSun">DEVICE=eth0</font><br><font size="-1" color="#ffff00" face="SimSun">ONBOOT=yes</font><br><font size="-1" face="SimSun"><font color="#ffff00">BOOTPROTO=dhcp </font><font color="#ff6666"> <==这一行设定正确即可!下面的四个网络参数没有用!</font></font><br><font size="-1" color="#ff6666" face="SimSun"> 需要留意的是,在 Openlinux 里面,这里的设定</font><br><font size="-1" face="SimSun"><font color="#ff6666"> 为 </font><font color="#ffffcc">DYNAMIC=dhcp</font><font color="#ff6666">喔!</font></font><br><font size="-1" color="#ffff00" face="SimSun">IPADDR=192.168.1.13</font><br><font size="-1" color="#ffff00" face="SimSun">NETMASK=255.255.255.0</font><br><font size="-1" color="#ffff00" face="SimSun">NETWORK=192.168.1.0</font><br><font size="-1" color="#ffff00" face="SimSun">BROADCAST=192.168.1.255</font></td></tr></tbody></table><font face="SimSun"> </font><li><font color="#000099" face="SimSun">/etc/resolv.conf ( 设定 DNS 主机的IP )</font></li><table bgcolor="#000000" border="1" cols="1" width="500"><tbody><tr><td><font size="-1" face="SimSun"><font color="#ffffff">[root@testroot]#</font><font color="#ffff00"> vi /etc/resolv.conf</font></font><br><font size="-1" color="#ffff00" face="SimSun">nameserver168.95.1.1</font><br><font size="-1" color="#ffff00" face="SimSun">nameserver139.175.10.20</font></td></tr></tbody></table><font face="SimSun">这个设定<font color="#000066">有时候会被主动的改变</font>,这是因为来自于dhcp 主机的设定所致!所以,如果被改变时,请不要讶异!详细的 DHCP 说明请参考后面章节的<a href="http://linux.vbird.org/linux_server/0340dhcp.php">DHCP服务器设定</a>喔!</font><br><font face="SimSun"> </font><li><font color="#000099" face="SimSun">重新启动网络设定:</font></li><table bgcolor="#000000" border="1" cols="1" width="500"><tbody><tr><td><font size="-1" face="SimSun"><font color="#ffffff">[root@testroot]#</font><font color="#ffff00"> /etc/rc.d/init.d/network restart</font></font><br><font size="-1" face="SimSun"><font color="#ffffff">[root@testroot]# </font><font color="#ffff00">ifdown eth0</font></font><br><font size="-1" face="SimSun"><font color="#ffffff">[root@testroot]# </font><font color="#ffff00">ifup   eth0</font></font></td></tr></tbody></table>当然,直接 reboot 也是可以啦!</ol> <br>设定 Cable modem 就是这么简单喔!<br> <br><hr width="100%"><a name="connect_adsl"></a><font size="+1" color="#000099">ADSL拨接上网方式</font><br> <br>好了,终于提到最热门的 ADSL 拨接制的上网方式啰!嗯!来谈一谈怎么在Linux 上拨接上网吧!在 Linux 系统中,要以 ADSL 连上 Internet 是一件很简单的事情,使用<a href="http://www.roaringpenguin.com/pppoe/" target="_blank">rp-pppoe( http://www.roaringpenguin.com/pppoe/ )</a> 软件就可以进行拨接了!安装也很方便喔!再来要注意的是,在目前的Linux 版本当中,由于强调桌上型计算机的便利性,所以很多版本的 Linux 都取消了文字接口下的ADSL 拨接指令,例如 Red Hat 新版的 Linux 。所以在预设的状态下,我们仅能以图形接口启动ADSL ,这真的很讨厌,因为我们的主机就是不想要启用 X Window 的啊!怎么办?没关系,我们可以透过重新安装rp-pppoe 就行啦!我们提过在 Linux 的安装方式主要有 <a href="http://linux.vbird.org/linux_basic/0520rpmtarball.php">RPM与 Tarball</a> 两种方式,目前鸟哥已经成功的在 Red Hat 7.2 上面安装 <a href="http://linux.vbird.org/download/index.php#rp-pppoe">rp-pppoe-2.6-5.src.rpm</a>这个版本的 rp-pppoe 啰!然而由于很多时候 RPM 有相依属性的问题,因此我们也尝试以Tarball 来安装一下 rp-pppoe 吧!( 注:如果依旧无法以 RPM 安装 rp-pppoe时,请直接以 Tarball 来安装吧! )<br> <br>此外,需要特别留意的是,原本 Linux 主机上面就会有 eth0 这个网络卡接口,不过在使用rp-pppoe 拨接之后,会多产生了一个对外的接口,称为 ppp0 的这个网络联机接口,因此,您将具有三个网络接口喔!分别是:<br> <ol><li><font color="#000066">内部循环测试用的lo接口;</font></li><li><font color="#000066">网络卡 eth0 这个接口;</font></li><li><font color="#000066">拨接之后产生的经由 ISP 对外连接的 ppp0 接口。</font></li></ol>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -