在RedHat7.2下配置ADSL通过双网卡共享局域网上网

前一段Michael在网通申请开通了包月的ADSL,于是开始了Michael网上真正冲浪的日子,这些年在IT圈里混,家里电脑加起来都有三台了,加上室友的一台笔记本和一台PC,一共有5台电脑了,于是开始琢磨怎么能让这些电脑都上网。

在网上找了一阵,从一些坛子上看到有些地方有不限制一个帐户多次拨号的情况,于是我也抱着试试看的想法动手试我家的ADSL,结果一试才发现家里的ADSL居然也可以多次拨号,嘿,这下可爽了。我买了一个8口的HUB,把ADSL猫接到HUB的UP Link口上,然后别的机器都用网线接到HUB上,分别在各个机器上都安装了ADSL拨号软件,结果每台电脑都可以独立拨号上去,并且各自的速度都是512Kbps,实在是爽!有ADSL的朋友不妨也试试看运气!

结果好日子没有持续多久就发生噩梦了,昨天回到家和往常一样打开HUB和ADSL猫的电源,结果发现无论怎么试都只能拨通一台机器,后来经过确认得知我们这个区的电话局也做了限制了,这下没办法了,只能开始折腾代理服务器了。

历史原因留下来家里有一台比较旧的电脑,目前闲置不用,配置为赛扬366、内存64MB、硬盘2.5G、无显示器和键盘鼠标、双网卡,正好用来做代理服务器,经过一晚上的折腾,总算是搞好了,现在大家虽然上网速度慢了点,不过也还算满意,下面就是整个的安装配置过程。

1、确定实现目标:
我们要实现代理服务器一块网卡和ADSL猫连接,另外一个和HUB连接,在服务器上设置NAT,并配置防火墙和DHCP,内网的其他电脑使用自动获取IP地址方式,并通过代理服务器共享上网。

2、服务器安装和网络配置:
由于当时手里只有RedHat Linux 7.2 的安装光盘,于是就决定安装RedHat7.2作为代理服务器的系统,安装过程不用详细说明了,我选择了最小安装方式,自定义选择了pppd服务、防火墙、rp-pppoe包安装。

系统安装好以后,开始配置两个网卡,两块网卡分别为eth0和eth1,我选择eth0连接ADSL猫,eth1连接内网。ADSL拨号上网无需设置eth0的ip地址,下面是我的网络配置文件设置情况
/etc/sysconfig/networks文件:

NETWORKING=yes
HOSTNAME=proxy
FORWARD_IPV4="yes"
GATEWAY="ppp0"
GATEWAYDEV=""

/etc/sysconfig/network-scripts/ifcfg-eth0文件:

DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes

/etc/sysconfig/network-scripts/ifcfg-eth1文件:

DEVICE=eth1
BROADCAST=192.168.0.255
IPADDR=192.168.0.1
NETMASK=255.255.255.0
NETWORK=192.168.0.0
ONBOOT=yes

接下来设置ip转发和打开核心对ip转发的支持,打开/etc/rc.local文件,加入下面三行

echo 1 > /proc/sys/net/ipv4/ip_forward
ipchains -A forward -s 192.168.0.0/24 -d 0/0 -j MASQ
adsl-start &

最后一行设置系统在启动时自动连接ADSL,这在后面有说明。

3、ADSL配置
配置好服务器的基本环境后,开始进行ADSL拨号设置,Michael在设置的时候发现了一个很奇怪的问题,就是系统中怎么都找不到adsl-setup命令,别的如adsl-start 、adsl-connect等都有,这让我很纳闷。实在没有办法,我去openbsd.org下载了redhat7.3的rp-pppoe-3.5-1.i386.rpm 包,然后用下面的命令重新安装了rp-pppoe包
#rpm -Uhiv –replacepkgs rp-pppoe-3.5-1.i386.rpm

一看一下就好了,呵呵,不知道7.2带的包到底有什么毛病,也没有功夫仔细研究了。
接下来开始运行adsl-setup来设置ADSL,下面是配置过程
#/usr/sbin/adsl-setup
当出现
>>> Enter your PPPoE user name :
输入ADSL帐号的用户名
当出现
>>> 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 ethn, where ‘n’ is a number.
(default eth0):
输入 eth0 ,这是ADSL相连的网卡的名字
当出现
>>> Enter the demand value (default no):
输入 no
当出现
>>> Enter the DNS information here:
输入 “server” ,这表示使用ADSL拨号自动获得的DNS服务器IP地址
当出现
>>> Please enter your PPPoE password:
输入ADSL帐号的密码
当出现
>>> Choose a type of firewall (0-2):
输入 0 ,不使用防火墙
当出现
>>> Accept these settings and adjust configuration files (y/n)?
如果输入的信息正确,输入 y ,完成配置,否则,输入 n 重新输入。

这样就完成了ADSL的配置,这时试着运行一下adsl-start,正确的话应该可以看到connected的信息,如果有问题试着看看/var/log/message的信息,然后重新进行配置。

运行adsl-start成功连接后,运行ifconfig -a看看网络设备信息,应该可以看到ppp0的信息,这就是ADSL建立的连接,应该可以看到电信分配的IP地址之类的信息。

此时,Michael尝试设置了其他的电脑的ip信息,比如设置了另外一台接在HUB上的笔记本的ip地址为192.168.0.128,网关设置为192.168.0.1,打开ie上网,呵呵,大功告成!

4、配置DHCP服务
为了让家里的网络环境更方便,于是开始在代理服务器上配置DHCP服务,下面是DHCP的简单配置过程;
从光盘或者网上找到dhcp-2.0pl5-8.i386.rpm和dhcpcd-1.3.22pl1-7.i386.rpm两个包,用rpm -hiv 安装。
拷贝/usr/share/doc/dhcp-2.0pl5/dhcpd.conf.sample 文件到 /etc/dhcpd.conf 然后根据自己具体情况修改部分配置信息,下面是Michael的dhcpd.conf文件内容:

subnet 192.168.0.0 netmask 255.255.255.0 {
# --- default gateway
option routers 192.168.0.1;
option subnet-mask 255.255.255.0;

option nis-domain "toplee.com";
option domain-name "toplee.com";
option domain-name-servers 202.106.196.115,202.106.196.152,202.96.199.133;

option time-offset -18000; # Eastern Standard Time
# option ntp-servers 192.168.1.1;
# option netbios-name-servers 192.168.1.1;
# --- Selects point-to-point node (default is hybrid). Don't change this unless
# -- you understand Netbios very well
# option netbios-node-type 2;

range dynamic-bootp 192.168.0.128 192.168.0.255;
default-lease-time 21600;
max-lease-time 43200;

# we want the nameserver to appear at a fixed address
host ns {
next-server ns.toplee.com;
hardware ethernet 00:03:0F:F8:60:22;
fixed-address 192.168.0.1;
}
}

基本上你直接拷贝上面的内容就可以了。

然后运行/etc/init.d/dhcpd start 启动dhcp服务(另外可以在setup里面设置启动的时候自动运行dhcp服务)
一切ok,设置内网其他的机器使用自动获取就ok了!你可以通过查看/var/lib/dhcp/dhcpd.leases 文件查看客户机器租用ip的情况。

好了,有点晚了,Michael就写到这里,基本上都说清楚了,大家有什么问题或者发现Michael有些什么设置不够好的都可以告诉我!

大家相互交流,共同进步!

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
No Responses
  1. Pingback: Ads
  2. Search engine optimization, which is usually known as SEO, is the practice of increasing the amount and high
    quality of visitors made into your site or other Internet established real estate in search motors’ natural/organic ranking effects for
    certain words called keywords.

  3. slot online says:

    Useful info. Lucky me I discovered your website unintentionally, and I am shocked why this coincidence did
    not came about earlier! I bookmarked it.

  4. I’m really inspired together with your writing abilities as smartly as with the layout on your blog.
    Is that this a paid topic or did you modify it your self?
    Either way stay up the excellent high quality writing, it’s uncommon to
    peer a nice blog like this one nowadays..

  5. Tremendous things here. I am very glad to peer your article.
    Thanks a lot and I am looking forward to touch you. Will you please
    drop me a e-mail?

  6. Seeing cricket has actually consistently been actually the traditional approach of
    TELEVISION as well as throughout the years it has been evident that net users has actually greatly improved and also it has actually ended up being a practice that they
    see online cricket online.

  7. Hi! I know this is kinda off topic however , I’d figured I’d ask.

    Would you be interested in trading links or maybe guest writing a blog article or vice-versa?

    My blog discusses a lot of the same subjects as yours and I feel we could greatly
    benefit from each other. If you’re interested feel free to send me an email.
    I look forward to hearing from you! Superb blog by the way!

  8. Homepage says:

    Hi, all is going sound here and ofcourse every one is sharing facts,
    that’s genuinely good, keep up writing.

  9. Definitely believe that which you stated. Your favorite reason appeared to be on the
    web the easiest thing to be aware of. I say to you, I
    definitely get irked while people consider worries that they plainly do
    not know about. You managed to hit the nail upon the top and defined out the whole thing without having side-effects , people can take a signal.
    Will likely be back to get more. Thanks

  10. Website says:

    certainly like your website however you have to take a look at the spelling
    on several of your posts. A number of them are rife with spelling problems and I to find
    it very bothersome to tell the truth on the other hand I will surely come again again.

  11. Home Page says:

    Hello there, I found your web site via Google whilst looking
    for a comparable topic, your web site came up, it seems
    good. I have bookmarked it in my google bookmarks.
    Hi there, just changed into alert to your blog through
    Google, and found that it is truly informative. I am gonna watch out for
    brussels. I’ll be grateful when you proceed this in future.
    Lots of other people can be benefited out of your writing. Cheers!

  12. click here says:

    Very energetic post, I liked that bit. Will there be a part 2?

  13. view source says:

    Quality posts is the secret to interest the visitors to
    go to see the web site, that’s what this web site is providing.

  14. Hello, i feel that i saw you visited my web site thus i got here to
    return the prefer?.I’m attempting to to find things to improve my website!I assume its adequate to use a few of your ideas!!

  15. Pingback: Reklamy
  16. Deshawnsloto says:

    Helpful postings. Thanks!
    mail order pharmacy
    canadian viagra
    best canadian online pharmacy
    canadian pharmacy king
    cialis canada – https://www.canadianpharmacyopen.com/

    canadian pharma companies on f48e3c3

  17. These are genuinely great ideas in regarding blogging. You have touched
    some fastidious points here. Any way keep up wrinting.

  18. tinyurl.com says:

    Hey would you mind letting me know which web host you’re utilizing?
    I’ve loaded your blog in 3 completely different internet
    browsers and I must say this blog loads a lot quicker then most.
    Can you recommend a good hosting provider at a honest price?
    Kudos, I appreciate it!

  19. I blog often and I truly thank you for your information. This great
    article has really peaked my interest. I will bookmark your
    website and keep checking for new details about
    once per week. I opted in for your Feed too.

  20. ps4 games says:

    Does your site have a contact page? I’m having problems locating it but, I’d like to shoot you
    an email. I’ve got some suggestions for your blog you might
    be interested in hearing. Either way, great website and I look forward to seeing it grow over time.

  21. Hello would you mind letting me know which web host you’re working
    with? I’ve loaded your blog in 3 different web browsers and I must say this blog
    loads a lot faster then most. Can you recommend a good hosting provider at a reasonable price?
    Kudos, I appreciate it!

  22. I have been browsing online greater than three hours as of late,
    yet I never discovered any fascinating article like yours.
    It’s beautiful price enough for me. In my opinion, if all web
    owners and bloggers made excellent content as
    you did, the web can be much more useful than ever
    before.

  23. ps4 games says:

    Hi there! Someone in my Facebook group shared this
    website with us so I came to take a look. I’m definitely enjoying the information. I’m book-marking and will be tweeting this to
    my followers! Superb blog and superb design and style.

  24. ps4 games says:

    Hello! I’m at work surfing around your blog from my new iphone!
    Just wanted to say I love reading your blog and look forward to all your posts!
    Keep up the excellent work!

  25. Hi! I’ve been reading your blog for a long time now and finally got the bravery to go ahead and give you a shout out from
    Austin Tx! Just wanted to say keep up the excellent work!

  26. ps4 games says:

    I always used to study piece of writing in news papers
    but now as I am a user of web thus from now I am using net
    for content, thanks to web.

Leave a Reply

Your email address will not be published. Required fields are marked *

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Anti-spam image