搭建Linux网关

来源:互联网 发布:python女生好找工作吗 编辑:程序博客网 时间:2024/06/06 00:25

主要目的:搭建网关,使内网能自动获得IP,并正常访问外网

操作系统:Ubuntu 10.10
需要的软件有dhcp3-server和firestarter
即 sudo apt-get install dhcp3-server firestarter
eth0为外网网卡,eth1为内网网卡
下面开始
先打开/etc/network/interfaces编辑固定IP,添加
auto eth0
auto eth1
iface eth1 inet static
address 192.168.3.254
netmask 255.255.255.0
打开/etc/default/dhcp3-server,将INTERFACES="″改为INTERFACES="eth1″
打开/etc/dhcpd.conf,将所有内容前都有#,并添加如下内容
# DHCP configuration generated by 小球
ddns-update-style interim; #定义所支持的DNS动态更新的型{none|adhoc|interim}

ignore client-updates; #allow/ignore允许/忽略客户机更新DNS记录

subnet 192.168.3.0 netmask 255.255.255.0 #定义dhcp服务的子网

{

range 192.168.3.50 192.168.3.200; #自动分配IP的范围

option subnet-mask 255.255.255.0;#定义子网掩码

option routers 192.168.3.254;#定义网关

option broadcast-address 192.168.3.255;#定义广播地址

option domain-name-servers 202.112.20.131,202.114.0.242; #定义dns地址

option domain-name "hustunique.com";#定义网络名字

default-lease-time 21600;#默认的租约时间,单位为秒

max-lease-time 43200;#最长租约时间,单位为秒

若还想配置固定的IP,则可按以下格式添加
host server1 {
hardware ethernet 00:1b:63:ef:db:54;
fixed-address 192.168.3.120;
}
然后再重启dhcp服务器就可以了
  sudo /etc/init.d/dhcp3-server restart
然后用Firestarter这个工具可以简单的配置iptables的nat功能,只要按照向导做很简单。

 

原创粉丝点击