How to configure Postfix to allow one IP to relay to any destination? - smtp

I have a local Postfix which is used to relay emails from local network to local domain users.
I should now allow one sender IP address to be able to relay to any destination email domain.
Current configuration looks like:
main.cf
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination<br>
smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/allowed_senders, reject
smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/allowed_recipients, reject
mynetworks = 10.10.0.0/16
relayhost = mydomain.mail.protection.outlook.com:25
allowed_senders
mydomain.com OK
allowed_recipients
mydomain.com OK
How can I whitelist one sender IP address to send to any domain but keep the other restrictions in place?

Related

Is there a way to "mask" an smtp server?

I am using a service for smtp relay and they give me a smtp server url (mail.theirdomain).. I wanted to ask if there is any way of "masking" this for example with some dns records to make the mail.theirdomain, mail.mydomain?
Sure, you can do a DNS lookup of mail.theirdomain.com and see what IP address this hostname points to (e.g. x.x.x.x). Then, you can create a hostname mail.mydomain.com, and point this hostname to the same IP address (x.x.x.x).
But, if you do a reverse DNS lookup (i.e. PTR lookup) of x.x.x.x, it will likely point to mail.theirdomain.com (not mail.mydomain.com), and you can't change this, because you do not have control of x.x.x.x.
Also, if you open an SMTP connection to mail.mydomain.com, it will likely show mail.theirdomain.com in the SMTP banner that the server responds with after a client connects - and this is not something that you can change either.

Replacing old ip address in ubuntu server database with new ip address

I want to update my old IP address from MySQL with my new IP address. How can I do this?
Since the IP address on the server is renewed, I want to recognize a new IP address to the database.
Ubuntu-16
Nginx

Plesk NodeJS Express app cannot connect to MySQL on same server

I am trying to get my Plesk NodeJS Express app to establish a connection with a mySQL database table on the same server
I am running the latest Plesk on a Ubuntu server.
I have a domain (domain.com) and a subdomain called api.domain.com
I have installed a nodejs application for the api.domain.com via the interface and it is running and will return sample route return data as long as it is not querying the database.
I have installed a database under domain.com and it shows api.domain.com on the interface to the side where it says add-on domains also.
I have tried connecting to this database from my local machine and also from the node application but it will not work locally and I assume it will not work from the node application either.
I checked var/log/apache2/logs/error.log and it does not seem to throw an error for the initial connection in the start of the nodejs app:
const connection = mysql.createConnection({
host: 'localhost',
user: 'admin',
password: 'secretpassword',
database: 'app',
});
connection.connect(err => {
if (err) throw err;
console.log('Connected!');
});
because in the error.log it does show the Connected! so it seems to have a connection?
But in my test route nothing is shown except: 'Cannot GET /people/1' on the browser
I also have 2 different rows added with data in the people table within the app database.
app.get('people/:id', (req, res) => {
console.log('Fetching data with id' + req.params.id);
const id = req.params.id;
const queryString = "SELECT * FROM people WHERE id = ?";
connection.query(queryString, [id], (err, rows, fields) =>
{
console.log('I think we fetched'); // this does not show
res.json(rows);
});
});
In the database management for the user it is set to Allow remote connections from any host
From the firewall screen it seems to allow all incoming connections:
FTP server passive ports Allow incoming from all
Customer & Business Manager payment gateways Allow incoming from all
Single Sign-On Allow incoming from all
Plesk Installer Allow incoming from all
Plesk administrative interface Allow incoming from all
WWW server Allow incoming from all
FTP server Allow incoming from all
SSH (secure shell) server Allow incoming from all
SMTP (submission port) server Allow incoming from all
SMTP (mail sending) server Allow incoming from all
POP3 (mail retrieval) server Allow incoming from all
IMAP (mail retrieval) server Allow incoming from all
Mail password change service Allow incoming from all
MySQL server Allow incoming from all
PostgreSQL server Allow incoming from all
Samba (file sharing in Windows networks) Allow incoming from all
Plesk VPN Allow incoming from all
Domain name server Allow incoming from all
IPv6 Neighbor Discovery Allow incoming from all
Ping service Allow incoming from all

Can't connect my Google Cloud SQL to my local PhpMyAdmin

I am having a problem connecting google cloud sql to my local phpmyadmin.
Here's what I did:
set up a new user
put my public ip address in the Authorized networks
paste the following code below on my phpmyadmin config.inc.php
.
$i++;
$cfg['Servers'][$i]['verbose'] = 'Google Cloud SQL';
$cfg['Servers'][$i]['host'] = '(my google cloud sql ip)';
$cfg['Servers'][$i]['auth_type'] = 'cookie';
I tested and put 0.0.0.0/0 on my Authorized networks for the server to accept any incoming IP, just to test it out on my localhost and yes It works.
It seems like my public IP address in not being Authorized? Even though I put my public IP address in there?
Side note: I just googled my public IP address
Let me know your thoughts.
Thank you so much

How to connect to MySQL database from another PC online? VB.NET

Here is my connection string
mySqlCon.ConnectionString = "server=testserver.noip.me; port=3306; database=testserver1; uid=admin; pwd=admin"
I have created a vb.net application with TryCatch function to check MySql connection.
My server testserver.noip.me is a hostname of my public ip (The hostname is an example, if you check the port online, it wont work). If I change the server to localhost/127.0.0.1 or my private ip address which is something like 192.168.0.xx, the result is connected just fine. Able to connect to database even on another PC but within the same wifi network.
Whenever I change it to my public ip address or my hostname, the application returns an error message :
"Unable to connect to any of the specified MySQL hosts."
Here is the code
Try
mySqlCon.Open()
If mySqlCon.State = ConnectionState.Open Then
Label5.Text = "Online"
Label5.ForeColor = Color.GreenYellow
LoginBtn.Enabled = True
Else
Label5.Text = "Offline"
Label5.ForeColor = Color.LightPink
LoginBtn.BackColor = Color.Red
End If
mySqlCon.Close()
Catch ex As MySqlException
If mySqlCon.State = ConnectionState.Open Then
mySqlCon.Close()
End If
Finally
mySqlCon.Dispose()
End Try
I have also done port forward in my router and the result is fine :
And the hostname port 3306 check is open as well:
Extra info : I have installed connectornet and is using MySQL workbench for this.
Everything is working fine on local network but not online. Any idea what I should do to make the application connect to the database successfully from another network online? No SSH or any secure connection guide please because this is just a test server.
In your MYSQL (source machine) you have to enable the destination domain name for access rights.
In the host table add your destination IP.
It's Because You Did Not Forward Port.
Go to Your Router Settings, Find Port Forwarding Add A Service With HTTP, Enter Your Local IP Address, Then Specify 3306 Port As Ending Port.
This Worked For Me. Perhaps It Will For You Too.