![在两个接口之间转发数据](https://linux22.com/image/826551/%E5%9C%A8%E4%B8%A4%E4%B8%AA%E6%8E%A5%E5%8F%A3%E4%B9%8B%E9%97%B4%E8%BD%AC%E5%8F%91%E6%95%B0%E6%8D%AE.png)
我安装了 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
一切顺利!