Adding O365 & EOP IPs to Exchange Receive Connector

As my colleague pointed out earlier there have been some new additions to the IP list for O365, if you are like us and keep a tight hold on the IPs allowed to speak to your Exchange receive connectors this can involve a lengthy process of adding these IPs individually. However there is a command you can run, although be aware this replaces everything in the current connector – it does not add.

To get the current IPs in the connector run:

Get-ReceiveConnector -Identity “SERVERNAMECONNECTORNAME” | select -ExpandProperty RemoteIpRanges | select expression | Out-File c:current.txt

This will give you a nice little text file list of all the IPs.

Alternatively you can grab the IPs from the O365 website (remember to get the EOP ones too if you use it):

https://technet.microsoft.com/en-us/library/hh373144.aspx

https://technet.microsoft.com/library/dn163583(v=exchg.150).aspx

Should you wish to just add these ones, heres the command to replace your current connectors IPs:

Set-ReceiveConnector -Identity “SERVERNAMECONNECTORNAME” –RemoteIPRanges 23.103.132.0/22,40.107.0.0/16,64.4.22.64/26,94.245.120.64/26,157.56.112.0/24,157.56.206.0/24,157.56.208.0/22,207.46.100.0/24,213.199.154.0/24,
23.103.160.0/20,23.103.224.0/19,40.97.0.0/16,40.98.0.0/16,40.100.0.0/16,40.101.0.0/16,40.105.0.0/16,65.54.62.0/25,65.55.39.128/25,70.37.151.128/25,
131.253.33.215,191.234.192.0/19,157.55.9.128/25,157.55.157.128/25,157.55.224.128/25,191.234.6.152,191.234.140.0/22,191.234.224.0/22,204.79.197.215,
206.191.224.0/19,207.46.4.128/25,207.46.58.128/25,207.46.198.0/25,207.46.203.128/26,65.55.169.0/24,65.55.83.128/27,23.130.156.0/22,23.103.200.0/21,
23.103.198.0/23,23.103.191.0/24,23.103.128.0/19,23.103.134.0/23,23.103.132.0/23,207.46.101.128/26,157.56.111.0/24,157.56.110.0/24,157.56.108.0/24,
157.56.87.192/26,157.56.73.0/24,157.55.234.0/24,157.55.206.0/23,157.55.158.0/23,157.55.133.160/27,134.170.171.0/24,134.170.140.0/24,134.170.132.0/24,104.47.0.0/17,
216.32.181.0/24,12.129.199.61,12.129.219.155,63.241.222.0/24,65.55.88.0/24,206.16.57.70,207.46.51.64/26,207.46.163.0/24,213.199.180.128/26,216.32.180.0/24,12.129.20.0/24,
212.140.172.68,213.199.148.0/23,207.46.206.0/23,207.46.150.128/25,207.46.73.250,207.46.70.0/24,207.46.57.128/25,207.46.216.54,157.56.236.0/22,157.56.200.0/23,157.56.151.0/25,
157.55.227.192/26,157.55.194.46,157.55.185.100,157.55.155.0/25,157.55.145.0/25,157.55.130.0/25,157.55.59.128/25,157.56.58.0/25,157.56.55.0/25,157.56.53.128/25,157.56.23.32/27,132.245.0.0/16,
111.221.127.112/28,111.221.111.196,111.221.71.0/25,111.221.70.0/25,111.221.24.0/21,111.221.16.0/21,94.245.108.85,94.245.117.53,94.245.86.0/24,94.245.84.0/24,94.245.82.0/23,
94.245.68.0/22,70.37.159.0/24,70.37.142.0/23,70.37.128.0/23,70.37.97.234,65.55.239.168,65.55.233.0/27,65.55.86.0/23,65.54.165.0/25,65.54.80.0/20,65.54.74.0/23,
65.54.55.201,65.54.54.32/27,65.52.240.233,65.52.208.73,65.52.196.64,65.52.184.75,65.52.148.27,
213.199.182.128/25

Unfortunately to get the command into the post i had to add some new lines so just delete carriage returns in the above.

Alternatively grab the list from your text file and just add the new ones!

Hope it helps!

About the author