Using a Linux Laptop as a Wireless Bridge

Is it possible to use Linux for a Wireless Bridge? You bet! Last night one of our USB wireless adapters kicked the bucket. Being down one, I decided to see if I could come up with a creative solution rather than plunk down another $20 that I may or may not have right now. One of the things in my inventory is a Linux laptop (Remember Project 50/50?) that has no problem connecting to my WiFi.

I suspected that there would be a way to route Ethernet traffic from my desktop PC (running Windows 7) through the Ethernet on the laptop, and through its WiFi connection. The laptop already has CrunchBang Linux running on it (a Debian derivative.) Thanks to IPTables, this was a simple task.

First, I ran an Ethernet cable between the Ethernet port on my desktop PC and the laptop. Because of Modern Technology I didn’t even have to use a crossover cable. I configured the PC with the IP of 192.168.2.2, Subnet Mask 255.255.255.0, Gateway of 192.168.1.1 and DNS of 8.8.8.8 and 8.8.4.4.

Then, with the WiFi already connected via the Linux GUI, I ran the following shell script as root:

ifconfig eth0 up
ifconfig eth0 192.168.2.1
echo "1" > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o wlan0 -s 192.168.2.0/24 -j MASQUERADE

Voila! We have a bridged connection. The only trouble was that Network-Manager kept putting eth0 down because it was not configured. This was solved by running

sudo nm-connection-editor

and then selecting “Wired conneciton 1″ and then “Edit…” and then unchecking “Connect Automatically.” This solved that problem.

Since this is only a temporary solution, I haven’t set it up to automatically do the routing every time the system boots. But, it works for now and is a simple, elegant solution. Plus it saved me $20!

I hope this works well for you. If you have any questions, please don’t hesitate to comment below! :)

 

 

 

cPanel Apache error: libgcc_s.so.1 must be installed for pthread_cancel to work

The other day I ran into the error “libgcc_s.so.1 must be installed for pthread_cancel to work.” Apache on this cPanel server would produce “Internal Server 500″ for any web page. When I checked the /usr/local/apache/logs/error_log, I found the following entry:

[Thu Jul 17 03:51:41 2014] [error] [client 12.34.56.78] libgcc_s.so.1 must be installed for pthread_cancel to work
[Thu Jul 17 03:51:41 2014] [error] [client 12.34.56.78] Premature end of script headers: index.php
[Thu Jul 17 03:51:42 2014] [error] [client 12.34.56.78] libgcc_s.so.1 must be installed for pthread_cancel to work
[Thu Jul 17 03:51:42 2014] [error] [client 12.34.56.78] Premature end of script headers: index.php
[Thu Jul 17 03:51:42 2014] [error] [client 12.34.56.78] libgcc_s.so.1 must be installed for pthread_cancel to work

The fix was only a Google search away. cPanel’s own forum had the fix here. I’ve consolidated the fix into a short shell script that you can just copy and paste. But first, understand what it does. In WHM, you can go to Home » Service Configuration » Apache Configuration » Memory Usage Restrictions and setup Resource Limits (RLimitMEM and RLimitCPU) to, well, limit CPU and memory resources.

The problem comes when sometimes, it doesn’t work as intended. So, you have to remove it. The easiest way is to edit /usr/local/apache/conf/httpd.conf, remove or comment out the RLimit lines, distill it and restart Apache. That’s what this script does, using sed to make the edit. It’s faster and it’s more precise, and it’s reversible (since I only commented out the lines rather than remove them.)

sed -i 's/^RLimit/#RLimit/g' /usr/local/apache/conf/httpd.conf
/usr/local/cpanel/bin/apache_conf_distiller --update
service httpd restart

You only need to log in to a shell prompt as root, and paste in the script. Make sure to press Enter after the “service httpd restart” to make sure Apache restarts. This should eliminate the error “libgcc_s.so.1 must be installed for pthread_cancel to work”.

Did this fix work for you? Share it with your friends using the link below, and leave a comment and let me know!

© Ryan's Techs Tidbits