Posted: . At: 9:07 PM. This was 10 years ago. Post ID: 7392
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.


Useful Linux networking tricks.


Change the mac address of your network adapter.

sudo ifconfig wlan0 down && sudo ifconfig wlan0 hw ether 00:11:22:33:44:55 && sudo ifconfig wlan0 up

This will change the mac address of your network interface instantly. Below is an example.

homer@deusexmachina ~ $ sudo ifconfig eth0 down && sudo ifconfig eth0 hw ether 00:11:22:33:44:55 && sudo ifconfig eth0 up
[sudo] password for homer: 
homer@deusexmachina ~ $ ifconfig 
eth0      Link encap:Ethernet  HWaddr 00:11:22:33:44:55  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

Another way to change your mac address. Using the macchanger utility.

homer@deusexmachina ~ $ sudo macchanger -m DE:AD:BE:EF:00:00 eth0
Permanent MAC: 00:13:46:3a:02:83 (D-link Corporation)
Current   MAC: 00:11:22:33:44:55 (Cimsys Inc)
New       MAC: de:ad:be:ef:00:00 (unknown)

Create a HTTP file server for a directory. This is good for quickly sharing the contents of a folder from your Linux machine to the Internet or a LAN.

python -m SimpleHTTPServer

Ping an ipv6 address. The ping6 command handles this admirably.

homer@deusexmachina ~ $ ping6 2001:470:1f06:1b5::2
PING 2001:470:1f06:1b5::2(2001:470:1f06:1b5::2) 56 data bytes
64 bytes from 2001:470:1f06:1b5::2: icmp_seq=1 ttl=64 time=0.046 ms
64 bytes from 2001:470:1f06:1b5::2: icmp_seq=2 ttl=64 time=0.050 ms
64 bytes from 2001:470:1f06:1b5::2: icmp_seq=3 ttl=64 time=0.050 ms
64 bytes from 2001:470:1f06:1b5::2: icmp_seq=4 ttl=64 time=0.051 ms
64 bytes from 2001:470:1f06:1b5::2: icmp_seq=5 ttl=64 time=0.054 ms
64 bytes from 2001:470:1f06:1b5::2: icmp_seq=6 ttl=64 time=0.054 ms
64 bytes from 2001:470:1f06:1b5::2: icmp_seq=7 ttl=64 time=0.062 ms
64 bytes from 2001:470:1f06:1b5::2: icmp_seq=8 ttl=64 time=0.055 ms
64 bytes from 2001:470:1f06:1b5::2: icmp_seq=9 ttl=64 time=0.057 ms
64 bytes from 2001:470:1f06:1b5::2: icmp_seq=10 ttl=64 time=0.054 ms
64 bytes from 2001:470:1f06:1b5::2: icmp_seq=11 ttl=64 time=0.055 ms
64 bytes from 2001:470:1f06:1b5::2: icmp_seq=12 ttl=64 time=0.053 ms
64 bytes from 2001:470:1f06:1b5::2: icmp_seq=13 ttl=64 time=0.054 ms
64 bytes from 2001:470:1f06:1b5::2: icmp_seq=14 ttl=64 time=0.058 ms
64 bytes from 2001:470:1f06:1b5::2: icmp_seq=15 ttl=64 time=0.054 ms
64 bytes from 2001:470:1f06:1b5::2: icmp_seq=16 ttl=64 time=0.054 ms
64 bytes from 2001:470:1f06:1b5::2: icmp_seq=17 ttl=64 time=0.055 ms
64 bytes from 2001:470:1f06:1b5::2: icmp_seq=18 ttl=64 time=0.054 ms
64 bytes from 2001:470:1f06:1b5::2: icmp_seq=19 ttl=64 time=0.054 ms
^C
--- 2001:470:1f06:1b5::2 ping statistics ---
19 packets transmitted, 19 received, 0% packet loss, time 17996ms
rtt min/avg/max/mdev = 0.046/0.053/0.062/0.010 ms

Get information about a host with the dig command.

homer@deusexmachina ~ $ dig slashdot.org
 
; <<>> DiG 9.9.3-rpz2+rl.13214.22-P2-Ubuntu-1:9.9.3.dfsg.P2-4ubuntu1.1 <<>> slashdot.org
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 60382
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
 
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;slashdot.org.			IN	A
 
;; ANSWER SECTION:
slashdot.org.		86	IN	A	216.34.181.45
 
;; Query time: 67 msec
;; SERVER: 127.0.1.1#53(127.0.1.1)
;; WHEN: Sun Jun 15 16:19:32 EST 2014
;; MSG SIZE  rcvd: 57

1 thought on “Useful Linux networking tricks.”

  1. You can also change the MAC address using iproute2

    ip link set dev wlan0 down &amp;&amp; 
    ip link set dev wlan0 address XX:XX:XX:XX:XX:XX &amp;&amp; 
    ip link set dev wlan0 up
    Reply

Leave a Reply to RoseHosting Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.