blog posts

How can you Remove an IP or IPs in MikroTik VPS by CLI(Command Line Interface)2023?

First, we will tell you what Mikrotik is and the Ways to connect to the Mikrotik router. The we will talk about How to Remove an IP or IPs in MikroTik VPS by CLI(Command Line Interface)?

What is Mikrotik? Mikrotik company review and history

Like other professors, I wanted to start training Mikrotik from the history of Mikrotik and where it came from. Still, I saw that you can read these words on most of the web sites and other places, and from there, friends and those who are looking for Mikrotik training do not have much patience, and soon They want to get to the conclusion, I said I’ll get to the point quickly. First of all, I have to say that Mikrotik is the name of a company in Latvia that produces network equipment. Still, the most important product of this company is an operating system called Mikrotik.

Mikrotik is an operating system that is made from the Linux kernel, and it can be installed on ordinary computers; of course, this company also has hardware such as router boards and wireless on which the same operating system is installed.

In order for us to configure Mikrotik, several methods can be used, the easiest of these methods is a graphical tool called WINBOX, which Mikrotik itself created, and you can always download its latest version from Mikrotik’s website (from Mikrotik’s website in the software section). Try to always use the latest version of this software to configure your routers.

One advantage of this software is that if your router is connected to your computer, as soon as winbox software runs, it will find your router and you can connect to it and configure it.

The Ways to connect to the Mikrotik router

1. Connecting to Mikrotik router through Winbox software:

Winbox software supports both Mac Address and IP Address, ie
The power was connected to the router through layer 2 and 3 communications. To download the software, we use the link https://www.mikrotik.com/download/winbox.exe or the internet address https://mikrotik.com/download

Winbox is designed and produced based on Windows operating system and we can run it on Linux and OS X by Wine software. To connect to RouterOS with factory default settings, we use admin username and password (blank) or no password.
Note: Winbox software uses MNDP or Mikrotik Neighbor Discovery Protocol
The list of RouterOS neighbors is displayed in the Neighbor tab, MNDP with UDP protocol and
Port 5678 works.

2- Connecting to the Mikrotik router through the WebFig web interface:

Communication through web browser software such as: Google Chrome – FireFox – Internet Explorer, … by default, there are a series of factory settings on RouterBOARD and Mikrotik RouterOS, one of these settings is the IP address with a range of 192.168 88.1/24 is on the router.

To access RouterOS settings by Webfig, use the address 192.168.88.1 with port 80
will be

3- Connecting to the Mikrotik router through Telnet, SSH

Communication through the command line interface, commands can be entered through related software such as Putty or Winbox Terminal. Style commands such as access path to program options
It is Winbox. For example, we use the following command to add the IP address.

ip address add address=192.168.1.1/24 interface=ether1

The above command adds the IP address 192.168.1.1 to port number one of the router.

Note: Valid commands can be completed using the Tab button.
Tip: Using characters? You can see the valid commands along with the description of each one in each section.
Note: By using the <↑>, >↓< buttons, you can view and execute the previous and next commands.

4- Connect to Mikrotik router through MAC-Telnet

Mikrotik’s unique router that can be used to connect between RouterOS through Mac Address

How can you Remove an IP or IPs in MikroTik VPS by CLI(Command Line Interface)?

In Mikrotik

We can use the ‘remove’ command to remove a certain configuration. But, we need ‘Item Number’ to use the ‘remove’ command. To get ‘Item Number,’ we have to use another command, ‘print.’

Or else, we can use the ‘find’ command. This will not be ‘OK’ for newbies.

In Cisco,

Just use ‘no’ to remove the configuration.

Example,

In Cisco,

interface FastEthernet 0/0

IP address 192.168.1.1 255.255.255.0

we want to remove IP address, and then no IP address 192.168.1.1 255.255.255.0

In Mikrotik,

/ip address

add address=192.168.1.1/24 interface=ether1

we want to remove IP address, then,

/ip address

print

# ADDRESS NETWORK INTERFACE

0 192.168.1.1/24 192.168.1.0 ether1

/ip address

remove 0

so, why can’t we use remove Like,

/ip address

remove address=192.168.1.1/24 interface=ether1

If yes,

It will be a lot easy to remove configuration scripting.

Cisco works differently from MikroTik.

These routers are both not for newbies. There are enough routers on the market that are much easier to configure than Cisco or MikroTik.I don’t think either of these manufacturers focuses on the newbies market.

One thing that could be interesting was to remove the rule with the opposite command of its creation.

Example:

add chain=AP_intra comment=”AP USA DNS Intranet” DST-port=53 protocol=udp -> This one create this rule

removechain=AP_intra comment=”AP USA DNS Intranet” DST-port=53 protocol=udp -> This one would remove the rule. The number system is good and should be kept. But this could simplify some scripts and whatnot.

How to edit and delete added IP address

So let’s learn about this issue’s main problems of the user Encounter.

nowadays, we are using

C# as my way of communicating to the rourterOS, we use the Api example there at the wiki api documentation and it works, our Issue is how to edit and remove the added IP Address, this is how we add new IP

router.Send(“/ip/address/add”);

router.Send(“=address=192.168.1.1/24”);

router.Send(“=network=10.10.10.0”);

router.Send(“=broadcast=10.10.10.255”);

router.Send(“=interface=ether1”);

router.Send(“=disabled=no”);

router.Send(“.tag=aaa”, true);

we attempted this statement for removing IP but an error happened

router.Send(“/ip/address/remove”);

router.Send(“=address=192.168.1.1/24”);

and for updating something like this

router.Send(“/ip/address/set”);

router.Send(“=address=192.168.1.1/24”);

by the way we are using the latest version of the routerOS

and for Solving The Problem you should

router.Send(“/ip/address/print”);

after that it will give you the IP address and the value number on the left most side, usually it is “0”

you can try this

router.Send(“/ip/address/remove/0”);

As you see, we have solved some of the users’ problems, so at the end of the Article, we Put a Video for Understanding better to Remove an IP or IPs in MikroTik VPS by CLI(Command Line Interface).