学习 Linux (二)

连上网际网路 (Connect to Internet !)

装好了 Linux, 开开心心的输入你的登入帐号和密码, 预设帐号请输入 "root" 而密码则是在安装时期所指定的密码 (不知是否还记得 ?!) . 现在你一定会移动你的滑鼠东点西点, 看看这到底是什么东西, 有什么新奇、好玩的。

现在, 请先做一个东西, 那就是 "连上网路". 嗯, 如果你是使用固定的网路 IP, 或许在安装期间已经设定好了, 马上迫不及待的点选 Panel 上的 "Mozilla (魔斯拉)"。喔, 如果使用的是 ADSL 拨接制的朋友们那怎么办呢? 没有关系, 接下来就要带入你设定 ADSL 了。

首先, 在桌面上点一下右键 (滑鼠啦 ~ 难道会是键盘吗 ?! ), 选取 "开启终端机视窗", 好, 现在就会跑出一个画面出来, 可别让这画面吓到了, 现在不熟没有关系, 我将带你如何设定 ADSL 拨接到 Internel。


终端机画面

好, 现在接下来的步骤, 白色粗体字表示要输入的字请一步一步跟著做, 如果是 <return> 则表示直接按下键盘上的 [Enter] 。

[root@nbcentos ~]# adsl-setup

Welcome to the ADSL client setup. First, I will run some checks on
your system to make sure the PPPoE client is installed properly...



LOGIN NAME
Enter your Login Name (default root): 84761000@hinet.net

INTERFACE

Enter the Ethernet interface connected to the ADSL modem
For Solaris, this is likely to be something like /dev/hme0.
For Linux, it will be ethX, where 'X' is a number.
(default eth0):<return>

Do you want the link to come up on demand, or stay up continuously?
If you want it to come up on demand, enter the idle time in seconds
after which the link should be dropped. If you want the link to
stay up permanently, enter 'no' (two letters, lower-case.)
NOTE: Demand-activated links do not interact well with dynamic IP
addresses. You may have some problems with demand-activated links.
Enter the demand value (default no):<return>

DNS

Please enter the IP address of your ISP's primary DNS server.
If your ISP claims that 'the server will provide dynamic DNS addresses',
enter 'server' (all lower-case) here.
If you just press enter, I will assume you know what you are
doing and not modify your DNS setup.
Enter the DNS information here:<return>

PASSWORD

Please enter your Password: 123456789 <= 这个密码在画面上并不会显示出来
Please re-enter your Password:123456789 <= 这个密码在画面上并不会显示出来

USERCTRL

Please enter 'yes' (two letters, lower-case.) if you want to allow
normal user to start or stop DSL connection (default yes):<return>

FIREWALLING

Please choose the firewall rules to use. Note that these rules are
very basic. You are strongly encouraged to use a more sophisticated
firewall setup; however, these will provide basic security. If you
are running any servers on your machine, you must choose 'NONE' and
set up firewalling yourself. Otherwise, the firewall rules will deny
access to all standard servers like Web, e-mail, ftp, etc. If you
are using SSH, the rules will block outgoing SSH connections which
allocate a privileged source port.

The firewall choices are:
0 - NONE: This script will not set any firewall rules. You are responsible
for ensuring the security of your machine. You are STRONGLY
recommended to use some kind of firewall rules.
1 - STANDALONE: Appropriate for a basic stand-alone web-surfing workstation
2 - MASQUERADE: Appropriate for a machine acting as an Internet gateway
for a LAN
Choose a type of firewall (0-2): 0

Start this connection at boot time

Do you want to start this connection at boot time?
Please enter no or yes (default no):yes

** Summary of what you entered **

Ethernet Interface: eth0
User name: 84761000@hinet.net
Activate-on-demand: No
DNS: Do not adjust
Firewalling: NONE
User Control: yes
Accept these settings and adjust configuration files (y/n)? y
Adjusting /etc/sysconfig/network-scripts/ifcfg-ppp0
Adjusting /etc/ppp/chap-secrets and /etc/ppp/pap-secrets
(But first backing it up to /etc/ppp/chap-secrets.bak)
(But first backing it up to /etc/ppp/pap-secrets.bak)



Congratulations, it should be all set up!

Type '/sbin/ifup ppp0' to bring up your xDSL link and '/sbin/ifdown ppp0'
to bring it down.
Type '/sbin/adsl-status /etc/sysconfig/network-scripts/ifcfg-ppp0'
to see the link status.

[root@nbcentos ~]#


 

好了, 那么现在已经设定好 ADSL, 那要如何才可以马上拨接使用呢? 别急, 接下来的步骤就是要拨接了 !
[root@nbcentos ~]# adsl-start
[root@nbcentos ~]#

喔 ~ 没有讯号出来, 嗯, 没错, 就是没有任何讯号 (No news is good news ^^). 如果不放心, 那么就来看看是否真的有得到 IP 吧 !

[root@nbcentos ~]# ifconfig ppp0
ppp0 Link encap:Point-to-Point Protocol
inet addr:220.136.80.204 P-t-P:218.166.144.254 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1492 Metric:1
RX packets:19 errors:0 dropped:0 overruns:0 frame:0
TX packets:27 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:2244 (2.1 KiB) TX bytes:1763 (1.7 KiB)

[root@nbcentos ~]#

只要看到那个 addr: 有数字就 OK 了! 当然因为是拨接制的, 所以每次都不会一样.

安全措施 - 防火墙

如果你有使用网路一段不短经验, 那么你一定会认同我的话 - 网路是个危险的地方.

以往 (很久以前) 上网是因为方便, 而网路上的坏人也没有很多, 但是在宽频的普及下, 越来越多人的电脑变成跳版, 不是被入侵破坏系统就是被人家拿来做侵攻击别人的跳板.不相信吗, 这是真的, 现今的网路环境, 就算你不去碰别人, 也会看到你的电脑被一堆不知名的 "人士" 们不段的扫描 ... 也就是说, 就算你呆呆的坐在那里, 不做任何事, 但只要一连上网路, 那么你就马上变成别人扫描的对象了 !

编 辑防火墙条件

首先, 如果我想要各位人兄一开始就使用 vi 这种工具来编辑, 那么我想应该有很多人马上就关了本篇了, 所以我现在是想要各位移动滑鼠, 然后再 "应用程式 > 附属应用程式 > 文字编辑器" 开启这个 gedit 的文字编辑程式, 如果找不到, 没关系, 还记得怎么开终端机视窗吗 ? 开起来, 然后输入 gedit 就好了。

好了, 那么现在开启旧档, 选择档案为 /etc/rc.d/rc.local

再来, 大家先不要管以下是什么东西, 请先全部都复 制起来, 然后把它贴到这个 rc.local 的最后面

# 清除所有规则
iptables -F
#把计数器规零
iptables -Z
#清除自订 chain
iptables -X

##指定预设 policy
#封包可以 OUTPUT
iptables -P OUTPUT ACCEPT
#封包不可以 INPUT
iptables -P INPUT DROP
#封包不可以 FORWARD
iptables -P FORWARD DROP

#允许本机 lo 介面可以使用
iptables -A INPUT -i lo -j ACCEPT

##指定特定规则
#已连线的封包可以连入
iptables -A INPUT -i ppp0 -m state --state ESTABLISHED,RELATED -j ACCEPT

贴完之后应该会像这样子:

好了, 现在按下 "储存" 就 OK 了!

重 新读取系统设定档

现在, 请再开启一次 (如果您还没关掉, 那么还可以继续使用) 终端机视窗, 输入 "source /etc/rc.d/rc.local" 就可以了。如果再不知道怎么做, 没关系, 那么请重新开吧, 所有设定值都会直接套用的 !

网路工具

这个小节介绍一些网路的小工具, 可以帮助您使用网际网路。

  • gftp - 这个就是用来当作 FTP Client 软体的工具啦, 可以用这个来连到 FTP 喔!

  • Mozilla, Mozilla Firefox - 同属於 Mozilla 基金会的浏览器软体!

  • Gaim - 用来登入 MSN, ICQ, Yahoo Messenger ... 等 IM 软体.

  • Evolution, Thunderbird - 就是收信软体罗 ~ 看起来是不是和某个 "向外看" 很像呢 ^^

04/03/2005

Index