LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-24-2010, 11:28 AM   #1
wolverene13
Member
 
Registered: May 2010
Location: Matiland, FL
Distribution: Debian Squeeze
Posts: 57

Rep: Reputation: 0
Need help figuring out how to run these commands on boot


Hi all,

I just started learning how to manipulate Linux (Debian Lenny) about a month ago with the intention of ditching Windows eventually and learning to configure servers in the process. But, I still need Windows for certain things. I downloaded and installed VirtualBox (I know, VMWare is better, but I didn't know that at the time and don't want to go through the process all over again) and got Windows XP working with a tap interface and bridge interface to get the guest OS to talk to the home OS and connect to the Internet. My only problem is that the tap interface and bridge interface disappear when I reboot and then I have to issue the commands to set them up all over again. I know there is a way to write a script to run on boot to create them and bring them up, but my whole technical career has been with CLI-based stuff, not scripting. I'd like to eventually learn it, but I'm a learn-by-doing type. Basically I need the following commands to be implemented at startup:

sudo tunctl -t tap1 -u allen
sudo brctl addbr br0
sudo ifconfig eth0 0.0.0.0 promisc
sudo brctl addif br0 eth0
sudo dhclient br0
sudo brctl addif br0 tap1
sudo ifconfig tap1 up
sudo chmod 0666 /dev/net/tun

I read somewhere that you can just add commands to your /etc/init.d/bootmisc.sh file in Debian, but I don't want to hose up my whole system somehow.

If someone could help me with this and tell me what the basic parts of the script accomplish (I'd like to learn this stuff, not just have people constantly do this for me b/c I don't know how), it would be greatly appreciated.

Thanks,

Allen
 
Old 05-24-2010, 11:31 AM   #2
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
One traditional way is to add your commands to /etc/rc.local (you won't need to prefix them with sudo).
 
Old 05-24-2010, 11:43 AM   #3
wolverene13
Member
 
Registered: May 2010
Location: Matiland, FL
Distribution: Debian Squeeze
Posts: 57

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by AlucardZero View Post
One traditional way is to add your commands to /etc/rc.local (you won't need to prefix them with sudo).
Isn't /etc/rc.local only present in RedHat, Fedora, etc?
 
Old 05-24-2010, 11:53 AM   #4
wolverene13
Member
 
Registered: May 2010
Location: Matiland, FL
Distribution: Debian Squeeze
Posts: 57

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by wolverene13 View Post
Isn't /etc/rc.local only present in RedHat, Fedora, etc?
Nevermind, I found it, but where do I put the commands? Right now, it looks like this:

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

exit 0
/usr/local/bin/noip2

Thanks,
Allen
 
Old 05-24-2010, 01:02 PM   #5
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
Well.. before the exit.
 
1 members found this post helpful.
Old 05-24-2010, 01:13 PM   #6
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Alternatively it could be done by writing the configuration in the /etc/network/interfaces file and letting the /etc/init.d/networking boot script do the work. Here is a sample interfaces file, taken from ubuntu 8.04 and used for VirtualBox before VirtualBox was enhanced to do it all itself. Change user c to allen and IP addresses as required
Code:
# eth0 is the physical interface.
# Bridging software will configure eth0 when it is added as a port to br0 (below)
# This minimal configuration avoids message "Ignoring unknown interface eth0=eth0"
auto eth0
iface eth0 inet manual
up ifconfig $IFACE 0.0.0.0 up
down ifconfig $IFACE down

# tap0 is a tap into the bridge defined below
# * tap0 is for use by VirtualBox
# * Guest OS will configure, hence "manual"
# * VirtualBox will be run by user c, hence user c
# * "ifconfig" is part of ifupdown package 
# * "tunctl_user" is part of tunctl package
auto tap0 
iface tap0 inet manual 
up ifconfig $IFACE 0.0.0.0 up 
down ifconfig $IFACE down 
tunctl_user c 

# br0 is a bridge connecting physical interface eth0 to OS and tap0
# * Stanzas for br0 ports must appear before the br0 stanza
# * Static configuration 
# * No need for spanning tree protocol (stp) because no other bridges on network
iface br0 inet static
address 192.168.0.11 
network 192.168.0.0
netmask 255.255.255.0 
broadcast 192.168.0.255
gateway 192.168.0.253
bridge_ports eth0 tap0
bridge_maxwait 0 
bridge_stp off
 
1 members found this post helpful.
Old 05-24-2010, 10:44 PM   #7
wolverene13
Member
 
Registered: May 2010
Location: Matiland, FL
Distribution: Debian Squeeze
Posts: 57

Original Poster
Rep: Reputation: 0
Thanks AlucardZero and catkin for your help. I tried both methods and they worked. I've started looking into several shell scripting tutorials and stuff, so hopefully I can figure this stuff out on my own in the future. I'm not used to being a noob and it kinda bugs me. Thanks again!
 
Old 05-25-2010, 12:23 AM   #8
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by wolverene13 View Post
I've started looking into several shell scripting tutorials and stuff, so hopefully I can figure this stuff out on my own in the future. I'm not used to being a noob and it kinda bugs me.
Glad you found a solution

Yes -- it's frustrating when you switch OS and go from being adept to having everything to learn. Although the specifics are different, many of the principles are the same so you are off to a head start compared with learning your first OS. Hope you enjoy the adventure
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Run commands on each boot linux-rulz Ubuntu 8 12-27-2011 04:28 PM
When I run commands nothing happens Aphrodite54 Linux - General 5 12-01-2009 02:56 AM
Trying to run commands at boot Centos 5 Anauj0101 Linux - Newbie 8 02-19-2008 02:04 AM
no commands run astroboiii Linux - General 2 01-08-2005 07:40 PM
Having problems figuring out these commands Dandy Linux - Newbie 2 04-18-2004 10:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration