Setting up OpenWrt for scientific上网 involves several steps to ensure you have a smooth and secure environment. Below is a step-by-step guide to help you get started:
-
Uninstall System Software:
- Remove any unnecessary system software or services to prevent conflicts.
- Remove
杀file,modprobe, and any other unnecessary utilities.
-
Install System Root:
- Use a package manager (e.g.,
sudo apt install system-rooton Ubuntu/Debian, orsudo revcaton Fedora/RedHat). - This creates a root user (root) with full system access.
- Use a package manager (e.g.,
-
Disable System Services:
- Stop services that are not needed (e.g.,
sudo service stop all).
- Stop services that are not needed (e.g.,
-
Install Required Software:
- Install
apt(for Debian/Ubuntu-based systems) oryum(for CentOS/RHEL). - Ensure your system has
sudoandsudo systemctlcommands.
- Install
Step 2: Install and Configure OpenWrt
-
Install OpenWrt:
- Download and install OpenWrt from the official website: https://openwrt.org/.
-
Install Dependencies:
- Open OpenWrt and go to
sudo systemctl install. - Install required packages like
libsh2-1,libsh2-ai,libsh2-base, andlibsh2-open. - Install
sudo-ntfsfor NTFS file system setup.
- Open OpenWrt and go to
-
Install Firewall:
- Install
iptableswith:sudo iptables -t user -u net -j drop -j 999,1 - Install a custom firewall for security:
sudo iptables -t user -u net -j basic -a match -o net - sudo iptables -t user -u net -j basic -a match -o net -i 192.168.1.1/255.255.255. sudo iptables -t user -u net -j basic -a match -o net -i 192.168.1.1/255.255.255. sudo iptables -t user -u net -j basic -a match -o net -i 192.168.1.1/255.255.255. sudo iptables -t user -u net -j basic -a match -o net -i 192.168.1.1/255.255.255. sudo iptables -t user -u net -j basic -a match -o net -i 192.168.1.1/255.255.255.
- Install
Step 3: Set Up User Directory
-
Create Root User:
- In the OpenWrt root user directory (
/user/) create a user namedroot:sudo user add -m root - Add another user (e.g.,
userdev devroot) withsudo user add -m devroot.
- In the OpenWrt root user directory (
-
Configure Role System:
- Set root as the primary user:
sudo user setrole root - Set root as the default role for development:
sudo user setrole devroot
- Set root as the primary user:
-
Set Up Development User:
- Create a development user if needed:
sudo user add -m developmentroot
- Create a development user if needed:
Step 4: Configure the Development Kernel
-
Add Development Kernel:
- Add the development kernel to the system:
sudo system add dev
- Add the development kernel to the system:
-
Configure Development Kernel Rules:
- Add a rule to allow editing files:
sudo system add rule editfile - Add a rule to allow creating directories:
sudo system add rule dir
- Add a rule to allow editing files:
-
Install Development Scripts:
- Install the development scripts in
/var/lib/:sudo add-args sudo cd /var/lib && ls
- Install the development scripts in
Step 5: Set Up Firewalls and Security
-
Add Firewall Rules:
- Add basic firewall rules to restrict certain actions:
sudo firewall add -i 8 -o 443 -d 256 sudo firewall add -i 8 -o 443 -d 256 -e 2 - Add custom firewall rules based on your security needs.
- Add basic firewall rules to restrict certain actions:
-
Install Custom Firewall:
Follow the instructions to set up a custom firewall for specific security requirements.
Step 6: Update the System
-
Back Up Data:
Before starting, backup your data to avoid loss if something goes wrong.
-
Update System Kernel:
- Update the system:
sudo system update
- Update the system:
-
Update Package Lists:
- Update the package list:
sudo apt update
- Update the package list:
-
Reboot OpenWrt:
- After updating, reboot OpenWrt to apply changes:
sudo reboot
- After updating, reboot OpenWrt to apply changes:
Step 7: Set Up System Boot
-
Enable System Boot:
- Ensure the system has the ability to boot from the hard drive:
sudo system boot enable
- Ensure the system has the ability to boot from the hard drive:
-
Configure System Boot:
- Set up the system to boot the root user:
sudo system boot -b root - Set up the development kernel to boot the development user:
sudo system boot -b dev
- Set up the system to boot the root user:
-
Install System Boot Scripts:
- Install the system boot scripts in the root user directory:
sudo add-args sudo cd /var/lib && ls - Add the following scripts:
sudo script install root -name systemboot -args root -cmd /bin/sh -c /bin/sh -l -s 128 -n "OpenWrt -B" sudo script install dev -name systemboot-dev -args dev -cmd /bin/sh -c /bin/sh -l -s 128 -n "OpenWrt -B"
- Install the system boot scripts in the root user directory:
Step 8: Test the System
-
Check User Access:
- Verify that the root user has access to all system files and scripts:
sudo ls /var/log/auth
- Verify that the root user has access to all system files and scripts:
-
Firewall Testing:
- Test the firewall rules to ensure they restrict unauthorized access:
sudo firewall test
- Test the firewall rules to ensure they restrict unauthorized access:
-
System Boot Test:
- Test the system boot to ensure it starts correctly:
sudo system boot test
- Test the system boot to ensure it starts correctly:
Step 9: Troubleshooting
-
Check Permissions:
- If you're accessing restricted files, check permissions:
sudo ls -l /path/to/file - Use
sudo ls -lto see restricted files.
- If you're accessing restricted files, check permissions:
-
Check Firewall Rules:
- If you're being blocked by a firewall, check rules:
sudo iptables -t global -A rule -a -s -o net/.1.1.1/255.255.255. -m 0
- If you're being blocked by a firewall, check rules:
-
Check System Boot Issues:
- If the system isn't booting, check the boot process:
sudo ls -l /dev/sdX - Check the boot script files:
sudo ls -l /var/lib/systems/root boot script
- If the system isn't booting, check the boot process:
Step 1: What to Expect When You Start Using OpenWrt for Science
- Secure Environment: OpenWrt provides strong security, making it suitable for scientific work.
- Extensive Configuration: You can customize OpenWrt to meet your specific needs.
- Extensive Package List: OpenWrt offers a wide range of tools and scripts for various tasks.
By following these steps, you should be able to set up and use OpenWrt for scientific上网 effectively. Have a great day!









