J
J
juffinhalli2013-07-30 09:44:48
Network administration
juffinhalli, 2013-07-30 09:44:48

Debian routing and iptables advice - 3 subnets + internet

Good afternoon, hackers!

Given:

The Debian-run gateway is distributing the Internet for the subnet 192.168.9.xx
And everything works well - PC #1 successfully accesses the Internet.
But the network expansion happened: I connected another network card and connected it to a cleverly configured Cisco ASA contractor. Thus, 2 more subnets were connected to the gateway: 192.168.111.xx and 192.168.112.xx.
But to get to the 192.168.112.xx subnet, you need to specify Cisco as the gateway.
I configured the inserted network card and now the gateway successfully connects to any computers: PC #1,2,3
image
[email protected]:~$ ip route show
default via 10.108. 167.1 dev eth3 metric 100
10.108.167.0/24 dev eth3 proto kernel scope link src 10.108.167.159
192.168.9.0/24 dev eth2 proto kernel scope link src 192.168.9.4 192.168.111.0/24
dev eth1 proto kernel scope link src 192.168.111.159
192.168.112.0/24 via 192.168.111.1 dev eth1

PC #1 could also connect to PC #2 and PC #3 without losing internet access.

Thank you very much in advance.

UPD: indicated above how routes are configured

UPD: It was necessary to configure masquerading in iptables
/sbin/iptables -t nat -A POSTROUTING -o eth1 -s 192.168.9.0/255.255.255.0 -d 192.168.112.0/255.255.255.0 -j MASQUERADE
/ sbin/iptables -t filter -A FORWARD -i eth2 -o eth1 -s 192.168.9.0/255.255.255.0 -d 192.168.112.0/255.255.255.0 -m state --state NEW -j NEWACCEPT

And PC #1 learned to connect to PC #2

The rest is by analogy.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Burov, 2013-07-30
@juffinhalli

debian should have
route add 192.168.111.0/24 dev eth1
and
route add 192.168.112.0/24 dev eth1
and vice versa
route add 192.168.9.0/24 dev eth2
in sysctl
net.ipv4.ip_forward=1
net.ipv4.conf .eth1.forwarding=1
net.ipv4.conf.eth2.forwarding=1

L
lionsimba, 2013-07-31
@lionsimba

Or, if you want without masquerading, you need to have a route registered on Cisco for 192.168.9.0/24 through 192.168.111.159.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question