Jump to content

Configure IP and DHCP range?


Dave-ee Jones

Recommended Posts

Hoi!

So, I want to configure the IP of the PS and configure the DHCP range when NATing. Anyone know how one would do this on the PS? Be much helpfulness.

It's for a payload that basically turns the PS into a configurable remote-access tool.
E.g. it has a web server that hosts a website, giving you control over the PS to remotely launch payloads, commands and access to other things like DNS, VPN, SSH and TCPDump. I've got TONNES of ideas for this payload, but unfortunately many of them, while incredible, are very hard and may not be possible for a 1-man job. It's basically entirely web-server-based (script-wise), and considering the PS has very limited processing power I'm not sure if it's going to be feasible or not.

If any of you know what a Cyberoam is, you may realise what I'm trying to get at.

Anyway, ENOUGH SPOILERS.

Anyone know how to configure the network settings of the PS? I'm sure Seb does..:rolleyes:

Cheers!

Link to comment
Share on other sites

2 hours ago, Dave-ee Jones said:

may not be possible for a 1-man job. It's basically entirely web-server-based (script-wise), and considering the PS has very limited processing power I'm not sure if it's going to be feasible or not.

Do or do not - there is no try.

2 hours ago, Dave-ee Jones said:

I'm sure Seb does..:rolleyes:

The file you are looking for is /etc/config/dhcp. To make it a bit easier, I would suggest looking into the UCI system and cli tool to change the settings you want to change. That said, what is wrong with the PS's DHCP pool?

Link to comment
Share on other sites

1 hour ago, Sebkinne said:

Do or do not - there is no try.

Maybe. But it raises the obvious question: How do you do something without trying to do it first?

1 hour ago, Sebkinne said:

The file you are looking for is /etc/config/dhcp. To make it a bit easier, I would suggest looking into the UCI system and cli tool to change the settings you want to change. That said, what is wrong with the PS's DHCP pool?

Cheers big-ears.

Well, if I change the IP of the PS to, say, 192.168.10.1 I don't want it to NAT the clients in the 172.16.32.* range. Also, it's meant to be configurable - as if you were setting up a router for your own use, and it would be nice to have that option. :)

Link to comment
Share on other sites

  • 2 weeks later...

Hate to bump a thread but thought it better than creating a new post relevant to this one..(Sorry, @Sebkinne)

I've found the relevant network settings I wish to change, but am wondering how I would change them with UCI. Here's my thoughts:

# Change IP
uci set network.lan.ipaddr=192.168.1.1 
# Change type (can also be 'dhcp'?)
uci set network.lan.proto=static
# Change netmask (I know it's already this, it's just for future reference)
uci set network.lan.netmask=255.255.255.0

Also, how would I change the DHCP range? I've found the start number and number limit (100 and 150 respectively) but where does it start from?
172.16.32.104 -> 172.16.32.254?
172.16.32.100 -> 172.16.32.250?

Just realising the amount of options for configuration I can add to my 'Configuration' page on PopsWRT..

Link to comment
Share on other sites

  • 4 weeks later...

Am having a fair amount of issues with the configuration..When it finishes updating (I know it finishes because it says so in the log file) it doesn't come back up properly - my IP doesn't change, the PS' IP and stuff seems to break (can't ping it on the old or the new IP).

Someone want to have a look at my precious update function and try to see what's wrong with it?

Here it is (don't get any ideas about stealing this stuff, k? :P):

function update() {
	source $fs_CONFIG
	# Network Settings
	## Netmode
	if [ $fm_netmode ]; then
		log "-+ Updating NETMODE: $fm_netmode"
		NETMODE $fm_netmode
		sleep 3
	fi
	## IP
	if [ $fm_staticip ]; then
		log "-+ Updating Static IP: $fm_staticip"
		uci set network.lan.ipaddr="$fm_staticip"
	fi
	## Mask
	if [ $fm_netmask ]; then
		log "-+ Updating Netmask: $fm_netmask"
		uci set network.lan.netmask="$fm_netmask"
	fi
	## DHCP
	if [ "$fm_dhcp" = "1" ]; then
		b_DHCP=1
		log "-+ DHCP Enabled"
		if [ $fm_dhcp_start ]; then
			log "-+ Updating start IP for DHCP: $fm_dhcp_start"
			uci set dhcp.lan.start="$fm_dhcp_start"
		fi
		if [ $fm_dhcp_limit ]; then
			log "-+ Updating limit for DHCP: $fm_dhcp_limit"
			uci set dhcp.lan.limit="$fm_dhcp_limit"
		fi
	else
		b_DHCP=0
		log "-+ DHCP Disabled"
		uci set dhcp.lan.start=100
		uci set dhcp.lan.limit=1
	fi
	## DNS
	if [ "$fm_dns" = "1" ]; then
		b_DNS=1
		log "-+ DNS Enabled"
		### Aggressive DNS
		if [ "$fm_dns_mode" = "1" ]; then
			cp $fs_CONFIG/hosts /tmp/dnsmasq.address &> /dev/null
			iptables -A PREROUTING -t nat -i eth0 -p udp --dport 53 -j REDIRECT --to-port 53
		fi
	else
		b_DNS=0
		log "-+ DNS Disabled"
		uci set dhcp.dnsmasq.port=0
	fi
	## SSH
	if [ "$fm_ssh" = "1" ]; then
		b_SSH=1
		log "-+ SSH Enabled"
	else
		b_SSH=0
	fi
	## VPN
	if [ "$fm_vpn" = "1" ]; then
		b_VPN=1
		log "-+ VPN Enabled"
		if [ $fm_vpn_dns ]; then
			DNS_SERVER=$fm_vpn_dns
		fi
		### Tunnel
		if [ "$fm_vpn_mode" = "1" ]; then
			NETMODE BRIDGE
		else
			NETMODE VPN
		fi
		uci set openvpn.vpn.config="$fs_CONFIG/config.ovpn"
	else
		b_VPN=0
		log "-+ VPN Disabled"
	fi
	# Apply changes
	uci commit
	/etc/init.d/network reload
	/etc/init.d/dnsmasq restart
	if [ "$b_VPN" = "1" ]; then
		/etc/init.d/openvpn start
		setdns &
	fi
	if [ "$b_SSH" = "1" ]; then
		/etc/init.d/sshd start &
	fi
}

Here's what the update file (config.ini) looks like:

fm_netmode=Bridge
fm_staticip=172.16.16.1
fm_dhcp=1
fm_dns=1
fm_dns_mode=1
fm_ssh=1
fm_vpn=0

Have a crack at that, see if you can fix it. I can't work it out - though maybe it's because NETMODE BRIDGE? It starts as NETMODE NAT, but I changed it to BRIDGE with no ethernet in the WAN port. I know that's a problem in itself :P

Network order of operations:
- Change NETMODE
- Reboot network settings
- Reboot DNSMasq
- Reboot SSH

Link to comment
Share on other sites

When your question doesn't get answered you just...

Bump, bump, BUMP it up! :D

EDIT: That said, I think I found the problem. It seems to be working well now, but I did forget to restart the web server after resetting network settings so yeah..rookie mistake.

However, 'that said' said, it still comes up with the "This site can't be reached" error (error: ERR_CONNECTION_REFUSED) when I try and browse to the PS. 

What I'm doing is killing the web server, restarting the network and DNSmasq and then starting the Python web server again.

Could it be that the PS still thinks the Python webserver is running, and so then the port (port 80) is 'still in use' so it won't start it properly?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...