Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Route doesn't seem to work :( #7

Open
chrisstigson opened this issue Feb 17, 2024 · 4 comments
Open

Route doesn't seem to work :( #7

chrisstigson opened this issue Feb 17, 2024 · 4 comments

Comments

@chrisstigson
Copy link

I have used bare metal Ubuntu 22.0.4 install. With a wifi-card to a router with192.168.1.1 using DHCP

My ubuntu install is on 192.168.1.42 (ssh works from windows/kali)
I have another box that is physically connected to 192.168.1.67 through Virtualbox (bridged) on another physical PC (kali)

In the end I get:
"Deployment succeeded, your lab is now up and running on the 192.168.56.0/24 network", and surely I can ping things inside from the SSH sessions or kali to 192.168.1.42

Now I've added the route

sudo ip route add 192.168.56.0/24 via 192.168.1.42 (in kali)

From kali I get ping response from 192.168.1.42(ubuntu), but not 192.168.56.10 for example,.

cme smb 192.168.56.0/24 doesn't get any responses.
nmap 192.168.56.0/24 is dead, except 192.168.56.1

So I am thinking the problem is within the ubuntubox somehow. I've tried lots of manulas and routing, opening and disabling firewalls etc...

Do I need to attack my network from the ubuntubox?

It seems 192.168.56.1 is "router in NAT mode"

┌──(kali㉿kali)-[~]
└─$ sudo ip route add 192.168.56.0/24 via 192.168.1.42

┌──(kali㉿kali)-[~]
└─$ ping 192.168.56.10
PING 192.168.56.10 (192.168.56.10) 56(84) bytes of data.
^C
--- 192.168.56.10 ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 1006ms

┌──(kali㉿kali)-[~]
└─$ ping 192.168.56.1
PING 192.168.56.1 (192.168.56.1) 56(84) bytes of data.
64 bytes from 192.168.56.1: icmp_seq=1 ttl=64 time=1.45 ms
64 bytes from 192.168.56.1: icmp_seq=2 ttl=64 time=1.54 ms
^C
--- 192.168.56.1 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1002ms
rtt min/avg/max/mdev = 1.449/1.494/1.540/0.045 ms

┌──(kali㉿kali)-[~]
└─$ sudo ip route add 192.168.56.0/24 dev eth0 via 192.168.1.42
RTNETLINK answers: File exists

┌──(kali㉿kali)-[~]
└─$ sudo ip route add 192.168.56.0/24 dev eth0 via 192.168.51.1
Error: Nexthop has invalid gateway.

┌──(kali㉿kali)-[~]
└─$

@chrisstigson
Copy link
Author

I solved it by installing OpenVPN Access Server and sharing the networks using NAT routing. Still not sure why it didn't work previously, but some setting must have been wrong in the Ubuntu server.
image

@lkarlslund
Copy link
Owner

Not sure what's going on there, but if you can ping everything 192.168.56.0/24 from your VirtualBox host (192.168.1.42), but not from outside the host, then it sounds like a routing thing.

IP routing is enabled by the script:

# Enable IP forwarding on Ubuntu
if [ "`cat /proc/sys/net/ipv4/ip_forward`" != "1" ]; then
  # Implement in sysctl
  echo net.ipv4.ip_forward = 1 >> /etc/sysctl.conf
  sysctl -p
fi

What does "ip addr" output?

@TamaGorengs
Copy link

I have the same issue. But I can only ping 192.168.56.1. Other than that I can't reach it.

@JattyB
Copy link

JattyB commented Nov 13, 2024

Hi,
I had the same issue with the installation.
Below steps fixed it for me:

First enable IP forwarding in Ubuntu:

sudo sysctl -w net.ipv4.ip_forward=1
sudo sysctl -p

Then add the route:
sudo ip route add 192.168.56.0/24 via <Your ubuntu machine IP>

Also you need to allow and masquerade the traffic:

sudo iptables -A FORWARD -s 192.168.1.0/24 -d 192.168.56.0/24 -j ACCEPT
sudo iptables -A FORWARD -s 192.168.56.0/24 -d 192.168.1.0/24 -j ACCEPT
sudo iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -d 192.168.56.0/24 -j MASQUERADE

After this I ran nmap from my kali machine and it worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants