一台Linux頂多個SOHO路由器 (iptables, iproute2, netfilter)|One Linux Box replacing Many SOHO Routers (iptables, iproute2, netfilter)
Saturday, October 18th, 2008一台Linux代替一個SOHO路由器很容易,大致可以用6句command概括
It’s easy to use Linux to replace one SOHO router. It can be conclude with 6 commands:
dhclient3 … $WANIF # Get the IP on WAN side
ip addr add 192.168.0.0/24 broadcast + dev $LANIF # Get the IP on LAN side
dhcpd3 … $LANIF # Enable the DHCPD on LAN side
sys.net.ipv4.ip_forward = 1 # Enable forwarding
iptables -t nat -A POSTROUTING -o $WANIF -j MASQUERADE # Enable SNAT
dnsmasq # Enable DNS proxy
目的:一台Linux代替N個SOHO路由器。即是說一台能夠建立多個獨立NAT,大家都用看似同似同一樣但實際不一樣的私有IP網址地段。
GOAL: Use one Linux box to replace N SOHO Routers. i.e. This box would multiple isolated NAT each running at the same but actually different private IP range.
始終1台用5個command不代表2台只需10個command,主要問題有七:
One router takes 5 commands doesn’t mean 2 routers take 10 commands, the problems are:
- WAN Interface要拿很多個WAN IP,但怎樣才可以有多個dhclient到很多IP?
- 怎樣MASQUERADE到不同的WAN IP……?
- 我想N個SOHO Router的LAN Interface都是192.168.0.0/24,就真的有如N個SOHO Router一樣,後面都是叫192.168.0.0/24,但實際此上192不同那192。若每個$LANIF[1..n]都是用192.168.0.0/24,傳統按Destination做Routing的Route Table會出問題,也就是說Kernel不知道192.168.0.0/24應從哪個Interface走的問題。
- 從LAN訪問Router機……?
- DMZ和Port Forwarding…?
- N NAT subnet互相通過大家的WAN Side IP做Connection也……?。
- Router機訪問Client Side……?
- How to get more than one IP for the WAN Interfaces?
- How to MASQUERADE to different WAN IP, for each set of router?
- N routers subnet will be defined as 192.168.0.0/24, but just like real router setup, THIS 192.168.0.0/24 is not THAT 192.168.0.0/24. Attaching 192.168.0.1/24 to $LANIF[1..n] confuses the kernel, or routing table to be exact, what can be done?
- From LAN side to visit the Router box?
- How about DMZ and Port Forwarding?
- Can visiting the other NAT subnet from one NAT subnet be done?
- How about Router visiting Client Side?

