Showing posts with label centos. Show all posts
Showing posts with label centos. Show all posts

Sunday, March 22, 2020

Change outbound connections IP for Mail

Hello admins, the server will start to send the Spam mails due to malicious code or compromised mailbox. In that case, our outgoing IP address will get blocked by several spam filters including Gmail and other mail services.

In this case, we have to wait for a long time to get whitelisted or have to pay to be whitelisted. But if you have secondary IP addresses for your server, we can do this trick to send emails and let the main IP to whitelist automatically.

This means we will change to outbound connections from the main IP to the secondary IP address.

Important: Before proceeding with this, make sure that you have fixed the compromised code or application or mailbox. Else, your secondary IP address will also get blocked on Spam filters.

Default IP for outgoing connections can be set using ‘ip’ utility.
First of all, check how routing is configured on the server:

You can check this by the following command: -
# /sbin/ip route
159.8.30.64/28 dev bond1 proto kernel scope link src 159.8.30.66
10.105.124.128/26 dev bond0 proto kernel scope link src 10.105.124.130
169.254.0.0/16 dev bond0 scope link metric 1006
169.254.0.0/16 dev bond1 scope link metric 1007
10.0.0.0/8 via 10.105.124.129 dev bond0
default via 159.8.30.65 dev bond1
If no ‘src’ listed in ‘ip’ output for the default route, then the main IP on the interface is used for outgoing connections. You can change it using:
# /sbin/ip route change default via 159.8.30.65 dev bond1 src 5.153.43.25
Now:
# /sbin/ip route
192.168.50.0/24 dev eth1 proto kernel scope link src 192.168.50.53
169.254.0.0/16 dev eth1 scope link
default via 192.168.50.254 dev eth1 src 192.168.50.100

Note: be careful, if you set the wrong IP as the source, you lose the connection to the server.

Wednesday, March 8, 2017

Device eth0 does not seem to be present, delaying initialization - Virtual Box Error - CentOS 6.6

Hello everyone,

Today I've faced an error on Virtual Box with CentOS 6.6 today, If you are frequently use virtual machines, you'll see these kind of errors. Let's explain my situation.

I've installed and used CentOS 6.6 for python before 2 months, later I've deleted it's account (not files) from Virtual Box because of no frequent use. Today I need to test something on that server. So I've created account and pointed this virtual machine to newly created account.

Once server up, logged to server and tried to ping for check the network. Network not succeeded, when I check IP with ifconfig, I can see only loopback network. "service network restart" says "Device eth0 does not seem to be present, delaying initialization".

Okay, What is solution now ?

Reason for this issue: When we install guest OS with virtual box, It'll assign mac address to it's guest OS's device. But in our case, we have installed guest OS already and it already assigned some mac address. When we create account again and merge guest OS with it, we will get conflict with 2 different mac address. One was created during original installation of guest OS, another one is created during recreate of virtualbox guest OS account.

To fix this,

Login to OS, remove the file as mentioned bellow, which have old mac address.

# rm /etc/udev/rules.d/70-persistent-net.rules

Reboot server, so that new fill will be generated again,

# reboot

Now open the file,
# cat /etc/udev/rules.d/70-persistent-net.rules

It'll look as mentioned bellow,

# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:17:ef:c5:08", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

Note down the ATTR{address}

open following file

# vim /etc/sysconfig/network-scripts/ifcfg-eth0

Replace mac address which you copied to HWADDR
Remove line with UUID

Now restart the network service,

# service network restart

That's It. Now you can able access network on guest OS.

Tuesday, June 3, 2014

Timezone restore in Linux

We got problem in Centos 6 server with plesk panel,

Timezone got reset frequently on one that server, I've found the issue on update of tzdata package, Working on it to find permanent solution, But in mean time I've used following script for reset timezone.

# /bin/sh
TZ=`date '+%Z'`
CTIME=` date '+%Y/%m/%d'-'%T'`
if [[ "$TZ" != IST ]] ; then
touch /var/log/timezone-script.log
echo "["$CTIME"]" "Current time-zone is" $TZ "and Needs to change" >> /var/log/timezone-script.log
rm -f /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Kolkata /etc/localtime
else
echo "["$CTIME"]" "Current time-zone is" $TZ "and Working fine" >> /var/log/timezone-script.log
fi
Change your timezone what you need, I'm using IST and using log file to know status. Even we can use mail function on it.
 Default location of timezone is /usr/share/zoneinfo/