Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Monday, June 15, 2020

udev renamed network interface eth0 to ...

udev renamed network interface eth0 to eth1 / eth2 (dmesg | grep eth)
Above message you'll hardly find while working on physical machine.
I have not faced this message on Citrix Xenserver, probably xenserver tools takes care of this.

This is what I faced while cloning one of VM on KVM. After cloning one of CentOS VM network wasn't working.

To resolve this, all you need is to remove / comment following lines from one of /etc/udev/rules.d/ files

Here I found eth0 entry in 70-persistent-net.rules

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:fe:18:e6", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:c2:b2:d3", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"


Once above lines removed / commented, you'll be able to configure interface as eth0.
You can also change eth1 / eth2 to eth0 for the relevant mac address.

Tuesday, June 9, 2020

SSH / SCP key authentication

Many time bash scrip demands scp. OR you may not wish to enter password every time you access remote server.
Generate key for local system.
ssh-keygen -t rsa
Copy key to remote server.
ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.1.1
Now you can ssh / scp without entering password.
For old system not equipped with ssh-copy-id
ssh-keygen -t rsa
scp ~/.ssh/id_rsa.pub root@192.168.1.1:
ssh root@192.168.1.1 ‘cat id_rsa.pub >> .ssh/authorized_keys’

Tuesday, June 2, 2020

NTP Client on CentOS / Fedora

NTP Client configuration.
It is very easy to configure NTP client on Linux machine.
Just two steps required to sync clock.
yum install ntp
ntpdate -u 1.pool.ntp.org
You can configure cron job to run 2nd step on schedule OR you can put in /etc/rc.local

Saturday, April 18, 2009

Squid Proxy



Squid is a caching proxy server.
Squid is a caching proxy for the Web supporting HTTP, HTTPS, FTP, and more. It reduces bandwidth and improves response times by caching and reusing frequently-requested web pages. Squid has extensive access controls and makes a great server accelerator. It runs on most available operating systems, including Windows and is licensed under the GNU GPL.
Read More

Squid is available with major linux distributions like CentOS, Fedora.

To install Squid
yum install squid

To configure Squid.
vi /etc/squid/squid.conf
visible_hostname test.squid

Restart Squid Service
service squid restart

Use your local squid proxy server ip address & port 3128 (squid default port) to configure in internet clients. While accessing internet you’ll get error Access Denied.

To allow internet access to your local lan.
vi /etc/squid/squid.conf
acl myuser src 192.168.1.0/255.255.255.0
http_access allow myuser

To allow all internet sites, blocking few e.g jobs, community.
acl myuser src 192.168.1.0/255.255.255.0
acl deniedsites url_regex “/etc/squid/denied” #list of the sites blocked
http_access deny myuser deniedsites #to block ban sites
http_access allow myuser

To disabled caching for specific sites, you might require to disable caching for few sites e.g intranet site.
acl MYSITES url_regex “/etc/squid/nocache”
no_cache deny MYSITES

Squid with ARP instead ip address.
You may be using DHCP with minimum lease time, in this case you require to filter sites using MAC ADD instead of ip address.

You need to compile Squid from source with --enable-arp-acl (use squid -v & add all existing configuration option.)
acl yahoomailuser arp “/etc/squid/yahoomailuser” #list of the user’s mac add
acl yahoomail url_regex “/etc/squid/yahoomail” #url allowed
http_access allow yahoomailuser yahoomail

Transparent proxy.
vi /etc/squid/squid.con
http_port 192.168.1.1:3128 transparent # squid local ip address

OR

http_port 3128 transparent

Transparent proxy is used when you do not wish to define proxy settings in clients terminal, for that you need to do port redirection using iptables over gateway.
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3128