Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Typical home-networking xDSL setup on a TG782 router/gateway. Hosts on the local private network are allocated IP-addresses in the range of 192.168.1.0/24 and can get to WAN through the aforementioned combo device at 192.168.1.254 (the gw for LAN). I'm running Debian on one of the machines (192.168.1.63) and want to add an IP-addr. to the same interface, but from a different network (i.e. 172.16.1.0/24) and be able to route packets to the outside network just like I'm doing now with the current setup.

Here are the details of ifconfig:

wlan2 Link encap:Ethernet HWaddr 94:0c:6d:8d:28:0f
inet addr:192.168.1.63 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

Output of route -n:

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.254 0.0.0.0 UG 0 0 0 wlan2
192.168.1.0 0.0.0.0 255.255.255.0 U 2 0 0 wlan2

So, let's say I will do this:

ip addr add 172.16.1.62/24 dev wlan2

What changes would I need to make locally, on this machine, so that I would get this working:

telnet -b 172.16.1.62 google.com 80

?

My assumption is that I would probably need to do some form of internal NAT with iptables, in order to have this properly routed or.. ?

Thanks.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

iptables -t nat -A POSTROUTING -o wlan2 -j SNAT -s 172.16.1.62/24 --to-source 192.168.1.63

Seems to do just that:

# telnet -b 172.16.1.62 google.com 80
Trying 173.194.32.33...
Connected to arn06s02-in-f1.1e100.net.
Escape character is '^]'.
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.