Page not found – ShopingServer Wiki http://wiki.shopingserver.com Tutorials and Articles About Technology and Gadgets Wed, 02 Sep 2020 02:23:24 +0000 en-US hourly 1 https://wordpress.org/?v=5.5.14 http://wiki.shopingserver.com/wp-content/uploads/2018/07/cropped-favicon-150x150.png Page not found – ShopingServer Wiki http://wiki.shopingserver.com 32 32 Mac OS X: Wake Up Servers Using Wake-on-LAN ( WOL ) Command Utility http://wiki.shopingserver.com/mac-os-x-wake-servers-using-wake-lan-wol-command-utility/ http://wiki.shopingserver.com/mac-os-x-wake-servers-using-wake-lan-wol-command-utility/#respond Sat, 06 Jan 2018 10:15:08 +0000 http://wiki.shopingserver.com/?p=18591 I know how to send WOL command using Linux or FreeBSD wake command. But, how do I send Wake on LAN (WOL) frames to hosts on a local Ethernet network using Apple OS X Unix operating systems to wake up my servers or nas devices?

 

You need to use the wakeonlan Perl script that generates and transmits a Wake-On-LAN (WOL) “Magic Packet”, used for restarting machines that have been soft powered-down (ACPI D3-warm state).

Method #1: Install wakeonlan using Homebrew

Open the Terminal app and type the following command:

brew install wakeonlan

Sample outputs:

Fig.01: OS X brew install wakeonlan client

Method #2: Download and install wakeonlan Perl script

Open a terminal and type the following curl command:

$ mkdir -p $HOME/bin

$ curl https://raw.githubusercontent.com/jpoliv/wakeonlan/master/wakeonlan -o ~/bin/wakeonlan

$ chmod +x ~/bin/wakeonlan

How do I send WOL on a OS X?

The syntax is:

$ ~/bin/wakeonlan server-mac-address-here

 

For example, if nas01 server has 00:08:9b:c4:30:30 mac address, enter:

$ ~/bin/wakeonlan 00:08:9b:c4:30:30

 

Sample outputs:

Sending magic packet to 255.255.255.255:9 with 00:08:9b:c4:30:30

Other options

-i ip_address

set the destination IP address

default: 255.255.255.255 (the limited broadcast address)

-p port

set the destination port

default: 9 (the discard port)

-f file

uses file as a source of hardware addresses

Apple computer wake for network access (WOL) setting

If you want other users to be able to access your Apple OS X based computer’s shared resources, such as shared printers/files/folders or iTunes playlists, even when your computer is in sleep mode. Open System Preferences > choose “Energy Saver preferences“. This set options that control your computer’s energy use including WOL for all Mac Based server and client systems:

Fig.01: OS X setting WOL

Make sure you select the option “Wake for network access” so that other users can wake up your computer using WOL magic packet.

References

wakeonlan(1) for more information.

Download Wakeonlan: Perl script for waking up computers via Wake-On-LAN magic packets

HowTo: Wake Up Computers Using Linux Command [ Wake-on-LAN ( WOL ) ]

 

 

]]>
http://wiki.shopingserver.com/mac-os-x-wake-servers-using-wake-lan-wol-command-utility/feed/ 0
Linux: Find Out What Is Using TCP Port 80 http://wiki.shopingserver.com/linux-find-using-tcp-port-80/ http://wiki.shopingserver.com/linux-find-using-tcp-port-80/#respond Sat, 06 Jan 2018 09:53:19 +0000 http://wiki.shopingserver.com/?p=18561 H

ow do I find out what is listing or using tcp port number 80 on Linux based systems using command line options?

 

You can use any one of the following command to find out what is using tcp or udp port number 80 on Linux operating systems:

netstat – a command-line tool that displays network connections, routing tables, and a number of network interface statistics.

fuser – a command line tool to identify processes using files or sockets.

lsof – a command line tool to list open files under Linux / UNIX to report a list of all open files and the processes that opened them.

/proc/$pid/ file system – Under Linux /proc includes a directory for each running process (including kernel processes) at /proc/PID, containing information about that process, notably including the processes name that opened port.

Examples

Open a terminal and then type the following command as root user:

netstat command find out what is using port 80

Type the following command

# netstat -tulpn | grep :80

 

OR pass the –color option to grep command as follows:

# netstat -tulpn | grep –color :80

 

Sample outputs:

tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      1215/nginx

Where,

0 0.0.0.0:80 – Source IP:Port

1215/nginx – PID/Process name

The tcp port 80 is opened and used by nginx web server. Type the following command to find out more about nginx:

whatis nginx

whereis nginx

Note: You may need to install lsof and fuser command.

Use /proc/$pid/exec file find out what is using port 80

First, find out the processes PID that opened tcp port 90, enter:

# fuser 80/tcp

 

Sample outputs:

80/tcp:              12161 21776 25250 25393

Finally, find out process name associated with PID # 3813, enter:

# ls -l /proc/12161/exe

 

Sample outputs:

lrwxrwxrwx. 1 root root 0 Aug  9 13:28 /proc/12161/exe -> /usr/sbin/lighttpd

Find out more about lighttpd:

man lighttpd

whatis lighttpd

whereis lighttpd

Sample outputs:

lighttpd             (8)  – a fast, secure and flexible web server

lighttpd: /usr/sbin/lighttpd /usr/lib64/lighttpd /usr/share/man/man8/lighttpd.8.gz

You can use package manager to dig into lighttpd:

# rpm -qa | grep lighttpd

 

Sample outputs:

lighttpd-1.4.32-1.el6.x86_64

To find out more about lighttpd-1.4.32-1.el6.x86_64 package, type:

# yum info lighttpd-1.4.32-1.el6.x86_64

 

Sample outputs:

Loaded plugins: auto-update-debuginfo, protectbase, rhnplugin, security

This system is receiving updates from RHN Classic or RHN Satellite.

0 packages excluded due to repository protections

Installed Packages

Name        : lighttpd

Arch        : x86_64

Version     : 1.4.32

Release     : 1.el6

Size        : 664 k

Repo        : installed

Summary     : A web server more optimized for speed-critical environments.

URL         : http://lighttpd.net/

License     : Revised BSD

Description : It is a secure and fast web server a very low memory footprint compared

: to other webservers and takes care of cpu-load.

OR use rpm command:

# rpm -qi lighttpd

 

Sample outputs:

Name        : lighttpd                     Relocations: (not relocatable)

Version     : 1.4.32                            Vendor: nixCraft

Release     : 1.el6                         Build Date: Sun 03 Feb 2013 03:22:08 AM CST

Install Date: Mon 04 Feb 2013 04:44:26 AM CST      Build Host: rhel6.nixcraft.net.in

Group       : System Environment/Daemons    Source RPM: lighttpd-1.4.32-1.el6.src.rpm

Size        : 680402                           License: Revised BSD

Signature   : (none)

URL         : http://lighttpd.net/

Summary     : A web server more optimized for speed-critical environments.

Description :

It is a secure and fast web server a very low memory footprint compared

to other webservers and takes care of cpu-load.

Debian / Ubuntu Linux user can use the following commands:

# dpkg –list | grep lighttpd

# apt-cache search lighttpd

# apt-cache show lighttpd

 

Sample outputs from the last command:

Package: lighttpd

Priority: optional

Section: universe/web

Installed-Size: 841

Maintainer: Ubuntu Developers

Original-Maintainer: Debian lighttpd maintainers

Architecture: amd64

Version: 1.4.28-2ubuntu4

Provides: httpd, httpd-cgi

Depends: libattr1 (>= 1:2.4.46-5), libbz2-1.0, libc6 (>= 2.4), libgamin0 | libfam0, libldap-2.4-2 (>= 2.4.7), libpcre3 (>= 8.10), libssl1.0.0 (>= 1.0.0), zlib1g (>= 1:1.1.4), lsb-base (>= 3.2-14), mime-support, libterm-readline-perl-perl

Recommends: spawn-fcgi

Suggests: openssl, rrdtool, apache2-utils, ufw

Conflicts: cherokee (<= 0.6.1-1)

Filename: pool/universe/l/lighttpd/lighttpd_1.4.28-2ubuntu4_amd64.deb

Size: 279838

MD5sum: 65aedfd0e0ab6d3ee28e7b394567ed22

SHA1: 34a9156fa3d23635eb24efb436de585c0594f046

SHA256: 751d6f8309d249740d7aab240a74b6bae713e524cf6815544b6cdbb6107fded2

Description-en: A fast webserver with minimal memory footprint

lighttpd is a small webserver and fast webserver developed with

security in mind and a lot of features.

It has support for

* CGI, FastCGI and SSI

* virtual hosts

* URL rewriting

* authentication (plain files, htpasswd, ldap)

* transparent content compression

* conditional configuration

and configuration is straight-forward and easy.

Homepage: http://www.lighttpd.net

Description-md5: 267ee2989b526d8253e822e7d8244ccd

Bugs: https://bugs.launchpad.net/ubuntu/+filebug

Origin: Ubuntu

lsof command find out what is using port 80

Type the following command

# lsof -i :80 | grep LISTEN

 

Sample outputs:

apache2   1607     root    3u  IPv4   6472      0t0  TCP *:www (LISTEN)

apache2   1616 www-data    3u  IPv4   6472      0t0  TCP *:www (LISTEN)

apache2   1617 www-data    3u  IPv4   6472      0t0  TCP *:www (LISTEN)

See also

Linux: Find Out Which Process Is Listening Upon a Port

ss: Display Linux TCP / UDP Network and Socket Information

See man pages for more info lsof(8),fuser(1),proc(5),netstat(8),ss(8)

 

 

]]>
http://wiki.shopingserver.com/linux-find-using-tcp-port-80/feed/ 0
CentOS / RHEL: Install iftop To Display Bandwidth Usage Per interface By Host http://wiki.shopingserver.com/centos-rhel-install-iftop-display-bandwidth-usage-per-interface-host/ http://wiki.shopingserver.com/centos-rhel-install-iftop-display-bandwidth-usage-per-interface-host/#respond Sat, 06 Jan 2018 09:20:47 +0000 http://wiki.shopingserver.com/?p=18523 I

am running Red Hat Enterprise Linux on IBM based system. How do I display bandwidth usage on an interface by host in real time using command line option? How do I monitor bandwidth usage in a real time on RHEL or CentOS Linux based server? How can I install iftop utility on CentOS or RHEL server using the yum command?

 

You can install and use iftop utility on Linux. This command listens to network traffic on a given interface (such as eth0 or eth1), and shows a table of current bandwidth usage by pairs of hosts. iftop must be run with sufficient permissions (usually as root user) to monitor all network traffic on the interface.

Install iftop

First, turn on EPEL repo on Linux. See how to install and enable epel repo on CentOS / RHEL / Scientific Linux v4.x/5.x/6.x for more information. Type the following yum command to install iftop on RHEL/CentOS/Fedora Linux:

# yum -y install iftop

 

Sample outputs:

Fig.01: iftop installed using yum command

How do I use iftop command?

The syntax is:

iftop

iftop [options]

iftop -i interface

iftop -i eth0 -f filter_code

Examples

Simply type the following command to monitor traffic on eth0:

# iftop -i eth0

 

Sample outputs:

Animated gif 01: iftop in action on CentOS/RHEL

DON’T DO DNS HOSTNAME LOOKUPS

By default, iftop will look up the hostnames associated with addresses it finds in packets. Pass the -n option to disable dns lookup:

# iftop -n -i eth0

HIDE SERVICE NAME AND PORT NUMBERS

Pass the -N option to hide resolve port number to service names:

# iftop -N -i eth0

FIND OUT PACKETS FLOWING IN AND OUT OF 192.168.1.0/24 NETWORK

Use the -F option to set net/mask for traffic analysis. In this example, find out packets flowing in and out of the 192.168.1.0/24 network. This is useful to find out if why the network is slow:

# iftop -F 192.168.1.0/255.255.255.0 -i eth0

ICMP BANDWIDTH STATS

Find out more about icmp ping requests and bandwidth usage per interface by host. Use the -f to set filter:

# iftop -f icmp -i eth0

HIDE BAR GRAPHS

Pass the -b option to turn off display bar graphs of traffic:

# iftop -b -i eth0

Pass the -B option to display bandwidth rates in bytes/sec rather than bits/sec:

# iftop -B -i eth0

IMPORTANT KEYBOARD SHORTCUTS

Press t control display type. The t cycles through the four line display modes; the default 2-line display, with sent and received traffic on separate lines, and 3 1-line displays, with sent, received, or total traffic shown.

Press P to pause the current display.

Press o to freeze the current screen order. This has the side effect that traffic between hosts not shown on the screen at the time will not be shown at all, although it will be included in the totals at the bottom of the screen.

Press j and k to scroll the display of hosts. This is useful for busy servers.

Recommended readings

Keeping a Log Of Daily Network Traffic for ADSL or Dedicated Remote Linux Server

Linux: Check Network Connection Command

Man pages: iftop(8),tcpdump(8)

 

 

]]>
http://wiki.shopingserver.com/centos-rhel-install-iftop-display-bandwidth-usage-per-interface-host/feed/ 0
OpenBSD: Reload / Restart / Stop dhcpd Server Command http://wiki.shopingserver.com/openbsd-reload-restart-stop-dhcpd-server-command/ http://wiki.shopingserver.com/openbsd-reload-restart-stop-dhcpd-server-command/#respond Sat, 06 Jan 2018 09:10:03 +0000 http://wiki.shopingserver.com/?p=18509 I

manage MS-Windows server and recently started to play with OpenBSD server. How do I reload or restart the dhcpd server on OpenBSD using shell command line option?

 

If you made changes to the configuration of your DHCP (dhcpd) server, you will have to stop and restart the server manually. On OpenBSD and Unix like operating system, you kill the dhcpd server and restart manually. Another option is to send HUP (SIGHUP) to dhcpd server.

Method#1: Find dhcpd PID and kill it

Type the following ps command to find dhcpd PID as root user:

# ps ax | grep dhcpd

 

Sample outputs:

USER       PID %CPU %MEM   VSZ   RSS TT   STAT STARTED       TIME COMMAND

_dhcp    13420  0.0  0.1   588   568 ??  Ss    10:27PM    0:00.04 dhcpd re0

You need to kill that process with kill command.

# kill -9 13420

To start dhcpd, type the following commands:

# touch /var/db/dhcpd.leases

# dhcpd -q re0

Method #2: Say hello to /etc/rc.d/dhcpd script

You can skip all of the above commands. Use rc script as follows to start, stop, restart, and check dhcpd server on OpenBSD:

/etc/rc.d/dhcpd start

/etc/rc.d/dhcpd stop

/etc/rc.d/dhcpd restart

/etc/rc.d/dhcpd check

 

 

]]>
http://wiki.shopingserver.com/openbsd-reload-restart-stop-dhcpd-server-command/feed/ 0
Increase NFS Client Mount Point Security For a Web-Server noexec, nosuid, nodev Options http://wiki.shopingserver.com/increase-nfs-client-mount-point-security-web-server-noexec-nosuid-nodev-options/ http://wiki.shopingserver.com/increase-nfs-client-mount-point-security-web-server-noexec-nosuid-nodev-options/#respond Sat, 06 Jan 2018 08:32:55 +0000 http://wiki.shopingserver.com/?p=18467 I

am using NFS server version 4.x on a CentOS/RHEL based system. I’m mounting my shared /var/www/ directory on five Apache based nodes using the following syntax:

mount -t nfs4 -o rw,intr,hard,proto=tcp rocknas02:/httproot/www /var/www/

I noticed that due to bug in my app user can sometime upload executable or other device files to get out of chrooted Apache server. How can I prevent such security issues on a CentOS or RHEL based NFS client and sever setup?

 

First, you need to fix your application. Next, you can pass the following three options to mount command to increase overall security on Apache/Nginx/Lighttpd nfs based client:

noexec – Prevents execution of binaries on mounted file systems. This prevents remote users from executing unwanted binaries on your system.

nosuid – Disables set-user-identifier or set-group-identifier bits. This prevents remote users from gaining higher privileges by running a setuid program.

nodev – Prevents character and block special devices from being defined, or if they exist, from being used as character and block special devices. This prevents remote users from getting out of chrooted server jails.

Modify your mount command as follows:

# mount -t nfs4 -o rw,intr,hard,proto=tcp,nodev,noexec,nosuid rocknas02:/httproot/www /var/www/

 

OR attempt to remount an already-mounted nfsv4.0 filesystem:

# mount -t nfs4 -o remount,rw,intr,hard,proto=tcp,nodev,noexec,nosuid rocknas02:/httproot/www /var/www/

Test it

To verify new settings, enter:

# mount

# mount | grep rocknas02

 

Sample outputs:

rocknas02:/httproot/www on /var/www type nfs4 (rw,noexec,nosuid,nodev,sync,intr,hard,proto=tcp,addr=192.168.1.10,clientaddr=192.168.1.100)

Copy /bin/ls to rocknas02:/httproot/www i.e. type the following on your nfsv4.0 server called rocknas02

# cp /bin/ls /httproot/www

 

On client, type:

cd /var/www

 

run /bin/ls

ls -l

 

# Run uploaded ls

./ls

Sample outputs:

Fig. 01: Running ls command on nfs client

 

Updating /etc/fstab is left as an exercise for the reader.

Mount the filesystem read-only

If possible mount the filesystem in read-only mode. Modify your mount command as follows:

# mount -t nfs4 -o ro,intr,hard,proto=tcp,nodev,noexec,nosuid rocknas02:/httproot/www /var/www/

 

OR attempt to remount an already-mounted nfsv4.0 filesystem:

# mount -t nfs4 -o remount,ro,intr,hard,proto=tcp,nodev,noexec,nosuid rocknas02:/httproot/www /var/www/

Recommend file/directory permission for Apache

I suggest the following schema:

Run Apache as apache user and group

You must run httpd as root initially and it will switch to apache user and group:

# egrep -i  ^(User|Group)  /etc/httpd/conf/httpd.conf

 

Sample outputs:

User apache

Group apache

NFS server file/directory permission for /var/www/

Create a user called www-files using useradd command:

# useradd -d /var/www -M -s /sbin/nologin www-files

 

Make sure you lock www-files account using passwd command:

# passwd -l www-files

 

Change file owner and group to www-files for /var/www directory use the following passwd command:

# chown -R www-files:www-files /var/www/

 

Finally changes the file mode bits of each given file and directory according to mode:

By default all files & dirs permissions are set to read-only ###

chmod -R 0444 /var/www

 

Allow, apache/nginx/lighttpd to serve files from directory by settings others to x bit ###

find /var/www -type d -print0 | xargs -0 -I {} chmod 0445  {}

 

Optional certain directory may need additional permissions such as /var/www/uploads ###

#chmod  0777 -R /var/www/uploads

Use ls -l command to verify file permissions:

# cd /var/www

# ls -l

 

Sample outputs:

total 32

-r–r–r–. 1 www-files www-files  606 Dec 21  2011 best_resources.php

-r–r–r–. 1 www-files www-files 1068 Sep  4  2011 cdn_info_linux_unix_setup.php

dr–r–r-x. 2 www-files www-files 4096 Aug  5  2012 data

….

-r–r–r–. 1 www-files www-files 1550 Jun 22  2012 service-per-vm-guide.php

See also

How to configure php to deny file uploads.

This entry is 15 of 15 in the Linux / UNIX NFS File Server Tutorial series. Keep reading the rest of the series:

CentOS / Redhat: Setup NFS v4.0 File Server

Debian / Ubuntu Linux: Setup NFSv4 File Server

Mac Os X: Mount NFS Share / Set an NFS Client

RHEL: How Do I Start and Stop NFS Service?

How To Restart Linux NFS Server Properly When Network Become Unavailable

Linux Iptables Allow NFS Clients to Access the NFS Server

Debian / Ubuntu Linux Disable / Remove All NFS Services

Linux: Tune NFS Performance

Mount NFS file system over a slow and busy network

Linux Track NFS Directory / Disk I/O Stats

Linux Disable / Remove All NFS Services

Linux: NFS4 mount Error reason given by server: No such file or directory

Linux NFS Mount: wrong fs type, bad option, bad superblock on fs2:/data3 Error And Solution

CentOS / RHEL CacheFS: Speed Up Network File System (NFS) File Access

Increase NFS Client Mount Point Security

 

 

]]>
http://wiki.shopingserver.com/increase-nfs-client-mount-point-security-web-server-noexec-nosuid-nodev-options/feed/ 0
Linux: Log Suspicious Martian Packets / Un-routable Source Addresses http://wiki.shopingserver.com/linux-log-suspicious-martian-packets-un-routable-source-addresses/ http://wiki.shopingserver.com/linux-log-suspicious-martian-packets-un-routable-source-addresses/#respond Sat, 06 Jan 2018 08:31:07 +0000 http://wiki.shopingserver.com/?p=18465 I

run a web-server and I would like to log packets with un-routable source addresses on Linux operating system. How can I log spoofed packets on Debian / Ubuntu / CentOS / RHEL / Linux based server? How can I log a Martian packet (packet from Mars) on Linux operating systems?

 

A Martian packet is nothing but an IP packet which specifies a source or destination address that is reserved for special-use by Internet Assigned Numbers Authority (IANA). Here are examples of such address blocks:

10.0.0.0/8

127.0.0.0/8

224.0.0.0/4

240.0.0.0/4

::/128

::/96

::1/128

How can I log Martian packets on Linux?

You need to use sysctl command command to view or set Linux kernel variables that can logs packets with un-routable source addresses to the kernel log file such as /var/log/messages.

See current settings

Type the following command:

# sysctl -a| grep martians

 

Sample outputs:

Fig. 01: Find out if suspicious packets are logged or not on Linux

Value 0 indicates that the suspicious martian packets are not logged on the system.

How do I log suspicious martian packets on Linux?

You need to set the following variables to 1 in /etc/sysctl.conf file:

net.ipv4.conf.all.log_martians

net.ipv4.conf.default.log_martians

Edit file /etc/sysctl.conf, enter:

# vi /etc/sysctl.conf

 

Append/edit as follows:

net.ipv4.conf.all.log_martians=1

net.ipv4.conf.default.log_martians=1

Save and close the file. To load changes, type:

# sysctl -p

How can I modify active kernel parameters on command line?

Alternatively, you can toggle active kernel parameters using the following bash for loop syntax:

Grab all Linux kernel vars in $x ##

x=$(sysctl -a| grep martians | awk  { print $1} )

Just display it on screen ##

echo  $x

 

Alright, toggle all vars to 1 or 0 as per your requirements ##

for i in $x

do

/sbin/sysctl -w ${i}=1

done

 

Verify settings ##

sysctl -a| grep martians

Sample outputs:

Fig.02: Bash for loop to log suspicious packets

How can I see logged suspicious martian packets logs on Linux?

Use the grep command as follows:

cd /var/log

grep -i –color martian messages*

Sample outputs:

messages-20120101:Dec 31 09:25:45 nixcraft-router kernel: martian source 74.xx.47.yy from 10.13.106.25, on dev eth1

messages-20120101:Dec 31 09:25:53 nixcraft-router kernel: martian source 74.xx.47.yy from 10.13.106.25, on dev eth1

messages-20120101:Dec 31 09:26:10 nixcraft-router kernel: martian source 74.xx.47.yy from 10.13.106.25, on dev eth1

messages-20120101:Dec 31 14:04:12 nixcraft-router kernel: martian source 74.xx.47.yy from 10.1.97.141, on dev eth1

messages-20120101:Dec 31 14:04:14 nixcraft-router kernel: martian source 74.xx.47.yy from 10.1.97.141, on dev eth1

messages-20120101:Dec 31 14:04:18 nixcraft-router kernel: martian source 74.xx.47.yy from 10.1.97.141, on dev eth1

messages-20120101:Dec 31 14:04:22 nixcraft-router kernel: martian source 74.xx.47.yy from 10.1.97.141, on dev eth1

messages-20120101:Dec 31 14:04:26 nixcraft-router kernel: martian source 74.xx.47.yy from 10.1.97.141, on dev eth1

messages-20120101:Dec 31 14:04:34 nixcraft-router kernel: martian source 74.xx.47.yy from 10.1.97.141, on dev eth1

messages-20120101:Dec 31 14:04:50 nixcraft-router kernel: martian source 74.xx.47.yy from 10.1.97.141, on dev eth1

messages-20120101:Jan  1 00:01:59 nixcraft-router kernel: martian source 74.xx.47.yy from 10.13.105.141, on dev eth1

messages-20120101:Jan  1 00:02:00 nixcraft-router kernel: martian source 74.xx.47.yy from 10.13.105.141, on dev eth1

messages-20120101:Jan  1 00:02:02 nixcraft-router kernel: martian source 74.xx.47.yy from 10.13.105.141, on dev eth1

messages-20120101:Jan  1 00:02:06 nixcraft-router kernel: martian source 74.xx.47.yy from 10.13.105.141, on dev eth1

messages-20120101:Jan  1 00:02:10 nixcraft-router kernel: martian source 74.xx.47.yy from 10.13.105.141, on dev eth1

messages-20120101:Jan  1 00:02:14 nixcraft-router kernel: martian source 74.xx.47.yy from 10.13.105.141, on dev eth1

messages-20120101:Jan  1 00:02:22 nixcraft-router kernel: martian source 74.xx.47.yy from 10.13.105.141, on dev eth1

messages-20120101:Jan  1 00:02:38 nixcraft-router kernel: martian source 74.xx.47.yy from 10.13.105.141, on dev eth1

How do I block martian packets using firewall?

See how to use iptables to block spoofing and bad address attack that tries to fool the server and try to claim that packets had come from local address/network.

Log and drop packets with suspicious source addresses

eth1 is wan port on server ##

/sbin/iptables -A INPUT -i eth1 -s 10.0.0.0/8 -j LOG –log-prefix  IP DROP SPOOF A:

/sbin/iptables -A INPUT -i eth1 -s 172.16.0.0/12 -j LOG –log-prefix  IP DROP SPOOF B:

/sbin/iptables -A INPUT -i eth1 -s 192.168.0.0/16 -j LOG –log-prefix  IP DROP SPOOF C:

/sbin/iptables -A INPUT -i eth1 -s 224.0.0.0/4 -j LOG –log-prefix  IP DROP MULTICAST D:

/sbin/iptables -A INPUT -i eth1 -s 240.0.0.0/5 -j LOG –log-prefix  IP DROP SPOOF E:

/sbin/iptables -A INPUT -i eth1 -d 127.0.0.0/8 -j LOG –log-prefix  IP DROP LOOPBACK:

 

/sbin/iptables -A INPUT -i eth1 -s 10.0.0.0/8 -j DROP

/sbin/iptables -A INPUT -i eth1 -s 172.16.0.0/12 -j DROP

/sbin/iptables -A INPUT -i eth1 -s 192.168.0.0/16 -j DROP

/sbin/iptables -A INPUT -i eth1 -s 224.0.0.0/4 -j DROP

/sbin/iptables -A INPUT -i eth1 -s 240.0.0.0/5 -j DROP

/sbin/iptables -A INPUT -i eth1 -d 127.0.0.0/8 -j DROP

 

/sbin/iptables-save > /root/my-iptables.rules

See also

Linux Kernel /etc/sysctl.conf Security Hardening

martian – A packet sent on a TCP/IP network with a source address of the test loopback interface [127.0.0.1]. This means that it will come back labeled with a source address that is clearly not of this earth. “The domain server is getting lots of packets from Mars. Does that gateway have a martian filter?”

 

 

]]>
http://wiki.shopingserver.com/linux-log-suspicious-martian-packets-un-routable-source-addresses/feed/ 0
curl Command Resume Broken Download http://wiki.shopingserver.com/curl-command-resume-broken-download/ http://wiki.shopingserver.com/curl-command-resume-broken-download/#respond Sat, 06 Jan 2018 08:25:08 +0000 http://wiki.shopingserver.com/?p=18457 I

know wget can resume a failed download. I am on a Mac OS X and do now want to install wget command. How can I resume a failed download using curl command on Linux or Unix-like systems?

 

You can continue getting a partially downloaded file using curl command. You need to pass the -C or –continue-at <offset> option resume a previous file transfer at the given offset.

curl resume broken download

COMMAND command

The syntax is as follows to to automatically find out where/how to resume the transfer using curl command:

curl -C – url

OR

curl -L -O -C – url

OR

curl -L -o  filename-here  -C – url

In this example, finish a download started by a previous instance of curl command:

 

curl -L -O -C – http://ftp.ussg.iu.edu/linux/centos/6.5/isos/x86_64/CentOS-6.5-x86_64-bin-DVD1.iso

 

Animated gif 01: Resume a broken download

If there is a file named CentOS-6.5-x86_64-bin-DVD1.iso in the current directory, curl will assume that it is the first portion of the remote file, and will ask the server to continue the retrieval from an offset equal to the length of the local file. Thus, it will result in saving both time and bandwidth.

Another example

You can continue a previous file transfer at the given offset. The given offset is the exact number of bytes that will be skipped, counting from the beginning of the source file before it is transferred to the destination. The syntax is:

curl -C offset url

In this example, retrieve ifdata-welcome-0.png file using the following command:

Get first 20000 bytes ##

curl  -o file.png –header  Range: bytes=0-20000  http://www.cyberciti.biz/media/images/misc/static/2012/11/ifdata-welcome-0.png

 

Resume at 20001 offset and download the rest of the file ##

curl -o file.png -C 20001 http://www.cyberciti.biz/media/images/misc/static/2012/11/ifdata-welcome-0.png

 

View an image file using a local image viewer ##

ls -lh file.png

open file.png

Sample outputs from ls command:

-rw-r–r–@ 1 vivek  wheel    30K Feb 28 23:24 file.png

Understanding options

-L – Follow location if HTTP 3xx status code found. For example, redirect url.

-O – Write output to a local file named like the remote file we get. Only the file part of the remote file is used, the path is cut off.

-C – Continue/Resume a previous file transfer.

-C offsetAT – Continue/Resume a previous file transfer at the given offset.

-o  filename  – Write/Save output to ‘filename’ instead of stdout/screen.

See also

Testing HTTP Status: 206 Partial Content and Range Requests

curl Linux and Unix command examples

Man pages – curl(1)

 

 

]]>
http://wiki.shopingserver.com/curl-command-resume-broken-download/feed/ 0
Fedora Linux 20: Install Broadcom-wl STA BCM43228 Wireless Driver http://wiki.shopingserver.com/fedora-linux-20-install-broadcom-wl-sta-bcm43228-wireless-driver/ http://wiki.shopingserver.com/fedora-linux-20-install-broadcom-wl-sta-bcm43228-wireless-driver/#respond Sat, 06 Jan 2018 07:50:36 +0000 http://wiki.shopingserver.com/?p=18413 I

‘m using Dell / Lenovo laptop with Broadcom’s IEEE 802.11a/b/g/n based wireless card. How can I install Broadcom-wl STA BCM4322 Wireless driver on a Fedora Linux version 20?

 

Broadcom’s IEEE 802.11a/b/g/n driver can be installed on any Linux disruption including Fedora Linux version 20. The driver (broadcom-wl and kmod-wl) works with the following Wireless chipsets only:

BCM4311

BCM4312

BCM4313

BCM4321

BCM4322

BCM43224

BCM43225

BCM43227

BCM43228

Finding out your chipset / wireless card name on a Fedora Linux

Open the Terminal app and type the following shell command:

$ lspci

$ lspci | grep -i broadcom

 

Sample outputs:

Fig.01: Fedora Linux Find Supported Broadcom Wireless Devices Name/Chipset

How do I use Broadcom wireless cards in Fedora version 19/20?

Fedora Linux provides a version of this driver via rpmfusion repo. All you’ve to do is configure rpmfusion repo and install the driver.

Step #1: Enable rpmfusion repo

Open the Terminal app and type the following command:

# yum localinstall –nogpgcheck \

http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm \

yum localinstall –nogpgcheck http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm

 

Sample outputs:

Loaded plugins: langpacks, refresh-packagekit

rpmfusion-free-release-20.noarch.rpm                   |  15 kB     00:00

Examining /var/tmp/yum-root-Gh9BLR/rpmfusion-free-release-20.noarch.rpm: rpmfusion-free-release-20-1.noarch

Marking /var/tmp/yum-root-Gh9BLR/rpmfusion-free-release-20.noarch.rpm to be installed

Skipping: yum, filename does not end in .rpm.

Skipping: localinstall, filename does not end in .rpm.

rpmfusion-nonfree-release-20.noarch.rpm                |  15 kB     00:00

Examining /var/tmp/yum-root-Gh9BLR/rpmfusion-nonfree-release-20.noarch.rpm: rpmfusion-nonfree-release-20-1.noarch

Marking /var/tmp/yum-root-Gh9BLR/rpmfusion-nonfree-release-20.noarch.rpm to be installed

Resolving Dependencies

–> Running transaction check

—> Package rpmfusion-free-release.noarch 0:20-1 will be installed

—> Package rpmfusion-nonfree-release.noarch 0:20-1 will be installed

–> Finished Dependency Resolution

 

Dependencies Resolved

 

==============================================================================

Package               Arch   Version

Repository                            Size

==============================================================================

Installing:

rpmfusion-free-release

noarch 20-1 /rpmfusion-free-release-20.noarch    9.7 k

rpmfusion-nonfree-release

noarch 20-1 /rpmfusion-nonfree-release-20.noarch 9.9 k

 

Transaction Summary

==============================================================================

Install  2 Packages

 

Total size: 20 k

Installed size: 20 k

Is this ok [y/d/N]: y

Downloading packages:

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

Warning: RPMDB altered outside of yum.

Installing : rpmfusion-free-release-20-1.noarch                         1/2

Installing : rpmfusion-nonfree-release-20-1.noarch                      2/2

Verifying  : rpmfusion-free-release-20-1.noarch                         1/2

Verifying  : rpmfusion-nonfree-release-20-1.noarch                      2/2

 

Installed:

rpmfusion-free-release.noarch 0:20-1

rpmfusion-nonfree-release.noarch 0:20-1

 

Complete!

Step #2: Install Broadcom Wireless Drivers on Linux Fedora 20

Type the following yum command:

# yum search kmod-wl

*** COMMENT: update the system *** ##

# yum update

*** COMMENT: if a new kernel was installed reboot the system, before installing kmod-wl using following command i.e. reboot and issue the following command *** ##

# yum install kmod-wl

 

Sample outputs:

Loaded plugins: langpacks, refresh-packagekit

Resolving Dependencies

–> Running transaction check

—> Package kmod-wl.x86_64 0:6.30.223.141-5.fc20.22 will be installed

–> Processing Dependency: kmod-wl-3.14.4-200.fc20.x86_64 >= 6.30.223.141-5.fc20.22 for package: kmod-wl-6.30.223.141-5.fc20.22.x86_64

–> Running transaction check

—> Package kmod-wl-3.14.4-200.fc20.x86_64.x86_64 0:6.30.223.141-5.fc20.22 will be installed

–> Processing Dependency: wl-kmod-common >= 6.30.223.141 for package: kmod-wl-3.14.4-200.fc20.x86_64-6.30.223.141-5.fc20.22.x86_64

–> Running transaction check

—> Package broadcom-wl.noarch 0:6.30.223.141-2.fc20 will be installed

–> Finished Dependency Resolution

 

Dependencies Resolved

 

===========================================================================================

Package                     Arch   Version                Repository                 Size

===========================================================================================

Installing:

kmod-wl                     x86_64 6.30.223.141-5.fc20.22 rpmfusion-nonfree-updates  14 k

Installing for dependencies:

broadcom-wl                 noarch 6.30.223.141-2.fc20    rpmfusion-nonfree          19 k

kmod-wl-3.14.4-200.fc20.x86_64

x86_64 6.30.223.141-5.fc20.22 rpmfusion-nonfree-updates 1.1 M

 

Transaction Summary

===========================================================================================

Install  1 Package (+2 Dependent packages)

 

Total download size: 1.2 M

Installed size: 5.1 M

Is this ok [y/d/N]: y

Downloading packages:

warning: /var/cache/yum/x86_64/20/rpmfusion-nonfree/packages/broadcom-wl-6.30.223.141-2.fc20.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID b5f29883: NOKEY

Public key for broadcom-wl-6.30.223.141-2.fc20.noarch.rpm is not installed

(1/3): broadcom-wl-6.30.223.141-2.fc20.noarch.rpm                   |  19 kB  00:00:01

Public key for kmod-wl-6.30.223.141-5.fc20.22.x86_64.rpm is not installed

(2/3): kmod-wl-6.30.223.141-5.fc20.22.x86_64.rpm                    |  14 kB  00:00:01

(3/3): kmod-wl-3.14.4-200.fc20.x86_64-6.30.223.141-5.fc20.22.x86_64 | 1.1 MB  00:00:04


Total                                                      250 kB/s | 1.2 MB  00:00:04

Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmfusion-nonfree-fedora-20

Importing GPG key 0xB5F29883:

Userid     :  RPM Fusion nonfree repository for Fedora (20) <rpmfusion-buildsys@lists.rpmfusion.org>

Fingerprint: a84d cf58 46cb 10b6 5c47 6c35 63c0 de8c b5f2 9883

Package    : rpmfusion-nonfree-release-20-1.noarch (@/rpmfusion-nonfree-release-20.noarch)

From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-rpmfusion-nonfree-fedora-20

Is this ok [y/N]: y

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

Installing : kmod-wl-3.14.4-200.fc20.x86_64-6.30.223.141-5.fc20.22.x86_64            1/3

Installing : broadcom-wl-6.30.223.141-2.fc20.noarch                                  2/3

Installing : kmod-wl-6.30.223.141-5.fc20.22.x86_64                                   3/3

Verifying  : broadcom-wl-6.30.223.141-2.fc20.noarch                                  1/3

Verifying  : kmod-wl-3.14.4-200.fc20.x86_64-6.30.223.141-5.fc20.22.x86_64            2/3

Verifying  : kmod-wl-6.30.223.141-5.fc20.22.x86_64                                   3/3

 

Installed:

kmod-wl.x86_64 0:6.30.223.141-5.fc20.22

 

Dependency Installed:

broadcom-wl.noarch 0:6.30.223.141-2.fc20

kmod-wl-3.14.4-200.fc20.x86_64.x86_64 0:6.30.223.141-5.fc20.22

 

Complete!

Step #3: Reboot the system

Type the following reboot command to reboot the Linux based system:

# reboot

Step #4: Verify and connect to the Wireless network

Type the following command to verify that wireless interface is up and running:

$ ifconfig

$ iwconfig

 

Sample outputs:

wlp1s0    IEEE 802.11abg  ESSID:off/any

Mode:Managed  Access Point: Not-Associated   Tx-Power=200 dBm

Retry short limit:7   RTS thr:off   Fragment thr:off

Encryption key:off

Power Management:off

 

lo        no wireless extensions.

 

p1p1      no wireless extensions.

You can now connect to your wireless network using Network Manager (top right side) > Select Wi-Fi > Select Network > Select a network > Connect > Enter password for wireless network:

Fig.02: Fedora Linux Wireless Connection

References

Brodcom 802.11 Linux STA driver source code.

b43 and b43legacy are drivers for the 802.11b/g/n family of wireless chips that Broadcom produces.

 

 

]]>
http://wiki.shopingserver.com/fedora-linux-20-install-broadcom-wl-sta-bcm43228-wireless-driver/feed/ 0
CentOS / RHEL 7 Restart / Stop / Start Networking Command http://wiki.shopingserver.com/centos-rhel-7-restart-stop-start-networking-command/ http://wiki.shopingserver.com/centos-rhel-7-restart-stop-start-networking-command/#respond Fri, 05 Jan 2018 16:23:37 +0000 http://wiki.shopingserver.com/?p=18391 I

recently installed CentOS Linux version 7 or Red Hat Enterprise Linux version 7. How can I restart networking service using command line options? How can I start / stop and restart networking service on a CentOS/RHEL 7 based system?

 

CentOS 7 / RHEL 7 / Fedora Linux (many other modern distor) uses Systemd. It is a system and service manager for Linux operating systems. In newer distro such as CentOS7/RHEL7 systemd replaces Upstart as the default init system.

In older versions of CentOS or Red Hat Enterprise Linux, you used init scripts located in the /etc/rc.d/init.d/ directory. These init scripts were typically written in Bash, and allowed the system administrator to control the state of services and daemons in their system. In CentOS/RHEL 7, these init scripts have been replaced with service units.

CentOS 7 / RHEL 7 networking service name

To bring up/down networking service you need to use the network.service.

Say hello to systemctl command

Use this command to control the systemd system and act as a service manager.

CentOS 7 / RHEL 7 get status of network service

sudo systemctl status network.service

OR

sudo systemctl status network

Sample outputs:

Fig.01: CentOS / RHEL 7 Networking Service Status Command

CentOS 7 / RHEL 7 restart network service

sudo systemctl restart network.service

OR

sudo systemctl restart network

CentOS 7 / RHEL 7 start network service

sudo systemctl start network.service

OR

sudo systemctl start network

CentOS 7 / RHEL 7 stop network service

sudo systemctl stop network.service

OR

sudo systemctl stop network

Sample outputs:

Animated gif 01: systemctl command in action

A note about old service and chkconfig command

The service and chkconfig commands are still available in the system and work as expected, but are only included for compatibility reasons and should be avoided as may be dropped in future release.

 

 

]]>
http://wiki.shopingserver.com/centos-rhel-7-restart-stop-start-networking-command/feed/ 0
FreeBSD Force DHCP Client (dhclient) to Renew IP Address To Get A New Lease http://wiki.shopingserver.com/freebsd-force-dhcp-client-dhclient-renew-ip-address-get-new-lease/ http://wiki.shopingserver.com/freebsd-force-dhcp-client-dhclient-renew-ip-address-get-new-lease/#respond Fri, 05 Jan 2018 15:50:34 +0000 http://wiki.shopingserver.com/?p=18353 I

have a Linux DD-WRT router DHCP server running on my network. How can I force my FreeBSD based dhcp client to get a new lease from this Linux based router? What is the command in FreeBSD equivalent to Windows’ “ipconfig /renew” command?

 

The dhclient command, provides a means for configuring one or more network interfaces using the Dynamic Host Configuration Protocol, BOOTP protocol, or if these protocols fail, by statically assigning an address.

FreeBSD renew ip command

The syntax is:

dhclient interface-name-here

dhclient [options] interface-name-here

The name of the interface must be specified on the command line. You must run this command as the root user.

How can I see the current IP address settings?

Type the following command:

ifconfig

ifconfig interface

ifconfig em0

ifconfig em0 | grep inet

Sample outputs:

Fig.01: FreeBSD Display Current IP Address, Netmask and Ethernet Options

How can I renew or release an IP in FreeBSD for em0 interface?

The syntax is:

$ sudo dhclient em0

 

#################################

OR first use  su –  and then type ##

#################################

# dhclient em0

Sample outputs:

Fig.02: Renew an IP address on FreeBSD using dhclient

Other options in FreeBSD to renew dhcp IP address

You can also use the following command to renew dhcp IP address for em0:

service dhclient restart em0

 

OR ##

/etc/rc.d/dhclient restart em0

Sample outputs:

Stopping dhclient.

Starting dhclient.

DHCPREQUEST on em0 to 255.255.255.255 port 67

DHCPACK from 192.168.1.254

bound to 192.168.1.142 — renewal in 43200 seconds.

dhclient log file

In order to keep track of leases across system reboots and server restarts, dhclient keeps a list of leases it has been assigned in the /var/db/dhclient.leases.IFNAME file. IFNAME represents the network interface of the DHCP client (e.g., em0), one for each interface:

tail -f /var/db/dhclient.leases.em0

OR

less /var/db/dhclient.leases.em0

Sample outputs:

lease {

interface  em0 ;

fixed-address 192.168.1.142;

next-server 192.168.1.254;

option subnet-mask 255.255.255.0;

option routers 192.168.1.254;

option domain-name-servers 192.168.1.254;

option host-name  freebsd10 ;

option broadcast-address 192.168.1.255;

option dhcp-lease-time 86400;

option dhcp-message-type 5;

option dhcp-server-identifier 192.168.1.254;

option dhcp-renewal-time 43200;

option dhcp-rebinding-time 75600;

renew 0 2015/2/1 21:38:04;

rebind 1 2015/2/2 06:38:04;

expire 1 2015/2/2 09:38:04;

}

lease {

interface  em0 ;

fixed-address 192.168.1.142;

next-server 192.168.1.254;

option subnet-mask 255.255.255.0;

option routers 192.168.1.254;

option domain-name-servers 192.168.1.254;

option host-name  freebsd10 ;

option broadcast-address 192.168.1.255;

option dhcp-lease-time 86400;

option dhcp-message-type 5;

option dhcp-server-identifier 192.168.1.254;

option dhcp-renewal-time 43200;

option dhcp-rebinding-time 75600;

renew 0 2015/2/1 21:44:47;

rebind 1 2015/2/2 06:44:47;

expire 1 2015/2/2 09:44:47;

}

References

See dhclient man page for more info on a FreeBSD server:

$ man dhclient

 

 

]]>
http://wiki.shopingserver.com/freebsd-force-dhcp-client-dhclient-renew-ip-address-get-new-lease/feed/ 0