Score:1

Accessing Devices on SubnetA from SubnetB

cd flag

Hi All been beating my head all day and will continue to do so but hoping someone can guide me in a direction.

My routing Problem

I am currently trying to plug an IP Cam directly into ubuntu machine that has an eth0 and wlan0 interface. I'm trying to route it so that PCs on SubnetA can access the IPCam on Subnet B. So far, I have managed to get the PCs to access eth0 on the machine but not the IP Cam.The way I did this was to: route add -net x.x.1.0 netmask 255.255.255.0 gw wlan0.ip.address

I've tried: route add -net x.x.0.0 netmask 255.255.255.0 gw eth0.ip.address but this causes the network to crash. Which makes sense as I believe it already has a route for that netmask. I tried setting up a dhcp server with the dhcp.conf

option domain-name "somedhcpserver";
option domain-name-servers wlan.ip.address;
option routers x.x.1.1;
option ntp-servers wlan.ip.address;
default-lease-time 14440;
ddns-update-style none;
deny bootp;
shared-network intranet {
        subnet x.x.1.0 netmask 255.255.255.0 {
                option subnet-mask 255.255.255.0;
                pool { range x.x.1.5 x.x.1.15; }
        }
}

but this doesn't seem to do anything.

I also tried setting up some iptable rules:

sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
sudo iptables -A FORWARD -i eth0 -o wlan0 -s x.x.1.0/24 -m conntrack --ctstate NEW -j ACCEPT
iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT

I'm guessing I'm going to have to try and configure the IP Cam to allow the routes somehow (plugging directly into the router) but any help would be appreciated.

Score:0
cd flag

OK so I got it working...

I did a few things, not sure which one got the communication going two ways.

option routers x.x.1.1; should have been option routers eth0.ip.address;

I also did:

sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE

and for good measure I set up another route

sudo ip route replace default via wlan.ip.address

Finally I set the gateway and dns servers on the IP Cam to be the same as eth.ip.address.

Hope that helps someone setting up an IP cam without plugging it into the router :).

Zac67 avatar
ru flag
Rather than working around the problem using NAT you should simply activate IP forwarding (routing) on the Ubuntu machine and add a static route to the wired cam network on the router.
Llewyn S avatar
cd flag
@Zac67 I've set up a route in the router using route add -net x.x.1.0 netmask 255.255.255.0 gw wlan0.ip.address I tried adding a simple forwarding rule using: sudo iptables -A FORWARD -i eth0 -o wlan0 -s x.x.1.0/24 -m conntrack --ctstate NEW -j ACCEPT To allow the IP Cam to respond to traffic adhering to the above route but it didn't work. Is there something I'm missing here? Happy to be pointed to any docs, I've never worked with subnets so I was just flying by the seat of my pants if it wasn't obvious.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.