cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
5080
Views
10
Helpful
5
Replies

Connect two hosts from different subnet

_matthew
Cisco Employee
Cisco Employee

Hello,

 

I need to connect two host from different networks. 

 

It looks like below. 
Network 1:

192.168.1.0/24 default gateway: 192.168.1.1

My host 192.168.1.100

 

Network 2:

172.16.1.0/24 default gateway 172.16.1.1 

My host 172.16.1.80

 

I need to communicate between host 192.168.1.100 and 172.16.1.80. I don't have access for network 1 and network 2 routers configuration.

 

Is it possible to communicate between this two hosts without changing existing routers config? I can use any new device between this networks.

1 Accepted Solution

Accepted Solutions

Ok.

Hope that you can have 2 IPs from each subnets?

 

The only simple solution I can see is to use nat:

Let's say 172.16.1.100 host is natted to 192.168.1.253 and hosts from 192.168.1.0 are natted to 172.16.1.253

 

You'll have a router with 1 interface on 192.168.1.0/24 and the other in 172.16.1.0/24.

In my example, interface e0/0 has IP 192.168.1.254 and e0/1 has 172.16.1.254.

 

Here a config sample:

 

interface Ethernet0/1
ip address 172.16.1.254 255.255.255.0
ip nat enable

!

interface Ethernet0/0
ip address 192.168.1.254 255.255.255.0
ip nat enable

!

access-list 100 permit ip 192.168.1.0 0.0.0.255 any  --> For simplicity I use the complete subnet. If you want to restrict to only few hosts, you can configure this acl with specifics IPs

!

ip nat pool POOL 172.16.1.253 172.16.1.253 netmask 255.255.255.0
ip nat source list 100 pool POOL overload
ip nat source static 172.16.1.100 192.168.1.253

 

 

Now, to reach your remote host 172.16.1.100 from host 192.168.1.100, do ping 192.168.1.253.

As you can see on the following wireshark, the source host is natted into 172.16.1.253

 

image.png

 

 

 


Thanks
Francesco
PS: Please don't forget to rate and select as validated answer if this answered your question

View solution in original post

5 Replies 5

Francesco Molino
VIP Alumni
VIP Alumni

Hi

 

You have access to the 2 hosts but not on the local default gateway router.

You don't want to break anything but you would like to get these 2 hosts communicating together.

 

What you can do is add a router with an interface on 192.168.1.0/24 subnet and the other interface on 172.16.1.0/24 subnet. Let's assume you configure those interfaces with IP 192.168.1.254 and 172.16.1.254.

 

As you have access to hosts you can add a local route on each host:

- route for host in 192.168.1.0/24 --> route for 172.16.1.0/24, gw is 192.168.1.254

- route for host in 172.16.1.0/24 --> route for 192.168.1.0/24, gw is 172.16.1.254

 

 


Thanks
Francesco
PS: Please don't forget to rate and select as validated answer if this answered your question

Hello,
Thank you for your reply.

The problem is that I cannot change IP address or add any route on host 192.168.1.100, and I have 5 devices with the same config, that I need to connect with host 172.16.1.80. I can have 5 additional routers.

Ok.

Hope that you can have 2 IPs from each subnets?

 

The only simple solution I can see is to use nat:

Let's say 172.16.1.100 host is natted to 192.168.1.253 and hosts from 192.168.1.0 are natted to 172.16.1.253

 

You'll have a router with 1 interface on 192.168.1.0/24 and the other in 172.16.1.0/24.

In my example, interface e0/0 has IP 192.168.1.254 and e0/1 has 172.16.1.254.

 

Here a config sample:

 

interface Ethernet0/1
ip address 172.16.1.254 255.255.255.0
ip nat enable

!

interface Ethernet0/0
ip address 192.168.1.254 255.255.255.0
ip nat enable

!

access-list 100 permit ip 192.168.1.0 0.0.0.255 any  --> For simplicity I use the complete subnet. If you want to restrict to only few hosts, you can configure this acl with specifics IPs

!

ip nat pool POOL 172.16.1.253 172.16.1.253 netmask 255.255.255.0
ip nat source list 100 pool POOL overload
ip nat source static 172.16.1.100 192.168.1.253

 

 

Now, to reach your remote host 172.16.1.100 from host 192.168.1.100, do ping 192.168.1.253.

As you can see on the following wireshark, the source host is natted into 172.16.1.253

 

image.png

 

 

 


Thanks
Francesco
PS: Please don't forget to rate and select as validated answer if this answered your question

That is exacltly what I need!

 

Thank you for help!

You're welcome

Thanks
Francesco
PS: Please don't forget to rate and select as validated answer if this answered your question
Review Cisco Networking for a $25 gift card