Re: [問題] DHCP 分配兩個網域 不同GW ???
※ 引述《sambas (sambas)》之銘言:
: 請問
: 我想在我的linux上面
: eth0的 DHCP 分派真實IP
: eth1的 DHCP 分派192的私有 IP
: 而eth0和eth1各有不同的GW
: 請問
: 這個要怎麼做????
: 我把eth0設上default的GW
: 這樣變成eth1分派出去的IP
: GW也捉成eth0的
: 造成192私有ip段
: 根本都不能上網.....
你先搞清楚什麼是route, ip , subnet, mask , NAT, iptables再來說吧(遠目)
dhclient eth0 #get public IP
ifconfig eth1 192.168.0.1 #set private IP and subnet
vim /etc/dhcpd.conf
#server ip should be 192.168.0.1
ddns-update-style none;
default-lease-time 600;
max-lease-time 86400;
subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.100 192.168.0.200;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.0.255;
option routers 192.168.0.1;
option domain-name-servers 168.95.1.1;
option domain-name "mydomain.org";
}
#/dhcpd
#enable ip forward
echo "1"> /proc/sys/net/ipv4/ip_forward
#iptables to forward packets from 192.168.0.0/24(dhcp) to eth0
iptables -t nat -A POSTROUTING -o eth0 -s 192.168.0.0/24 -j MASQUERADE
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 219.84.125.80
※ 編輯: mshx 來自: 219.84.125.80 (05/06 23:26)
討論串 (同標題文章)