I run some software called RPCEmu (http://www.marutan.net/rpcemu/) and I want to run networking on it. I've setup networking on the emulator and also on my linux box. But I have to run the commands each time.
These are the commands, run as root :- iptables -I FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT iptables -t nat -A POSTROUTING --source 172.31.0.0/16 -o eth0 -j MASQUERADE sysctl -w net.ipv4.ip_forward=1 sysctl -w net.ipv4.ip_dynaddr=1
How do I run them each time I switch on the machine so that they're run as root?
Any help appreciated.
Chris Walker cdw_alug@the-walker-household.co.uk
I run some software called RPCEmu (http://www.marutan.net/rpcemu/) and I want to run networking on it. I've setup networking on the emulator and also on my linux box. But I have to run the commands each time. [...] How do I run them each time I switch on the machine so that they're run as root?
Maybe you could put them in root's crontab with an @reboot timestamp.
I suspect you shouldn't run them at boot because networking may not be up and may go up/down subsequently.
Instead, put them in an file in /etc/network/if-up.d with the executable permission - there should be scripts in there that you can mimic.
Hope that helps,
On 08/04/13 17:01, MJ Ray wrote:
Chris Walker cdw_alug@the-walker-household.co.uk
I run some software called RPCEmu (http://www.marutan.net/rpcemu/) and I want to run networking on it. I've setup networking on the emulator and also on my linux box. But I have to run the commands each time. [...] How do I run them each time I switch on the machine so that they're run as root?
Maybe you could put them in root's crontab with an @reboot timestamp.
I suspect you shouldn't run them at boot because networking may not be up and may go up/down subsequently.
Instead, put them in an file in /etc/network/if-up.d with the executable permission - there should be scripts in there that you can mimic.
There is no folder called /etc/network/if-up.d on my machine. The nearest is /etc/sysconfig/network-scripts/ifup.d/ so I created a script in there called rpc_tables_up.
But having rebooted, I see that it's not running as networking isn't running in RPCEmu. If it manually run the command with sudo, then networking functions as expected in the emulator.
So I need to work out where to put it so that it runs but runs safely. More googling I fear.
Hope that helps,
It certainly does, thanks. I'm not down hearted because it didn't work this time. You've given me more than enough of a clue.
On 8 April 2013 20:25, Chris Walker cdw_alug@the-walker-household.co.uk wrote:
So I need to work out where to put it so that it runs but runs safely.
I think that the location looks OK, so I think it's the script that needs tweaking (albeit that it works fine if run manually).
Can you post the script content? I assume it's similar to the lines in the original post with something like #!/bin/bash at the top but assumptions aren't great when troubleshooting!
Also, the output from: ls -la /etc/sysconfig/network-scripts/ifup.d/rpc_tables_up .. to confirm ownership and permissions.
When you run it manually (and it works), are you just doing: sudo /etc/sysconfig/network-scripts/ifup.d/rpc_tables_up or something different?
On 09/04/13 09:05, Mark Rogers wrote:
On 8 April 2013 20:25, Chris Walker cdw_alug@the-walker-household.co.uk wrote:
So I need to work out where to put it so that it runs but runs safely.
I think that the location looks OK, so I think it's the script that needs tweaking (albeit that it works fine if run manually).
Can you post the script content? I assume it's similar to the lines in the original post with something like #!/bin/bash at the top but assumptions aren't great when troubleshooting!
It's exactly the same. I just did a cut and paste from the email I'd sent.
Also, the output from: ls -la /etc/sysconfig/network-scripts/ifup.d/rpc_tables_up .. to confirm ownership and permissions.
ls -l /etc/sysconfig/network-scripts/ifup.d/rpc_tables_up -rwxr-xr-x 1 root root 294 Apr 8 19:18 /etc/sysconfig/network-scripts/ifup.d/rpc_tables_up*
When you run it manually (and it works), are you just doing: sudo /etc/sysconfig/network-scripts/ifup.d/rpc_tables_up or something different?
Nope. That's exactly what I'm doing.
Chris Walker cdw_alug@the-walker-household.co.uk
On 09/04/13 09:05, Mark Rogers wrote:
When you run it manually (and it works), are you just doing: sudo /etc/sysconfig/network-scripts/ifup.d/rpc_tables_up or something different?
Nope. That's exactly what I'm doing.
I don't know that structure, but I suspect scripts in ifup.d are run with parameters, which is why I suggested mimicking a script that's already in there.
Worst case, you may have to register them somewhere to have them run.
Hope that helps,
On Mon, Apr 08, 2013 at 12:36:54PM +0100, Chris Walker wrote:
iptables -I FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT iptables -t nat -A POSTROUTING --source 172.31.0.0/16 -o eth0 -j MASQUERADE
These could go into /etc/rc.local or potentially there is a script your system will run for iptables rules on boot.
sysctl -w net.ipv4.ip_forward=1 sysctl -w net.ipv4.ip_dynaddr=1
These would be best reformatted and put into /etc/sysctl.conf
Adam
On 09/04/13 09:49, Adam Bower wrote:
On Mon, Apr 08, 2013 at 12:36:54PM +0100, Chris Walker wrote:
iptables -I FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT iptables -t nat -A POSTROUTING --source 172.31.0.0/16 -o eth0 -j MASQUERADE
These could go into /etc/rc.local or potentially there is a script your system will run for iptables rules on boot.
sysctl -w net.ipv4.ip_forward=1 sysctl -w net.ipv4.ip_dynaddr=1
These would be best reformatted and put into /etc/sysctl.conf
You'll have to forgive me asking this question, but how and why would I need to reformat them?
I've looked at http://www.linuxvbashi.cz/en/system and the sysctl commands listed there appear to me to be in the same format as those you've listed above.
On Tue, Apr 09, 2013 at 06:13:07PM +0100, Chris Walker wrote:
You'll have to forgive me asking this question, but how and why would I need to reformat them?
To remove the bit saying sysctl -w at the beginning is what I meant! I didn't want you just cutting and pasting those lines into place.
Adam
On 10/04/13 02:43, Adam Bower wrote:
On Tue, Apr 09, 2013 at 06:13:07PM +0100, Chris Walker wrote:
You'll have to forgive me asking this question, but how and why would I need to reformat them?
To remove the bit saying sysctl -w at the beginning is what I meant! I didn't want you just cutting and pasting those lines into place.
I did as you suggested, rebooted the box and it all just works. Thanks to all who helped. It's much appreciated.