Exchange Server External Relay

Allow anonymous forwarding on Exchange Server Relay

An open relay is a very bad thing for messaging servers on the Internet.

SMTP relays that have been accidentally or intentionally configured as open relays allow you to transparently route e-mail from any source through the open relay server.

This behavior masks the original source of the messages and makes them look as if the email originated from the open relay server.

Open relay servers are eagerly searched and used by spammers.

550 5.7.54 SMTP; Unable to relay recipient in non-accepted domain

On the other hand, anonymous relay is a common requirement for many organizations that have internal Web servers, database servers. Monitoring equipment, or other network devices that generate e-mail messages but cannot actually send and deliver those messages.

Exchange 2019 Set up SMTP external relay in the Powershell

Exchange Servers can use a FrontEndTransport service on a Mailbox server to provide a dedicated receive connector that allows anonymous forwarding from a specific list of internal network hosts.

To do this, run the following command in the Exchange management shell for the appropriate dedicated receive connector:

PS C:> Set-ReceiveConnector "EXCH19-Frontend Anonymous Relay" -AuthMechanism ExternalAuthoritative -PermissionGroups ExchangeServers

In this example, the Exchange 2019 Server EXCH19 with the Frontend Anonymous Relay as the Receive Connector.

Check that the anonymous Exchange SMTP relay is successfully configured with the following command:

PS C:> Get-ReceiveConnector "EXCH19-Frontend Anonymous Relay" | Format-List Enabled,TransportRole,Bindings,RemoteIPRanges
Exchange Server External Relay

Ping in the PowerShell with Test-Connection

PowerShell ICMP Ping Test-Connection

Powershell Test-Connection has its own cmdlet to send Ping ICMP packets to other computers to check their availability. Compared to conventional ping, it offers more options, such as addressing multiple target computers at the same time. Basically, you can also call the Windows utility Ping.exe in PowerShell.

The Test-Connection cmdlet in PowerShell 7 includes advanced features such as Repeat and Traceroute or as a ping process in the background.

Examples Ping with Test-Connection in PowerShell

The Test-Connection Powershell cmdlet sends Ping Internet Control Message Protocol (ICMP) Echo request packets to one or more comma-separated remote hosts and returns the Echo responses.

PS C:\> Test-Connection 8.8.8.8, 8.8.4.4, time.google.com

With the -Repeat option, as is known from Ping, ICMP requests are sent to the specified host until the end of the operation, by entering CTRL+BREAK.

PS C:\> Test-Connection 1.1.1.1 -Repeat

This example shows how to run a test connection command as a PowerShell background job.

PS C:\> $job = Start-Job -ScriptBlock { Test-Connection -TargetName (Get-Content -Path "Servers.txt") }
$Results = Receive-Job $job -Wait

Traceroute with Test-NetConnection

Use Traceroute in PowerShell 5.1 which is installed by default in Windows 10.

PS C:\> Test-NetConnection 1.1.1.1 -TraceRoute

ComputerName           : 1.1.1.1
RemoteAddress          : 1.1.1.1
InterfaceAlias         : WLAN
SourceAddress          : 192.168.1.3
PingSucceeded          : True
PingReplyDetails (RTT) : 5 ms
TraceRoute             : 192.168.1.1
                         85.7.42.1
                         193.134.95.170
                         138.187.131.211
                         138.187.129.97
                         1.1.1.1

Traceroute with Test-Connection in PowerShell

The Traceroute parameter introduced in PowerShell 6.0 arranges route tracking between the local computer and the remote destination specified by parameters.

PS C:\> Test-Connection www.google.com -Traceroute -IPv4

Note. using traceroute it need PowerShell 6 or newer.

In another example, parameters are used to customize the Test Connection command. The local computer sends a ping test to a remote computer.

PS C:\> Test-Connection -TargetName Server10 -Count 4 -Delay 2 -MaxHops 128 -BufferSize 256

This cmdlet is available from PowerShell 6.0 and later.

Test-Connection TCP Port Parameters

The parameter -TcpPort specifies the TCP port number to the destination to use in the TCP connection test. The cmdlet attempts to establish a TCP connection with the specified port to the destination.

PS C:\> Test-Connection -TargetName isc.org -TcpPort 443

If a connection can be established, $True is returned. If a connection cannot be established, $False is returned. The Paramter -TcpPort is available from PowerShell 7.0 and later.

Test-Connection MTU Size Parameters

The parameter -MtuSize is used to determine the path MTU size.

PS C:\> Test-Connection -TargetName ripe.org -MtuSize

The cmdlet returns a PingReply MTU Size object that contains the MTU size path to the target, it is available from PowerShell 7.0 and later.

Test-Connection Parameter Quiet

The parameter -Quiet returns a Boolean value. Using this parameter to suppresses all errors.

PS C:\> Test-Connection -TargetName iana.org -Quiet

This cmdlet is available from PowerShell 7.0 and later.

PowerShell Remoting Test-Connection

The next example creates a session to Server2 if at least one of the pings sent to the computer succeeds. To do this, you must configure TrustedHosts on the remote computer.

PS C:\> if (Test-Connection -TargetName Server2 -Quiet) { New-PSSession -ComputerName Server2 }

To use HTTP for PowerShell remoting, run the following command on the remote host from Command Prompt as administrator.

winrm quickconfig

The TrustedHosts configuration setting is done by running winrm.cmd with the config/client option on the remote host.

winrm set winrm/config/client @{TrustedHosts="192.168.1.2"}

Accept reply from 192.168.1.2. The query for the Global Configuration of WinRM is as follows.

winrm get winrm/config/client
Exit mobile version