我安装了 Ubuntu 服务器 12.04,然后安装了 dhcp3-server 并对其进行了如下配置:
在isc-dhcp 服务器
INTERFACES="eth0"
并且在dhcpd配置文件
# A slightly different configuration for an internal subnet.
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.5 192.168.1.100;
option domain-name-servers 192.168.1.1;
option domain-name "nazwa.local";
option routers 192.168.1.1;
option broadcast-address 192.168.1.255;
default-lease-time 600;
max-lease-time 7200;
}
我还有两个 eth 接口:
# second netowrk interface
auto eth0
iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.0
# The primary network interface
auto eth1
iface eth1 inet dhcp
当我将计算机插入 eth0 时,我获得了正确的 IP 地址,但我无法访问任何网站。我甚至这样做:
echo 1 > /proc/sys/net/ipv4/ip_forward
答案1
我这样做:
auto eth0
iface eth0 inet dhcp
auto eth1
iface eth1 inet static
address 10.0.0.1
netmask 255.255.255.0
up /sbin/iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -d 0/0 -j MASQUERADE
一切顺利!