Showing posts with label networking. Show all posts
Showing posts with label networking. Show all posts

Mar 24, 2012

Slow Mac WiFi but Internet Fine on PC?

Occasionally, my internet gets REALLY slow on my laptop. Then I go use my wife's PC and everything is fine. Since few things are more aggravating than Windows machines working better than Macs, I decided to post this solution so I won't forget it.

Problem

MacBook Pro internet is slow over wifi and ethernet.

Symptoms

  • After opening several tabs, they all show no content--just perpetual spinning
  • Things worked fine for a few seconds, then suddenly, everything is slow
  • You see none of these issues on your Windows machine on the same network
  • You do not have this issue on your mobile phone or tablet, using WiFi

Solution

Add DNS servers in "System Preferences > Network" under the "Advanced" options. By default, my settings were pointing to Comcast. Once I added Open DNS, instead, everything worked fine.


As an added bonus, you can create an account at opendns.com and get some pretty cool features.

Mar 2, 2011

Clients and Servers on the Terminal: Simple File Transfers

I just stumbled across an interesting shell command: nc

It's used for simple client/server interactions from the shell. With it, you can do interesting things like take output from one machine, send it over the network to another machine that pipes this input into other commands. Here's an example:
# On the destination machine
nc -l -p 2345 | tar xv
# On the source machine
tar c PATH_TO_FILES > /dev/tcp/IP.OF.DESTINATION/2345
Which will tar PATH_TO_FILES, on the source machine and transmit it over the network on port 2345. The destination will receive the data and pipe it into a command that will extract the tar.

This is so useful, I had to jot it down!

Jul 15, 2010

Linux Equivalent of ipconfig renew and ipconfig release on Windows

I've looked this up 3 times so I finally decided to jot it down so I don't forget it.

Problem

Can't remember the Linux commands equivalent to:
ipconfig renew
ipconfig release

Symptoms

  • Your IP is assigned via DHCP on a Linux box
  • You've unplugged from one network and plugged into another and the old IP address hasn't cleared out
  • Don't want to shutdown/restart the interface you just want to refresh the DHCP settings

Solution

sudo /sbin/dhclient -r is equivalent to ipconfig release
sudo /sbin/dhclient is equivalent to ipconfig renew
sudo /sbin/ifconfig is equivalent to ipconfig
The dhclient command broadcasts a DHCP message to your DHCP server, resulting in a new lease. A slower way to achieve the same result is to shutdown the interface and bring it back up via (assuming your target interface is eth0):
sudo /sbin/ifdown eth0
sudo /sbin/ifup eth0
This same, slower approach can also be done graphically on RedHat by clicking System > Administration > Network, choosing your interface (eth0) and clicking deactivate followed by activate.

Feb 11, 2010

Mac OS X : Open Ports, Network Connections, PIDs

Yesterday, my MacBook Pro was acting VERY strangely. I was hacked! (or so I thought) I feared that some evildoer hacked my home network and ran amuck.

Quickly, I had to figure out what was happening on my network. I wanted to know what ports were open, what connections were live and which applications were using those connections. Finding Linux info was easy. Mac OS X info? Not so much!

After hunting dozens of Google pages, here's what I've come up with:

Check All Network Connections
Run the following shell command to display all network connections:
netstat -an | grep 'LIS\|WAIT\|Recv-Q'

This will show all ESTABLISHED, LISTEN and TIME_WAIT connections and also displays the header for convenience.
Show Processes On Network
The command above is good but it doesn't show you WHO is on those ports. The following allows us to see the PID and Name of each process using the network!
sudo lsof -Pnl +M -i

Note: the first flag is -PNL (the last character is not a one). The first time I ran the lsof command, I couldn't see the ports that were listening. This was my main concern (evildoers love listening on ports). The key is to run this command as root (via sudo). Also note, with the netstat call, you can use egrep 'LIS|WAIT'. Honestly, I haven't gotten around to learning what egrep does. All I know is you don't have to escape the | symbol with egrep.